Skip to content

Commit

Permalink
Allow customer to manipulate auto-insstrumention both enable/disable …
Browse files Browse the repository at this point in the history
…config
  • Loading branch information
mxiamxia committed Oct 24, 2024
1 parent a043f25 commit aa6a242
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions lambda-layer/packages/layer/scripts/otel-instrument
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,22 @@ if [ -z "${OTEL_EXPORTER_OTLP_PROTOCOL}" ]; then
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
fi

# - If OTEL_NODE_ENABLED_INSTRUMENTATIONS is not set by user, use default instrumentation
if [ -z "${OTEL_NODE_ENABLED_INSTRUMENTATIONS}" ]; then
export OTEL_NODE_ENABLED_INSTRUMENTATIONS="aws-lambda,aws-sdk"
# If both OTEL_NODE_ENABLED_INSTRUMENTATIONS and OTEL_NODE_DISABLED_INSTRUMENTATIONS are not configured,
# set OTEL_NODE_ENABLED_INSTRUMENTATIONS="aws-sdk,aws-lambda"
if [ -z "${OTEL_NODE_ENABLED_INSTRUMENTATIONS}" ] && [ -z "${OTEL_NODE_DISABLED_INSTRUMENTATIONS}" ]; then
export OTEL_NODE_ENABLED_INSTRUMENTATIONS="aws-sdk,aws-lambda"

# Else if OTEL_NODE_ENABLED_INSTRUMENTATIONS is configured and OTEL_NODE_DISABLED_INSTRUMENTATIONS is not,
# append OTEL_NODE_ENABLED_INSTRUMENTATIONS with "aws-lambda"
elif [ -n "${OTEL_NODE_ENABLED_INSTRUMENTATIONS}" ] && [ -z "${OTEL_NODE_DISABLED_INSTRUMENTATIONS}" ]; then
export OTEL_NODE_ENABLED_INSTRUMENTATIONS="${OTEL_NODE_ENABLED_INSTRUMENTATIONS},aws-lambda"

# Else if both OTEL_NODE_ENABLED_INSTRUMENTATIONS and OTEL_NODE_DISABLED_INSTRUMENTATIONS are configured,
# append OTEL_NODE_ENABLED_INSTRUMENTATIONS with "aws-lambda"
elif [ -n "${OTEL_NODE_ENABLED_INSTRUMENTATIONS}" ] && [ -n "${OTEL_NODE_DISABLED_INSTRUMENTATIONS}" ]; then
export OTEL_NODE_ENABLED_INSTRUMENTATIONS="${OTEL_NODE_ENABLED_INSTRUMENTATIONS},aws-lambda"

# Else do nothing
fi

# - Set the service name
Expand Down

0 comments on commit aa6a242

Please sign in to comment.