Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use otel collector #114

Merged
merged 9 commits into from
Feb 7, 2023
12 changes: 9 additions & 3 deletions java/build-layer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 0 additions & 13 deletions java/scripts/otel-handler

This file was deleted.

13 changes: 0 additions & 13 deletions java/scripts/otel-proxy-handler

This file was deleted.

13 changes: 0 additions & 13 deletions java/scripts/otel-stream-handler

This file was deleted.

3 changes: 0 additions & 3 deletions nodejs/nodejs-otel-handler
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
40 changes: 3 additions & 37 deletions scripts/splunk-default-config
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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