diff --git a/lambda-layer/packages/layer/scripts/otel-instrument b/lambda-layer/packages/layer/scripts/otel-instrument index 9366295..cdd55dd 100644 --- a/lambda-layer/packages/layer/scripts/otel-instrument +++ b/lambda-layer/packages/layer/scripts/otel-instrument @@ -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