diff --git a/apm-sniffer/apm-sdk-plugin/hbase-1.x-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hbase/HTable100Interceptor.java b/apm-sniffer/apm-sdk-plugin/hbase-1.x-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hbase/HTable100Interceptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..3b3528a8e2a210cbe3fb75dd5f1a14526cdf4b1b
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/hbase-1.x-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hbase/HTable100Interceptor.java
@@ -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);
+ }
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/hbase-1.x-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hbase/HTable200Interceptor.java b/apm-sniffer/apm-sdk-plugin/hbase-1.x-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hbase/HTable200Interceptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..be23cba60029c9901c3841975737fd9ffc326cf3
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/hbase-1.x-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hbase/HTable200Interceptor.java
@@ -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);
+ }
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/hbase-1.x-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hbase/HTable220Interceptor.java b/apm-sniffer/apm-sdk-plugin/hbase-1.x-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hbase/HTable220Interceptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..4d8e224410a037f7542c7a40781fac44616ba594
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/hbase-1.x-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hbase/HTable220Interceptor.java
@@ -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);
+ }
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/hbase-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hbase/HTableInterceptor.java b/apm-sniffer/apm-sdk-plugin/hbase-1.x-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hbase/HTableInterceptor.java
similarity index 100%
rename from apm-sniffer/apm-sdk-plugin/hbase-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hbase/HTableInterceptor.java
rename to apm-sniffer/apm-sdk-plugin/hbase-1.x-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hbase/HTableInterceptor.java
diff --git a/apm-sniffer/apm-sdk-plugin/hbase-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hbase/define/HTableInstrumentation.java b/apm-sniffer/apm-sdk-plugin/hbase-1.x-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hbase/define/HTableInstrumentation.java
similarity index 58%
rename from apm-sniffer/apm-sdk-plugin/hbase-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hbase/define/HTableInstrumentation.java
rename to apm-sniffer/apm-sdk-plugin/hbase-1.x-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hbase/define/HTableInstrumentation.java
index af73efc9ac6f8ff9030c5c5f19fc4192664bc52b..7ca5d20d8f5aea5549bdef38ed4aecaa5e107ee3 100644
--- a/apm-sniffer/apm-sdk-plugin/hbase-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hbase/define/HTableInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/hbase-1.x-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hbase/define/HTableInstrumentation.java
@@ -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.
+ * HTable100Interceptor, 100 means version 1.0.0, compatible with version [1.0.0, 2.0.0)
+ * HTable200Interceptor, 200 means version 2.0.0, compatible with version [2.0.0, 2.2.0)
+ * HTable220Interceptor, 220 means version 2.2.0, compatible with version [2.2.0, )
+ */
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 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 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 getConstructorMatcher() {
+ return takesArguments(5)
+ .and(takesArgumentWithType(0, "org.apache.hadoop.hbase.client.ConnectionImplementation"));
+ }
+
+ @Override
+ public String getConstructorInterceptor() {
+ return INTERCEPT_CLASS_220;
}
}
};
@@ -77,13 +116,16 @@ public class HTableInstrumentation extends ClassInstanceMethodsEnhancePluginDefi
@Override
public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
- return new InstanceMethodsInterceptPoint[]{
+ return new InstanceMethodsInterceptPoint[] {
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher getMethodsMatcher() {
- 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"))));
+ 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"))));
}
@Override()
diff --git a/apm-sniffer/apm-sdk-plugin/hbase-1.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/hbase-1.x-2.x-plugin/src/main/resources/skywalking-plugin.def
similarity index 90%
rename from apm-sniffer/apm-sdk-plugin/hbase-1.x-plugin/src/main/resources/skywalking-plugin.def
rename to apm-sniffer/apm-sdk-plugin/hbase-1.x-2.x-plugin/src/main/resources/skywalking-plugin.def
index aad5b0238c0a6190bdd75bd49d7e1a0538493942..7e1acdded3b43b25a09b9c4a00c516206eacd1c5 100644
--- a/apm-sniffer/apm-sdk-plugin/hbase-1.x-plugin/src/main/resources/skywalking-plugin.def
+++ b/apm-sniffer/apm-sdk-plugin/hbase-1.x-2.x-plugin/src/main/resources/skywalking-plugin.def
@@ -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
\ No newline at end of file
+hbase-1.x/2.x=org.apache.skywalking.apm.plugin.hbase.define.HTableInstrumentation
\ No newline at end of file
diff --git a/apm-sniffer/apm-sdk-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/pom.xml
index 202ddef85078452755a00ac8f30687e424c4b751..2676756b95d256b757dc5e0e1acc4e2fe5b7112d 100644
--- a/apm-sniffer/apm-sdk-plugin/pom.xml
+++ b/apm-sniffer/apm-sdk-plugin/pom.xml
@@ -97,7 +97,7 @@
mariadb-2.x-plugin
influxdb-2.x-plugin
baidu-brpc-plugin
- hbase-1.x-plugin
+ hbase-1.x-2.x-plugin
graphql-plugin
xxl-job-2.x-plugin
thrift-plugin
diff --git a/docs/en/setup/service-agent/java-agent/Plugin-list.md b/docs/en/setup/service-agent/java-agent/Plugin-list.md
index b8e7c2bd6dd6c6a1672663d9b5807c9901cfdd71..41ba14d95ef08480af6051de8fe55280d0cf5262 100644
--- a/docs/en/setup/service-agent/java-agent/Plugin-list.md
+++ b/docs/en/setup/service-agent/java-agent/Plugin-list.md
@@ -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
diff --git a/docs/en/setup/service-agent/java-agent/Supported-list.md b/docs/en/setup/service-agent/java-agent/Supported-list.md
index dfc01aa05a36a0fb335e43924cae09ed544969f7..6b9ee71862b855bb08216813b788956d59f92675 100644
--- a/docs/en/setup/service-agent/java-agent/Supported-list.md
+++ b/docs/en/setup/service-agent/java-agent/Supported-list.md
@@ -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
diff --git a/test/plugin/scenarios/hbase-scenario/configuration.yml b/test/plugin/scenarios/hbase-scenario/configuration.yml
index 952b5c9b894b1de504f7270e103cd1df2122bd59..7cbd9239481e02733c765c87043d75f6844dfff8 100644
--- a/test/plugin/scenarios/hbase-scenario/configuration.yml
+++ b/test/plugin/scenarios/hbase-scenario/configuration.yml
@@ -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"
diff --git a/test/plugin/scenarios/hbase-scenario/support-version.list b/test/plugin/scenarios/hbase-scenario/support-version.list
index 6e0034bc110b4e9dca8a7dedc58bdd35da04dc9a..230dce131c03d0b29da4143943f07ca27f299287 100644
--- a/test/plugin/scenarios/hbase-scenario/support-version.list
+++ b/test/plugin/scenarios/hbase-scenario/support-version.list
@@ -16,4 +16,6 @@
1.2.6
1.3.1
-1.4.9
\ No newline at end of file
+1.4.9
+2.1.10
+2.4.2
\ No newline at end of file