Skip to content

Commit 57960fa

Browse files
committed
HBASE-25424 Find a way to config OpenTelemetry tracing without direct… (#2808)
Signed-off-by: Guanghao Zhang <zghao@apache.org>
1 parent 2420286 commit 57960fa

5 files changed

Lines changed: 40 additions & 1 deletion

File tree

bin/hbase

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,11 @@ add_jdk11_deps_to_classpath() {
480480
done
481481
}
482482

483+
enable_trace() {
484+
agent_jar=$(find lib/trace -type f -name "opentelemetry-javaagent-*")
485+
HBASE_OPTS="$HBASE_OPTS -javaagent:$agent_jar $HBASE_TRACE_OPTS"
486+
}
487+
483488
#Add the development env class path stuff
484489
if $in_dev_env; then
485490
add_maven_deps_to_classpath "cached_classpath.txt"
@@ -772,6 +777,11 @@ elif [ "${DEBUG}" = "true" ]; then
772777
echo "JDK11 jars skipped from classpath."
773778
fi
774779

780+
if [[ -n "${HBASE_TRACE_OPTS}" ]]; then
781+
echo "Attach opentelemetry agent to enable trace"
782+
enable_trace
783+
fi
784+
775785
# Have JVM dump heap if we run out of memory. Files will be 'launch directory'
776786
# and are named like the following: java_pid21612.hprof. Apparently it doesn't
777787
# 'cost' to have this flag enabled. Its a 1.6 flag only. See:

conf/hbase-env.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,8 @@
142142
# Override text processing tools for use by these launch scripts.
143143
# export GREP="${GREP-grep}"
144144
# export SED="${SED-sed}"
145+
146+
# Uncomment to enable trace, you can change the options to use other exporters such as jaeger or
147+
# zipkin. See https://github.com/open-telemetry/opentelemetry-java-instrumentation on how to config
148+
# exporters and other components through system properties.
149+
# export HBASE_TRACE_OPTS="-Dotel.config.sampler.probability=0.1 -Dotel.exporter=logging"

hbase-assembly/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,5 +347,11 @@
347347
<groupId>org.apache.logging.log4j</groupId>
348348
<artifactId>log4j-1.2-api</artifactId>
349349
</dependency>
350+
<!-- Include OpenTelemetry agent -->
351+
<dependency>
352+
<groupId>io.opentelemetry.javaagent</groupId>
353+
<artifactId>opentelemetry-javaagent</artifactId>
354+
<classifier>all</classifier>
355+
</dependency>
350356
</dependencies>
351357
</project>

hbase-assembly/src/main/assembly/hadoop-three-compat.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
<exclude>org.apache.yetus:audience-annotations</exclude>
112112
<exclude>org.slf4j:*</exclude>
113113
<exclude>org.apache.logging.log4j:*</exclude>
114+
<exclude>io.opentelemetry.javaagent:*</exclude>
114115
</excludes>
115116
</dependencySet>
116117
</dependencySets>
@@ -221,7 +222,7 @@
221222
<outputDirectory>lib/jdk11</outputDirectory>
222223
<useTransitiveDependencies>true</useTransitiveDependencies>
223224
<includes>
224-
<include>com.sun.activation:javax.activation</include>
225+
<include>com.sun.activation:javax.activation</include>
225226
<!-- The following artifacts are transitive dependencies of com.sun.xml.ws:jaxws-ri:pom
226227
They are needed to be included in lib/jdk11 to be added to classpath during
227228
Java 11 runtime
@@ -253,6 +254,12 @@
253254
<include>jakarta.jws:jakarta.jws-api</include>
254255
</includes>
255256
</dependencySet>
257+
<dependencySet>
258+
<outputDirectory>lib/trace</outputDirectory>
259+
<includes>
260+
<include>io.opentelemetry.javaagent:*</include>
261+
</includes>
262+
</dependencySet>
256263
</dependencySets>
257264

258265
</assembly>

pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,12 @@
17181718
<junit.version>4.13</junit.version>
17191719
<hamcrest.version>1.3</hamcrest.version>
17201720
<opentelemetry.version>0.13.1</opentelemetry.version>
1721+
<<<<<<< HEAD
17211722
<log4j2.version>2.14.1</log4j2.version>
1723+
=======
1724+
<opentelemetry-instrumentation.version>0.13.0</opentelemetry-instrumentation.version>
1725+
<log4j.version>1.2.17</log4j.version>
1726+
>>>>>>> HBASE-25424 Find a way to config OpenTelemetry tracing without direct… (#2808)
17221727
<mockito-core.version>2.28.2</mockito-core.version>
17231728
<protobuf.plugin.version>0.6.1</protobuf.plugin.version>
17241729
<thrift.path>thrift</thrift.path>
@@ -2407,6 +2412,12 @@
24072412
<artifactId>opentelemetry-sdk-testing</artifactId>
24082413
<version>${opentelemetry.version}</version>
24092414
</dependency>
2415+
<dependency>
2416+
<groupId>io.opentelemetry.javaagent</groupId>
2417+
<artifactId>opentelemetry-javaagent</artifactId>
2418+
<version>${opentelemetry-instrumentation.version}</version>
2419+
<classifier>all</classifier>
2420+
</dependency>
24102421
<dependency>
24112422
<groupId>com.lmax</groupId>
24122423
<artifactId>disruptor</artifactId>

0 commit comments

Comments
 (0)