HBASE-25424 Find a way to config OpenTelemetry tracing without direct… (#2808)

Signed-off-by: Guanghao Zhang <zghao@apache.org>
This commit is contained in:
Duo Zhang 2020-12-24 18:37:16 +08:00 committed by Duo Zhang
parent 2420286715
commit 57960fa8fa
5 changed files with 40 additions and 1 deletions

View File

@ -480,6 +480,11 @@ add_jdk11_deps_to_classpath() {
done 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 #Add the development env class path stuff
if $in_dev_env; then if $in_dev_env; then
add_maven_deps_to_classpath "cached_classpath.txt" add_maven_deps_to_classpath "cached_classpath.txt"
@ -772,6 +777,11 @@ elif [ "${DEBUG}" = "true" ]; then
echo "JDK11 jars skipped from classpath." echo "JDK11 jars skipped from classpath."
fi 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' # 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 # 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: # 'cost' to have this flag enabled. Its a 1.6 flag only. See:

View File

@ -142,3 +142,8 @@
# Override text processing tools for use by these launch scripts. # Override text processing tools for use by these launch scripts.
# export GREP="${GREP-grep}" # export GREP="${GREP-grep}"
# export SED="${SED-sed}" # 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"

View File

@ -347,5 +347,11 @@
<groupId>org.apache.logging.log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId> <artifactId>log4j-1.2-api</artifactId>
</dependency> </dependency>
<!-- Include OpenTelemetry agent -->
<dependency>
<groupId>io.opentelemetry.javaagent</groupId>
<artifactId>opentelemetry-javaagent</artifactId>
<classifier>all</classifier>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -111,6 +111,7 @@
<exclude>org.apache.yetus:audience-annotations</exclude> <exclude>org.apache.yetus:audience-annotations</exclude>
<exclude>org.slf4j:*</exclude> <exclude>org.slf4j:*</exclude>
<exclude>org.apache.logging.log4j:*</exclude> <exclude>org.apache.logging.log4j:*</exclude>
<exclude>io.opentelemetry.javaagent:*</exclude>
</excludes> </excludes>
</dependencySet> </dependencySet>
</dependencySets> </dependencySets>
@ -221,7 +222,7 @@
<outputDirectory>lib/jdk11</outputDirectory> <outputDirectory>lib/jdk11</outputDirectory>
<useTransitiveDependencies>true</useTransitiveDependencies> <useTransitiveDependencies>true</useTransitiveDependencies>
<includes> <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 <!-- 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 They are needed to be included in lib/jdk11 to be added to classpath during
Java 11 runtime Java 11 runtime
@ -253,6 +254,12 @@
<include>jakarta.jws:jakarta.jws-api</include> <include>jakarta.jws:jakarta.jws-api</include>
</includes> </includes>
</dependencySet> </dependencySet>
<dependencySet>
<outputDirectory>lib/trace</outputDirectory>
<includes>
<include>io.opentelemetry.javaagent:*</include>
</includes>
</dependencySet>
</dependencySets> </dependencySets>
</assembly> </assembly>

11
pom.xml
View File

@ -1718,7 +1718,12 @@
<junit.version>4.13</junit.version> <junit.version>4.13</junit.version>
<hamcrest.version>1.3</hamcrest.version> <hamcrest.version>1.3</hamcrest.version>
<opentelemetry.version>0.13.1</opentelemetry.version> <opentelemetry.version>0.13.1</opentelemetry.version>
<<<<<<< HEAD
<log4j2.version>2.14.1</log4j2.version> <log4j2.version>2.14.1</log4j2.version>
=======
<opentelemetry-instrumentation.version>0.13.0</opentelemetry-instrumentation.version>
<log4j.version>1.2.17</log4j.version>
>>>>>>> HBASE-25424 Find a way to config OpenTelemetry tracing without direct… (#2808)
<mockito-core.version>2.28.2</mockito-core.version> <mockito-core.version>2.28.2</mockito-core.version>
<protobuf.plugin.version>0.6.1</protobuf.plugin.version> <protobuf.plugin.version>0.6.1</protobuf.plugin.version>
<thrift.path>thrift</thrift.path> <thrift.path>thrift</thrift.path>
@ -2407,6 +2412,12 @@
<artifactId>opentelemetry-sdk-testing</artifactId> <artifactId>opentelemetry-sdk-testing</artifactId>
<version>${opentelemetry.version}</version> <version>${opentelemetry.version}</version>
</dependency> </dependency>
<dependency>
<groupId>io.opentelemetry.javaagent</groupId>
<artifactId>opentelemetry-javaagent</artifactId>
<version>${opentelemetry-instrumentation.version}</version>
<classifier>all</classifier>
</dependency>
<dependency> <dependency>
<groupId>com.lmax</groupId> <groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId> <artifactId>disruptor</artifactId>