Skip to content

Commit 81a2f73

Browse files
committed
change java-agent order
TODO: also validate hash for it
1 parent 9881eba commit 81a2f73

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh

+22-21
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,6 @@ if [[ ! -e "${CONF}/hugegraph-server.keystore" ]]; then
6969
download "${CONF}" "${GITHUB}/apache/hugegraph-doc/raw/binary-1.0/dist/server/hugegraph-server.keystore"
7070
fi
7171

72-
if [ "${OPEN_TELEMETRY}" == "true" ]; then
73-
OT_JAR="opentelemetry-javaagent.jar"
74-
if [[ ! -e "${PLUGINS}/${OT_JAR}" ]]; then
75-
echo "Downloading ${OT_JAR}..."
76-
download "${PLUGINS}" \
77-
"${GITHUB}/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.1.0/${OT_JAR}"
78-
fi
79-
80-
export JAVA_TOOL_OPTIONS="-javaagent:${PLUGINS}/${OT_JAR}"
81-
export OTEL_TRACES_EXPORTER=otlp
82-
export OTEL_METRICS_EXPORTER=none
83-
export OTEL_LOGS_EXPORTER=none
84-
export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=grpc
85-
# 127.0.0.1:4317 is the port of otel-collector running in Docker located in
86-
# 'hugegraph-server/hugegraph-dist/docker/example/docker-compose-trace.yaml'.
87-
# Make sure the otel-collector is running before starting HugeGraphServer.
88-
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://127.0.0.1:4317
89-
export OTEL_RESOURCE_ATTRIBUTES=service.name=server
90-
fi
91-
9272
# Add the slf4j-log4j12 binding
9373
CP=$(find -L $LIB -name 'log4j-slf4j-impl*.jar' | sort | tr '\n' ':')
9474
# Add the jars in lib that start with "hugegraph"
@@ -99,7 +79,7 @@ CP="$CP":$(find -L $LIB -name '*.jar' \
9979
\! -name 'log4j-slf4j-impl*.jar' | sort | tr '\n' ':')
10080
# Add the jars in ext (at any subdirectory depth)
10181
CP="$CP":$(find -L $EXT -name '*.jar' | sort | tr '\n' ':')
102-
# Add the jars in plugins (at any subdirectory depth)
82+
# Add the jars in plugins (at any subdirectory depth), check "javaagent" related jars carefully
10383
CP="$CP":$(find -L $PLUGINS -name '*.jar' | sort | tr '\n' ':')
10484

10585
# (Cygwin only) Use ; classpath separator and reformat paths for Windows ("C:\foo")
@@ -171,6 +151,27 @@ if [[ ${OPEN_SECURITY_CHECK} == "true" ]]; then
171151
JVM_OPTIONS="${JVM_OPTIONS} -Djava.security.manager=org.apache.hugegraph.security.HugeSecurityManager"
172152
fi
173153

154+
if [ "${OPEN_TELEMETRY}" == "true" ]; then
155+
OT_JAR="opentelemetry-javaagent.jar"
156+
if [[ ! -e "${PLUGINS}/${OT_JAR}" ]]; then
157+
echo "## Downloading ${OT_JAR}..."
158+
download "${PLUGINS}" \
159+
"${GITHUB}/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.1.0/${OT_JAR}"
160+
fi
161+
162+
# Note: check carefully if multi "javeagent" params are set
163+
export JAVA_TOOL_OPTIONS="-javaagent:${PLUGINS}/${OT_JAR}"
164+
export OTEL_TRACES_EXPORTER=otlp
165+
export OTEL_METRICS_EXPORTER=none
166+
export OTEL_LOGS_EXPORTER=none
167+
export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=grpc
168+
# 127.0.0.1:4317 is the port of otel-collector running in Docker located in
169+
# 'hugegraph-server/hugegraph-dist/docker/example/docker-compose-trace.yaml'.
170+
# Make sure the otel-collector is running before starting HugeGraphServer.
171+
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://127.0.0.1:4317
172+
export OTEL_RESOURCE_ATTRIBUTES=service.name=server
173+
fi
174+
174175
# Turn on security check
175176
exec ${JAVA} -Dname="HugeGraphServer" ${JVM_OPTIONS} ${JAVA_OPTIONS} -cp ${CLASSPATH}: \
176177
org.apache.hugegraph.dist.HugeGraphServer ${GREMLIN_SERVER_CONF} ${REST_SERVER_CONF} \

hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ PID_FILE="$BIN/pid"
4646

4747
. "$BIN"/util.sh
4848

49+
# Note: keep ':' in the end of the string to indicate the option needs a value
4950
while getopts "d:g:m:p:s:j:t:y:" arg; do
5051
case ${arg} in
5152
d) DAEMON="$OPTARG" ;;
@@ -93,6 +94,7 @@ if [[ $PRELOAD == "true" ]]; then
9394
sed -i -e '/registerRocksDB/d; /serverStarted/d' "${SCRIPTS}/${EXAMPLE_SCRIPT}"
9495
fi
9596

97+
# TODO: show the output message in hugegraph-server.sh when start the server
9698
if [[ $DAEMON == "true" ]]; then
9799
echo "Starting HugeGraphServer in daemon mode..."
98100
"${BIN}"/hugegraph-server.sh "${CONF}/${GREMLIN_SERVER_CONF}" "${CONF}"/rest-server.properties \

0 commit comments

Comments
 (0)