Skip to content

Commit a326e82

Browse files
committed
Update shared.bash
1 parent a670c0b commit a326e82

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

lib/shared.bash

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,19 +305,39 @@ function run_docker_compose() {
305305
echo "DEBUG: TRACEPARENT: ${TRACEPARENT:-NOT SET}"
306306

307307
(
308-
# Preserve TRACEPARENT for containers but disable for docker-compose
308+
# Save variables that need to be passed to containers
309309
local SAVED_TRACEPARENT="${TRACEPARENT:-}"
310+
local SAVED_TRACESTATE="${TRACESTATE:-}"
311+
local SAVED_OTEL_ENDPOINT="${OTEL_EXPORTER_OTLP_ENDPOINT:-}"
312+
local SAVED_OTEL_HEADERS="${OTEL_EXPORTER_OTLP_HEADERS:-}"
313+
local SAVED_OTEL_PROTOCOL="${OTEL_EXPORTER_OTLP_PROTOCOL:-}"
314+
315+
# Unset everything to disable docker-compose tracing
310316
unset TRACEPARENT
311317
unset TRACESTATE
312318
unset OTEL_EXPORTER_OTLP_ENDPOINT
319+
unset OTEL_EXPORTER_OTLP_HEADERS
320+
unset OTEL_EXPORTER_OTLP_PROTOCOL
313321
unset OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
314322
export OTEL_SDK_DISABLED=true
315323
export OTEL_TRACES_EXPORTER=none
316324

317-
# Restore TRACEPARENT so it can be passed to containers via -e TRACEPARENT
325+
# Restore all variables so they can be passed to containers via -e flags
318326
if [[ -n "$SAVED_TRACEPARENT" ]]; then
319327
export TRACEPARENT="$SAVED_TRACEPARENT"
320328
fi
329+
if [[ -n "$SAVED_TRACESTATE" ]]; then
330+
export TRACESTATE="$SAVED_TRACESTATE"
331+
fi
332+
if [[ -n "$SAVED_OTEL_ENDPOINT" ]]; then
333+
export OTEL_EXPORTER_OTLP_ENDPOINT="$SAVED_OTEL_ENDPOINT"
334+
fi
335+
if [[ -n "$SAVED_OTEL_HEADERS" ]]; then
336+
export OTEL_EXPORTER_OTLP_HEADERS="$SAVED_OTEL_HEADERS"
337+
fi
338+
if [[ -n "$SAVED_OTEL_PROTOCOL" ]]; then
339+
export OTEL_EXPORTER_OTLP_PROTOCOL="$SAVED_OTEL_PROTOCOL"
340+
fi
321341

322342
plugin_prompt_and_run "${command[@]}" "$@"
323343
)

0 commit comments

Comments
 (0)