Skip to content

Commit a670c0b

Browse files
committed
Linking traceparent from buildkite service (notifications OTLP_
1 parent eeaebfe commit a670c0b

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

lib/shared.bash

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,17 +294,31 @@ function run_docker_compose() {
294294

295295
local disable_otel_config="$(plugin_read_config DISABLE_HOST_OTEL_TRACING "false")"
296296

297+
# If we have BUILDKITE_TRACING_TRACEPARENT but not TRACEPARENT, set it
298+
# This allows containers to link their spans to the Buildkite trace
299+
if [[ -n "${BUILDKITE_TRACING_TRACEPARENT:-}" ]] && [[ -z "${TRACEPARENT:-}" ]]; then
300+
export TRACEPARENT="$BUILDKITE_TRACING_TRACEPARENT"
301+
fi
302+
297303
if [[ "$disable_otel_config" == "true" ]]; then
298304
echo "~~~ :no_entry_sign: Disabling docker-compose OTEL traces"
299305
echo "DEBUG: TRACEPARENT: ${TRACEPARENT:-NOT SET}"
300306

301307
(
308+
# Preserve TRACEPARENT for containers but disable for docker-compose
309+
local SAVED_TRACEPARENT="${TRACEPARENT:-}"
302310
unset TRACEPARENT
303311
unset TRACESTATE
304312
unset OTEL_EXPORTER_OTLP_ENDPOINT
305313
unset OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
306314
export OTEL_SDK_DISABLED=true
307315
export OTEL_TRACES_EXPORTER=none
316+
317+
# Restore TRACEPARENT so it can be passed to containers via -e TRACEPARENT
318+
if [[ -n "$SAVED_TRACEPARENT" ]]; then
319+
export TRACEPARENT="$SAVED_TRACEPARENT"
320+
fi
321+
308322
plugin_prompt_and_run "${command[@]}" "$@"
309323
)
310324
else

0 commit comments

Comments
 (0)