Skip to content

Commit

Permalink
Renaming to otel-instrument and default configs (#956)
Browse files Browse the repository at this point in the history
  • Loading branch information
srprash authored Nov 27, 2024
1 parent 015c6db commit aa84018
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 25 deletions.
2 changes: 1 addition & 1 deletion lambda-layer/build-layer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ popd

## Copy ADOT Java Agent downloaded using Gradle task and bundle it with the Lambda handler script
cp "$SOURCEDIR"/build/javaagent/aws-opentelemetry-agent*.jar ./opentelemetry-javaagent.jar
zip -qr opentelemetry-javaagent-layer.zip opentelemetry-javaagent.jar otel-handler
zip -qr opentelemetry-javaagent-layer.zip opentelemetry-javaagent.jar otel-instrument
24 changes: 0 additions & 24 deletions lambda-layer/otel-handler

This file was deleted.

38 changes: 38 additions & 0 deletions lambda-layer/otel-instrument
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

export OTEL_INSTRUMENTATION_AWS_SDK_EXPERIMENTAL_SPAN_ATTRIBUTES=true

export OTEL_PROPAGATORS="${OTEL_PROPAGATORS:-xray,tracecontext,b3,b3multi}"

export OTEL_SERVICE_NAME=${OTEL_SERVICE_NAME:-${AWS_LAMBDA_FUNCTION_NAME}}

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

export OTEL_INSTRUMENTATION_AWS_LAMBDA_FLUSH_TIMEOUT=10000

# Disable the Application Signals runtime metrics since we are on Lambda
export OTEL_AWS_APPLICATION_SIGNALS_RUNTIME_ENABLED=false

# Use OTLP traces exporter if not specified
export OTEL_TRACES_EXPORTER=${OTEL_TRACES_EXPORTER:-"otlp"}

# Disable metrics and logs export by default if not specified
export OTEL_METRICS_EXPORTER=${OTEL_METRICS_EXPORTER:-"none"}
export OTEL_LOGS_EXPORTER=${OTEL_LOGS_EXPORTER:-"none"}

# Enable Application Signals by default if not specified
export OTEL_AWS_APPLICATION_SIGNALS_ENABLED=${OTEL_AWS_APPLICATION_SIGNALS_ENABLED:-"true"}

# Append Lambda Resource Attributes to OTel Resource Attribute List
LAMBDA_RESOURCE_ATTRIBUTES="cloud.region=$AWS_REGION,cloud.provider=aws,faas.name=$AWS_LAMBDA_FUNCTION_NAME,faas.version=$AWS_LAMBDA_FUNCTION_VERSION,faas.instance=$AWS_LAMBDA_LOG_STREAM_NAME,aws.log.group.names=$AWS_LAMBDA_LOG_GROUP_NAME";
if [ -z "${OTEL_RESOURCE_ATTRIBUTES}" ]; then
export OTEL_RESOURCE_ATTRIBUTES=$LAMBDA_RESOURCE_ATTRIBUTES;
else
export OTEL_RESOURCE_ATTRIBUTES="$LAMBDA_RESOURCE_ATTRIBUTES,$OTEL_RESOURCE_ATTRIBUTES";
fi

exec "$@"

0 comments on commit aa84018

Please sign in to comment.