Skip to content

Commit e782ec0

Browse files
committed
HBASE-26363 OpenTelemetry configuration support for per-process service names
Exposes process-specific tracing arguments for most of the commands that we can launch from `bin/hbase`. In addition to serving as an on/off flag, `HBASE_TRACE_OPTS` acts as the site-wide configuration setting. Additional variables are provided for each applicable command, giving operators fine-grain control over which processes participate in the tracing system, and to what degree. Signed-off-by: Tak Lon (Stephen) Wu <taklwu@apache.org> Signed-off-by: Josh Elser <elserj@apache.org>
1 parent 6a78f0f commit e782ec0

2 files changed

Lines changed: 30 additions & 5 deletions

File tree

bin/hbase

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,9 @@ add_jdk11_deps_to_classpath() {
493493
}
494494

495495
add_opentelemetry_agent() {
496-
if ! agent_jar=$(find lib/trace -type f -name "opentelemetry-javaagent-*" 2>/dev/null); then
496+
if [ -e "${OPENTELEMETRY_JAVAAGENT_PATH}" ] ; then
497+
agent_jar="${OPENTELEMETRY_JAVAAGENT_PATH}"
498+
elif ! agent_jar=$(find -L "${HBASE_HOME}/lib/trace" -type f -name "opentelemetry-javaagent-*" 2>/dev/null); then
497499
# must be dev environment
498500
f="${HBASE_HOME}/hbase-build-configuration/target/cached_classpath.txt"
499501
if [ ! -f "${f}" ]; then
@@ -502,7 +504,7 @@ add_opentelemetry_agent() {
502504
fi
503505
agent_jar=$(tr ':' '\n' < "${f}" | grep opentelemetry-javaagent)
504506
fi
505-
HBASE_OPTS="$HBASE_OPTS -javaagent:$agent_jar $HBASE_TRACE_OPTS"
507+
HBASE_OPTS="$HBASE_OPTS -javaagent:$agent_jar"
506508
}
507509

508510
#Add the development env class path stuff
@@ -565,6 +567,7 @@ elif [ "$COMMAND" = 'jshell' ] ; then
565567
CLASS='jdk.internal.jshell.tool.JShellToolProvider'
566568
# set default values for HBASE_JSHELL_ARGS
567569
read -r -a JSHELL_ARGS <<< "${HBASE_JSHELL_ARGS:-"--startup DEFAULT --startup PRINTING --startup ${HBASE_HOME}/bin/hbase_startup.jsh"}"
570+
HBASE_OPTS="$HBASE_OPTS $HBASE_JSHELL_OPTS"
568571
elif [ "$COMMAND" = "hbck" ] ; then
569572
# Look for the -j /path/to/HBCK2.jar parameter. Else pass through to hbck.
570573
case "${1}" in

conf/hbase-env.sh

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,32 @@
143143
# export GREP="${GREP-grep}"
144144
# export SED="${SED-sed}"
145145

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
146+
# Tracing
147+
# Uncomment some combination of these lines to enable tracing. You should change the options to use
148+
# the exporters appropriate to your environment. See
149+
# https://github.com/open-telemetry/opentelemetry-java-instrumentation for details on how to
148150
# configure exporters and other components through system properties.
149-
# export HBASE_TRACE_OPTS="-Dotel.resource.attributes=service.name=HBase -Dotel.traces.exporter=logging -Dotel.metrics.exporter=none"
151+
#
152+
# The presence HBASE_TRACE_OPTS indicates that tracing should be enabled, and serves as site-wide
153+
# settings.
154+
# export HBASE_TRACE_OPTS="-Dotel.traces.exporter=none -Dotel.metrics.exporter=none"
155+
#
156+
# Per-process configuration variables allow for fine-grained configuration control.
157+
# export HBASE_SHELL_OPTS="${HBASE_SHELL_OPTS} ${HBASE_TRACE_OPTS} -Dotel.resource.attributes=service.name=hbase-shell"
158+
# export HBASE_JSHELL_OPTS="${HBASE_JSHELL_OPTS} ${HBASE_TRACE_OPTS} -Dotel.resource.attributes=service.name=hbase-jshell"
159+
# export HBASE_HBCK_OPTS="${HBASE_HBCK_OPTS} ${HBASE_TRACE_OPTS} -Dotel.resource.attributes=service.name=hbase-hbck"
160+
# export HBASE_MASTER_OPTS="${HBASE_MASTER_OPTS} ${HBASE_TRACE_OPTS} -Dotel.resource.attributes=service.name=hbase-master"
161+
# export HBASE_REGIONSERVER_OPTS="${HBASE_REGIONSERVER_OPTS} ${HBASE_TRACE_OPTS} -Dotel.resource.attributes=service.name=hbase-regionserver"
162+
# export HBASE_THRIFT_OPTS="${HBASE_THRIFT_OPTS} ${HBASE_TRACE_OPTS} -Dotel.resource.attributes=service.name=hbase-thrift"
163+
# export HBASE_REST_OPTS="${HBASE_REST_OPTS} ${HBASE_TRACE_OPTS} -Dotel.resource.attributes=service.name=hbase-rest"
164+
# export HBASE_ZOOKEEPER_OPTS="${HBASE_ZOOKEEPER_OPTS} ${HBASE_TRACE_OPTS} -Dotel.resource.attributes=service.name=hbase-zookeeper"
165+
# export HBASE_PE_OPTS="${HBASE_PE_OPTS} ${HBASE_TRACE_OPTS} -Dotel.resource.attributes=service.name=hbase-performanceevaluation"
166+
# export HBASE_LTT_OPTS="${HBASE_LTT_OPTS} ${HBASE_TRACE_OPTS} -Dotel.resource.attributes=service.name=hbase-loadtesttool"
167+
# export HBASE_CANARY_OPTS="${HBASE_CANARY_OPTS} ${HBASE_TRACE_OPTS} -Dotel.resource.attributes=service.name=hbase-canary"
168+
# export HBASE_HBTOP_OPTS="${HBASE_HBTOP_OPTS} ${HBASE_TRACE_OPTS} -Dotel.resource.attributes=service.name=hbase-hbtop"
169+
#
170+
# Manually specify a value for OPENTELEMETRY_JAVAAGENT_PATH to override the autodiscovery mechanism
171+
# export OPENTELEMETRY_JAVAAGENT_PATH=""
150172

151173
# Additional argments passed to jshell invocation
152174
# export HBASE_JSHELL_ARGS="--startup DEFAULT --startup PRINTING --startup hbase_startup.jsh"

0 commit comments

Comments
 (0)