Skip to content

Commit 2b0a46e

Browse files
authored
Allow customer to manipulate auto-insstrumention both enable/disable (#107)
*Description of changes:* Fully support NodeJS enable/disable configuration ``` if both OTEL_NODE_ENABLED_INSTRUMENTATIONS and OTEL_NODE_DISABLED_INSTRUMENTATIONS are not configured, set OTEL_NODE_ENABLED_INSTRUMENTATIONS="aws-sdk,aws-lambda" else if OTEL_NODE_ENABLED_INSTRUMENTATIONS is configure and OTEL_NODE_DISABLED_INSTRUMENTATIONS is not, append OTEL_NODE_ENABLED_INSTRUMENTATIONS with "aws-lambda" else if both OTEL_NODE_ENABLED_INSTRUMENTATIONS and OTEL_NODE_DISABLED_INSTRUMENTATIONS are configured, append OTEL_NODE_ENABLED_INSTRUMENTATIONS with "aws-lambda" else do nothing ``` By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent a043f25 commit 2b0a46e

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

lambda-layer/packages/layer/scripts/otel-instrument

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,22 @@ if [ -z "${OTEL_EXPORTER_OTLP_PROTOCOL}" ]; then
4343
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
4444
fi
4545

46-
# - If OTEL_NODE_ENABLED_INSTRUMENTATIONS is not set by user, use default instrumentation
47-
if [ -z "${OTEL_NODE_ENABLED_INSTRUMENTATIONS}" ]; then
48-
export OTEL_NODE_ENABLED_INSTRUMENTATIONS="aws-lambda,aws-sdk"
46+
# If both OTEL_NODE_ENABLED_INSTRUMENTATIONS and OTEL_NODE_DISABLED_INSTRUMENTATIONS are not configured,
47+
# set OTEL_NODE_ENABLED_INSTRUMENTATIONS="aws-sdk,aws-lambda"
48+
if [ -z "${OTEL_NODE_ENABLED_INSTRUMENTATIONS}" ] && [ -z "${OTEL_NODE_DISABLED_INSTRUMENTATIONS}" ]; then
49+
export OTEL_NODE_ENABLED_INSTRUMENTATIONS="aws-sdk,aws-lambda"
50+
51+
# Else if OTEL_NODE_ENABLED_INSTRUMENTATIONS is configured and OTEL_NODE_DISABLED_INSTRUMENTATIONS is not,
52+
# append OTEL_NODE_ENABLED_INSTRUMENTATIONS with "aws-lambda"
53+
elif [ -n "${OTEL_NODE_ENABLED_INSTRUMENTATIONS}" ] && [ -z "${OTEL_NODE_DISABLED_INSTRUMENTATIONS}" ]; then
54+
export OTEL_NODE_ENABLED_INSTRUMENTATIONS="${OTEL_NODE_ENABLED_INSTRUMENTATIONS},aws-lambda"
55+
56+
# Else if both OTEL_NODE_ENABLED_INSTRUMENTATIONS and OTEL_NODE_DISABLED_INSTRUMENTATIONS are configured,
57+
# append OTEL_NODE_ENABLED_INSTRUMENTATIONS with "aws-lambda"
58+
elif [ -n "${OTEL_NODE_ENABLED_INSTRUMENTATIONS}" ] && [ -n "${OTEL_NODE_DISABLED_INSTRUMENTATIONS}" ]; then
59+
export OTEL_NODE_ENABLED_INSTRUMENTATIONS="${OTEL_NODE_ENABLED_INSTRUMENTATIONS},aws-lambda"
60+
61+
# Else do nothing
4962
fi
5063

5164
# - Set the service name

0 commit comments

Comments
 (0)