diff --git a/java/build-layer.sh b/java/build-layer.sh index 8e4d01d..013f658 100755 --- a/java/build-layer.sh +++ b/java/build-layer.sh @@ -21,9 +21,15 @@ echo "Preparing Splunk layer" cd $DISTRO_DIR unzip -qo opentelemetry-java-wrapper.zip rm opentelemetry-java-wrapper.zip -mv otel-handler otel-handler-upstream -mv otel-stream-handler otel-stream-handler-upstream -mv otel-proxy-handler otel-proxy-handler-upstream +sed -i '2isource /opt/splunk-default-config' otel-handler +sed -i '2isource /opt/splunk-default-config' otel-stream-handler +sed -i '2isource /opt/splunk-default-config' otel-proxy-handler +sed -i '3isource /opt/splunk-java-config' otel-handler +sed -i '3isource /opt/splunk-java-config' otel-stream-handler +sed -i '3isource /opt/splunk-java-config' otel-proxy-handler +# proxy handler has one more special change +sed -i 's/io.opentelemetry.instrumentation.awslambdaevents.v2_2.TracingRequestApiGatewayWrapper/com.splunk.support.lambda.TracingRequestApiGatewayWrapper/g' otel-proxy-handler + popd # copy Splunk scripts (delegating to OTEL ones) diff --git a/java/scripts/otel-handler b/java/scripts/otel-handler deleted file mode 100755 index 306c911..0000000 --- a/java/scripts/otel-handler +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -source /opt/splunk-default-config -source /opt/splunk-java-config - -export OTEL_INSTRUMENTATION_AWS_LAMBDA_HANDLER="$_HANDLER" -export _HANDLER="io.opentelemetry.instrumentation.awslambdaevents.v2_2.TracingRequestWrapper" - -if [[ $OTEL_RESOURCE_ATTRIBUTES != *"service.name="* ]]; then - export OTEL_RESOURCE_ATTRIBUTES="service.name=${AWS_LAMBDA_FUNCTION_NAME},${OTEL_RESOURCE_ATTRIBUTES}" -fi - -exec "$@" \ No newline at end of file diff --git a/java/scripts/otel-proxy-handler b/java/scripts/otel-proxy-handler deleted file mode 100755 index 2054ab5..0000000 --- a/java/scripts/otel-proxy-handler +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -source /opt/splunk-default-config -source /opt/splunk-java-config - -export OTEL_INSTRUMENTATION_AWS_LAMBDA_HANDLER="$_HANDLER" -export _HANDLER="com.splunk.support.lambda.TracingRequestApiGatewayWrapper" - -if [[ $OTEL_RESOURCE_ATTRIBUTES != *"service.name="* ]]; then - export OTEL_RESOURCE_ATTRIBUTES="service.name=${AWS_LAMBDA_FUNCTION_NAME},${OTEL_RESOURCE_ATTRIBUTES}" -fi - -exec "$@" diff --git a/java/scripts/otel-stream-handler b/java/scripts/otel-stream-handler deleted file mode 100755 index c8ec6c0..0000000 --- a/java/scripts/otel-stream-handler +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -source /opt/splunk-default-config -source /opt/splunk-java-config - -export OTEL_INSTRUMENTATION_AWS_LAMBDA_HANDLER="$_HANDLER" -export _HANDLER="io.opentelemetry.instrumentation.awslambdacore.v1_0.TracingRequestStreamWrapper" - -if [[ $OTEL_RESOURCE_ATTRIBUTES != *"service.name="* ]]; then - export OTEL_RESOURCE_ATTRIBUTES="service.name=${AWS_LAMBDA_FUNCTION_NAME},${OTEL_RESOURCE_ATTRIBUTES}" -fi - -exec "$@" \ No newline at end of file diff --git a/nodejs/nodejs-otel-handler b/nodejs/nodejs-otel-handler index 93e29f6..2604db0 100755 --- a/nodejs/nodejs-otel-handler +++ b/nodejs/nodejs-otel-handler @@ -1,7 +1,4 @@ #!/bin/bash - -export OTEL_TRACES_EXPORTER="${OTEL_TRACES_EXPORTER:-otlp}" - source /opt/splunk-default-config export NODE_OPTIONS="${NODE_OPTIONS} --require /opt/wrapper.js" diff --git a/scripts/splunk-default-config b/scripts/splunk-default-config index de9f510..c263b8c 100755 --- a/scripts/splunk-default-config +++ b/scripts/splunk-default-config @@ -1,4 +1,7 @@ #!/bin/bash +# specifically unset these so language-level instrumentations won't talk directly to ingest +unset SPLUNK_REALM +unset SPLUNK_ACCESS_TOKEN # no otel metrics export OTEL_METRICS_EXPORTER=none @@ -14,42 +17,5 @@ export OTEL_PROPAGATORS="${OTEL_PROPAGATORS:-tracecontext,baggage}" # no sampling export OTEL_TRACES_SAMPLER="${OTEL_TRACES_SAMPLER:-always_on}" -# splunk token header if OLTP -if [[ -n "$SPLUNK_ACCESS_TOKEN" && "$OTEL_TRACES_EXPORTER" = "otlp" ]] -then - HEADER="X-SF-TOKEN=$SPLUNK_ACCESS_TOKEN," - export OTEL_EXPORTER_OTLP_TRACES_HEADERS="$HEADER""${OTEL_EXPORTER_OTLP_TRACES_HEADERS}" -fi - # default flush timeout if not set export OTEL_INSTRUMENTATION_AWS_LAMBDA_FLUSH_TIMEOUT="${OTEL_INSTRUMENTATION_AWS_LAMBDA_FLUSH_TIMEOUT:-30000}" - -# splunk REALM support -if [ -n "$SPLUNK_REALM" ] -then - - if [ -z "$SPLUNK_METRICS_ENDPOINT" ] - then - export SPLUNK_METRICS_ENDPOINT="https://ingest.${SPLUNK_REALM}.signalfx.com" - fi - - if [[ "$OTEL_TRACES_EXPORTER" = *"otlp"* && -z "$OTEL_EXPORTER_OTLP_TRACES_ENDPOINT" ]] - then - export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="https://ingest.${SPLUNK_REALM}.signalfx.com/v2/trace/otlp" - elif [[ "$OTEL_TRACES_EXPORTER" = *"jaeger"* && -z "$OTEL_EXPORTER_JAEGER_ENDPOINT" ]] - then - export OTEL_EXPORTER_JAEGER_ENDPOINT="https://ingest.${SPLUNK_REALM}.signalfx.com/v2/trace" - fi -fi - -# validation - realm must have token -if [[ -n "$SPLUNK_REALM" && -z "$SPLUNK_ACCESS_TOKEN" ]] -then - echo "[ERROR] SPLUNK_REALM is set, but SPLUNK_ACCESS_TOKEN is not set. To export data to Splunk Observability Cloud, define a Splunk Access Token" -fi - -# validation - either realm or relevant exporter endpoint -if [[ -z "$SPLUNK_REALM" && ( "$OTEL_TRACES_EXPORTER" = *"otlp"* && -z "$OTEL_EXPORTER_OTLP_ENDPOINT" || "$OTEL_TRACES_EXPORTER" = *"jaeger"* && -z "$OTEL_EXPORTER_JAEGER_ENDPOINT" ) ]] -then - echo "[ERROR] Exporter endpoint must be set when SPLUNK_REALM is not set. To export data, either set a realm and access token or a custom exporter endpoint." -fi \ No newline at end of file