From aa6a242a0438262d48eebfa4e0b2eb032ded8148 Mon Sep 17 00:00:00 2001 From: Min Xia Date: Wed, 23 Oct 2024 17:15:31 -0700 Subject: [PATCH] Allow customer to manipulate auto-insstrumention both enable/disable config --- .../packages/layer/scripts/otel-instrument | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) 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