-
Notifications
You must be signed in to change notification settings - Fork 234
Expand file tree
/
Copy pathotel-handler
More file actions
executable file
·45 lines (34 loc) · 1.4 KB
/
otel-handler
File metadata and controls
executable file
·45 lines (34 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
set -ef -o pipefail
export JAVA_TOOL_OPTIONS="-javaagent:/opt/opentelemetry-javaagent.jar ${JAVA_TOOL_OPTIONS}"
if [[ $OTEL_RESOURCE_ATTRIBUTES != *"service.name="* ]]; then
export OTEL_RESOURCE_ATTRIBUTES="service.name=${AWS_LAMBDA_FUNCTION_NAME},${OTEL_RESOURCE_ATTRIBUTES}"
fi
CLOUD_ACCOUNT_ID=$(readlink /tmp/.otel-aws-account-id 2>/dev/null || true)
if [[ -n "$CLOUD_ACCOUNT_ID" && $OTEL_RESOURCE_ATTRIBUTES != *"cloud.account.id="* ]]; then
export OTEL_RESOURCE_ATTRIBUTES="cloud.account.id=${CLOUD_ACCOUNT_ID},${OTEL_RESOURCE_ATTRIBUTES}"
fi
if [[ -z "$OTEL_PROPAGATORS" ]]; then
export OTEL_PROPAGATORS="tracecontext,baggage,xray"
fi
export OTEL_INSTRUMENTATION_AWS_LAMBDA_FLUSH_TIMEOUT=10000
########################################
ARGS=("$@")
EXTRA_ARGS=()
if [ "${OTEL_JAVA_AGENT_FAST_STARTUP_ENABLED}" == "true" ]; then
echo "[OTEL] Enabling fast startup mode ..."
# Disable bytecode verification
EXTRA_ARGS+=("-Xverify:none")
# Be sure that tiered compilation is enabled
EXTRA_ARGS+=("-XX:+TieredCompilation")
# Stop tiered compilation at level 1
EXTRA_ARGS+=("-XX:TieredStopAtLevel=1")
for i in "${!ARGS[@]}"; do
# If tiered compilation is disabled, ignore it as we enable it at level 1 for fast startup
if [[ ${ARGS[i]} = "-XX:-TieredCompilation" ]]; then
unset 'ARGS[i]'
fi
done
fi
ARGS=("${ARGS[0]}" "${EXTRA_ARGS[@]}" "${ARGS[@]:1}")
exec "${ARGS[@]}"