You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2020/12/26 05:10:44 UTC

[hbase] 03/03: HBASE-25424 Find a way to config OpenTelemetry tracing without direct… (#2808)

This is an automated email from the ASF dual-hosted git repository.

zhangduo pushed a commit to branch HBASE-22120
in repository https://gitbox.apache.org/repos/asf/hbase.git

commit 1f88968f6f81c4dba9f02e13861ea48f0a54ea8b
Author: Duo Zhang <zh...@apache.org>
AuthorDate: Thu Dec 24 18:37:16 2020 +0800

    HBASE-25424 Find a way to config OpenTelemetry tracing without direct… (#2808)
    
    Signed-off-by: Guanghao Zhang <zg...@apache.org>
---
 bin/hbase                                                | 10 ++++++++++
 conf/hbase-env.sh                                        |  5 +++++
 hbase-assembly/pom.xml                                   |  6 ++++++
 hbase-assembly/src/main/assembly/hadoop-three-compat.xml |  9 ++++++++-
 pom.xml                                                  |  7 +++++++
 5 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/bin/hbase b/bin/hbase
index d2307c5..496ce49 100755
--- a/bin/hbase
+++ b/bin/hbase
@@ -475,6 +475,11 @@ add_jdk11_deps_to_classpath() {
   done
 }
 
+enable_trace() {
+  agent_jar=$(find lib/trace -type f -name "opentelemetry-javaagent-*")
+  HBASE_OPTS="$HBASE_OPTS -javaagent:$agent_jar $HBASE_TRACE_OPTS"
+}
+
 #Add the development env class path stuff
 if $in_dev_env; then
   add_maven_deps_to_classpath "cached_classpath.txt"
@@ -767,6 +772,11 @@ elif [ "${DEBUG}" = "true" ]; then
   echo "JDK11 jars skipped from classpath."
 fi
 
+if [[ -n "${HBASE_TRACE_OPTS}" ]]; then
+  echo "Attach opentelemetry agent to enable trace"
+  enable_trace
+fi
+
 # Have JVM dump heap if we run out of memory.  Files will be 'launch directory'
 # and are named like the following: java_pid21612.hprof. Apparently it doesn't
 # 'cost' to have this flag enabled. Its a 1.6 flag only. See:
diff --git a/conf/hbase-env.sh b/conf/hbase-env.sh
index e0f9c01..e1dff2b 100644
--- a/conf/hbase-env.sh
+++ b/conf/hbase-env.sh
@@ -142,3 +142,8 @@
 # Override text processing tools for use by these launch scripts.
 # export GREP="${GREP-grep}"
 # export SED="${SED-sed}"
+
+# Uncomment to enable trace, you can change the options to use other exporters such as jaeger or
+# zipkin. See https://github.com/open-telemetry/opentelemetry-java-instrumentation on how to config
+# exporters and other components through system properties.
+# export HBASE_TRACE_OPTS="-Dotel.config.sampler.probability=0.1 -Dotel.exporter=logging"
diff --git a/hbase-assembly/pom.xml b/hbase-assembly/pom.xml
index 8053517..248f0ce 100644
--- a/hbase-assembly/pom.xml
+++ b/hbase-assembly/pom.xml
@@ -339,5 +339,11 @@
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
     </dependency>
+    <!-- Include OpenTelemetry agent -->
+    <dependency>
+      <groupId>io.opentelemetry.javaagent</groupId>
+      <artifactId>opentelemetry-javaagent</artifactId>
+      <classifier>all</classifier>
+    </dependency>
   </dependencies>
 </project>
diff --git a/hbase-assembly/src/main/assembly/hadoop-three-compat.xml b/hbase-assembly/src/main/assembly/hadoop-three-compat.xml
index 1c172e9..25d533b 100644
--- a/hbase-assembly/src/main/assembly/hadoop-three-compat.xml
+++ b/hbase-assembly/src/main/assembly/hadoop-three-compat.xml
@@ -113,6 +113,7 @@
               <exclude>org.apache.yetus:audience-annotations</exclude>
               <exclude>org.slf4j:slf4j-api</exclude>
               <exclude>org.slf4j:slf4j-log4j12</exclude>
+              <exclude>io.opentelemetry.javaagent:*</exclude>
             </excludes>
           </dependencySet>
         </dependencySets>
@@ -225,7 +226,7 @@
       <outputDirectory>lib/jdk11</outputDirectory>
       <useTransitiveDependencies>true</useTransitiveDependencies>
       <includes>
-          <include>com.sun.activation:javax.activation</include>
+        <include>com.sun.activation:javax.activation</include>
         <!-- The following artifacts are transitive dependencies of com.sun.xml.ws:jaxws-ri:pom
              They are needed to be included in lib/jdk11 to be added to classpath during
              Java 11 runtime
@@ -257,6 +258,12 @@
         <include>jakarta.jws:jakarta.jws-api</include>
       </includes>
     </dependencySet>
+    <dependencySet>
+      <outputDirectory>lib/trace</outputDirectory>
+      <includes>
+        <include>io.opentelemetry.javaagent:*</include>
+      </includes>
+    </dependencySet>
   </dependencySets>
 
 </assembly>
diff --git a/pom.xml b/pom.xml
index 1fd42e0..da1f7e4 100755
--- a/pom.xml
+++ b/pom.xml
@@ -1653,6 +1653,7 @@
     <junit.version>4.13</junit.version>
     <hamcrest.version>1.3</hamcrest.version>
     <opentelemetry.version>0.13.1</opentelemetry.version>
+    <opentelemetry-instrumentation.version>0.13.0</opentelemetry-instrumentation.version>
     <log4j.version>1.2.17</log4j.version>
     <mockito-core.version>2.28.2</mockito-core.version>
     <protobuf.plugin.version>0.6.1</protobuf.plugin.version>
@@ -2334,6 +2335,12 @@
         <version>${opentelemetry.version}</version>
       </dependency>
       <dependency>
+        <groupId>io.opentelemetry.javaagent</groupId>
+        <artifactId>opentelemetry-javaagent</artifactId>
+        <version>${opentelemetry-instrumentation.version}</version>
+        <classifier>all</classifier>
+      </dependency>
+      <dependency>
         <groupId>com.lmax</groupId>
         <artifactId>disruptor</artifactId>
         <version>${disruptor.version}</version>