Update the agent HBase plugin to support HBase Client 2.x (#6577)
This commit is contained in:
parent
35d7a520c5
commit
51b60ae218
|
|
@ -24,6 +24,7 @@ Release Notes.
|
|||
* Collect and report agent starting / shutdown events.
|
||||
* Support jedis pipeline in jedis-2.x-plugin.
|
||||
* Fix apm-toolkit-log4j-2.x-activation no trace Id in async log.
|
||||
* Replace hbase-1.x-plugin with hbase-1.x-2.x-plugin to adapt hbase client 2.x
|
||||
|
||||
#### OAP-Backend
|
||||
* Allow user-defined `JAVA_OPTS` in the startup script.
|
||||
|
|
|
|||
|
|
@ -26,12 +26,12 @@
|
|||
<version>8.5.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>apm-hbase-1.x-plugin</artifactId>
|
||||
<artifactId>apm-hbase-1.x-2.x-plugin</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>hbase-1.x-plugin</name>
|
||||
<name>hbase-1.x-2.x-plugin</name>
|
||||
|
||||
<properties>
|
||||
<hbase-client.version>1.4.9</hbase-client.version>
|
||||
<hbase-client.version>2.4.1</hbase-client.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.plugin.hbase;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Properties;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.client.ClusterConnection;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
|
||||
import org.apache.skywalking.apm.util.StringUtil;
|
||||
|
||||
public class HTable100Interceptor extends HTableInterceptor {
|
||||
|
||||
@Override
|
||||
public void onConstruct(EnhancedInstance objInst, Object[] allArguments) throws Throwable {
|
||||
Configuration configuration = ((ClusterConnection) allArguments[1]).getConfiguration();
|
||||
Field field = configuration.getClass().getDeclaredField("overlay");
|
||||
field.setAccessible(true);
|
||||
Properties properties = (Properties) field.get(configuration);
|
||||
String value = properties.getProperty("hbase.zookeeper.quorum");
|
||||
if (StringUtil.isNotBlank(value)) {
|
||||
objInst.setSkyWalkingDynamicField(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.plugin.hbase;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Properties;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.client.ClusterConnection;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
|
||||
import org.apache.skywalking.apm.util.StringUtil;
|
||||
|
||||
public class HTable200Interceptor extends HTableInterceptor {
|
||||
|
||||
@Override
|
||||
public void onConstruct(EnhancedInstance objInst, Object[] allArguments) throws Throwable {
|
||||
Configuration configuration = ((ClusterConnection) allArguments[0]).getConfiguration();
|
||||
Field field = configuration.getClass().getDeclaredField("overlay");
|
||||
field.setAccessible(true);
|
||||
Properties properties = (Properties) field.get(configuration);
|
||||
String value = properties.getProperty("hbase.zookeeper.quorum");
|
||||
if (StringUtil.isNotBlank(value)) {
|
||||
objInst.setSkyWalkingDynamicField(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.plugin.hbase;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Properties;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.client.Connection;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
|
||||
import org.apache.skywalking.apm.util.StringUtil;
|
||||
|
||||
public class HTable220Interceptor extends HTableInterceptor {
|
||||
|
||||
@Override
|
||||
public void onConstruct(EnhancedInstance objInst, Object[] allArguments) throws Throwable {
|
||||
Method getConfigurationMethod = Connection.class.getMethod("getConfiguration");
|
||||
Configuration configuration = (Configuration) getConfigurationMethod.invoke(allArguments[0]);
|
||||
Field field = configuration.getClass().getDeclaredField("overlay");
|
||||
field.setAccessible(true);
|
||||
Properties properties = (Properties) field.get(configuration);
|
||||
String value = properties.getProperty("hbase.zookeeper.quorum");
|
||||
if (StringUtil.isNotBlank(value)) {
|
||||
objInst.setSkyWalkingDynamicField(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -47,11 +47,22 @@ import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
|||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
|
||||
import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
|
||||
|
||||
/**
|
||||
* There have several interceptors to adapt different version hbase client. We use the minimal compatible version to
|
||||
* name the Interceptor. eg.
|
||||
* <p>HTable100Interceptor, 100 means version 1.0.0, compatible with version [1.0.0, 2.0.0)</p>
|
||||
* <p>HTable200Interceptor, 200 means version 2.0.0, compatible with version [2.0.0, 2.2.0)</p>
|
||||
* <p>HTable220Interceptor, 220 means version 2.2.0, compatible with version [2.2.0, )</p>
|
||||
*/
|
||||
public class HTableInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
|
||||
|
||||
private static final String ENHANCE_CLASS = "org.apache.hadoop.hbase.client.HTable";
|
||||
private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.hbase.HTableInterceptor";
|
||||
private static final String INTERCEPT_CLASS_100 = "org.apache.skywalking.apm.plugin.hbase.HTable100Interceptor";
|
||||
private static final String INTERCEPT_CLASS_200 = "org.apache.skywalking.apm.plugin.hbase.HTable200Interceptor";
|
||||
private static final String INTERCEPT_CLASS_220 = "org.apache.skywalking.apm.plugin.hbase.HTable220Interceptor";
|
||||
|
||||
@Override
|
||||
protected ClassMatch enhanceClass() {
|
||||
|
|
@ -60,16 +71,44 @@ public class HTableInstrumentation extends ClassInstanceMethodsEnhancePluginDefi
|
|||
|
||||
@Override
|
||||
public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
|
||||
return new ConstructorInterceptPoint[]{
|
||||
return new ConstructorInterceptPoint[] {
|
||||
// compatible with version [1.0.0, 2.0.0)
|
||||
new ConstructorInterceptPoint() {
|
||||
@Override
|
||||
public ElementMatcher<MethodDescription> getConstructorMatcher() {
|
||||
return takesArguments(6);
|
||||
return takesArguments(6)
|
||||
.and(takesArgumentWithType(0, "org.apache.hadoop.hbase.TableName"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConstructorInterceptor() {
|
||||
return INTERCEPT_CLASS;
|
||||
return INTERCEPT_CLASS_100;
|
||||
}
|
||||
},
|
||||
// compatible with version [2.0.0, 2.2.0)
|
||||
new ConstructorInterceptPoint() {
|
||||
@Override
|
||||
public ElementMatcher<MethodDescription> getConstructorMatcher() {
|
||||
return takesArguments(5)
|
||||
.and(takesArgumentWithType(0, "org.apache.hadoop.hbase.client.ClusterConnection"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConstructorInterceptor() {
|
||||
return INTERCEPT_CLASS_200;
|
||||
}
|
||||
},
|
||||
// compatible with version [2.2.0, )
|
||||
new ConstructorInterceptPoint() {
|
||||
@Override
|
||||
public ElementMatcher<MethodDescription> getConstructorMatcher() {
|
||||
return takesArguments(5)
|
||||
.and(takesArgumentWithType(0, "org.apache.hadoop.hbase.client.ConnectionImplementation"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConstructorInterceptor() {
|
||||
return INTERCEPT_CLASS_220;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -77,12 +116,15 @@ public class HTableInstrumentation extends ClassInstanceMethodsEnhancePluginDefi
|
|||
|
||||
@Override
|
||||
public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
|
||||
return new InstanceMethodsInterceptPoint[]{
|
||||
return new InstanceMethodsInterceptPoint[] {
|
||||
new InstanceMethodsInterceptPoint() {
|
||||
@Override
|
||||
public ElementMatcher<MethodDescription> getMethodsMatcher() {
|
||||
return named("delete").or(named("put")).or(isPublic().and(named("get")))
|
||||
.or(named("getScanner").and(takesArguments(1))
|
||||
return named("delete")
|
||||
.or(named("put"))
|
||||
.or(isPublic().and(named("get")))
|
||||
.or(named("getScanner")
|
||||
.and(takesArguments(1))
|
||||
.and(takesArgument(0, named("org.apache.hadoop.hbase.client.Scan"))));
|
||||
}
|
||||
|
||||
|
|
@ -14,4 +14,4 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
hbase-1.x=org.apache.skywalking.apm.plugin.hbase.define.HTableInstrumentation
|
||||
hbase-1.x/2.x=org.apache.skywalking.apm.plugin.hbase.define.HTableInstrumentation
|
||||
|
|
@ -97,7 +97,7 @@
|
|||
<module>mariadb-2.x-plugin</module>
|
||||
<module>influxdb-2.x-plugin</module>
|
||||
<module>baidu-brpc-plugin</module>
|
||||
<module>hbase-1.x-plugin</module>
|
||||
<module>hbase-1.x-2.x-plugin</module>
|
||||
<module>graphql-plugin</module>
|
||||
<module>xxl-job-2.x-plugin</module>
|
||||
<module>thrift-plugin</module>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
- grpc-1.x
|
||||
- gson-2.8.x
|
||||
- h2-1.x
|
||||
- hbase-1.x
|
||||
- hbase-1.x/2.x
|
||||
- httpasyncclient-4.x
|
||||
- httpclient-3.x
|
||||
- httpclient-4.x
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ metrics based on the tracing data.
|
|||
* [Cassandra](https://github.com/apache/cassandra) 3.x
|
||||
* [cassandra-java-driver](https://github.com/datastax/java-driver) 3.7.0-3.7.2
|
||||
* HBase
|
||||
* [hbase-client](https://github.com/apache/hbase) HTable 1.x
|
||||
* [hbase-client](https://github.com/apache/hbase) HTable 1.0.0-2.4.2
|
||||
* Service Discovery
|
||||
* [Netflix Eureka](https://github.com/Netflix/eureka)
|
||||
* Distributed Coordination
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ depends_on:
|
|||
- hbase-server
|
||||
dependencies:
|
||||
hbase-server:
|
||||
image: harisekhon/hbase:1.4
|
||||
image: harisekhon/hbase:2.1
|
||||
hostname: hbase-server
|
||||
expose:
|
||||
- "2181"
|
||||
|
|
|
|||
|
|
@ -17,3 +17,5 @@
|
|||
1.2.6
|
||||
1.3.1
|
||||
1.4.9
|
||||
2.1.10
|
||||
2.4.2
|
||||
Loading…
Reference in New Issue