diff --git a/bin/hbase b/bin/hbase index ef1ff3d2b21f..2f27270276c8 100755 --- a/bin/hbase +++ b/bin/hbase @@ -480,6 +480,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" @@ -772,6 +777,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 e0f9c01bc995..e1dff2b7e3e2 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 160293ceb3ea..16056e01ec04 100644 --- a/hbase-assembly/pom.xml +++ b/hbase-assembly/pom.xml @@ -347,5 +347,11 @@ org.apache.logging.log4j log4j-1.2-api + + + io.opentelemetry.javaagent + opentelemetry-javaagent + all + diff --git a/hbase-assembly/src/main/assembly/hadoop-three-compat.xml b/hbase-assembly/src/main/assembly/hadoop-three-compat.xml index ab2a4c5ede8a..8d4eaf60de0c 100644 --- a/hbase-assembly/src/main/assembly/hadoop-three-compat.xml +++ b/hbase-assembly/src/main/assembly/hadoop-three-compat.xml @@ -111,6 +111,7 @@ org.apache.yetus:audience-annotations org.slf4j:* org.apache.logging.log4j:* + io.opentelemetry.javaagent:* @@ -221,7 +222,7 @@ lib/jdk11 true - com.sun.activation:javax.activation + com.sun.activation:javax.activation