Skip to content

Commit 5201dce

Browse files
committed
Update shared.bash
1 parent cb649c9 commit 5201dce

1 file changed

Lines changed: 16 additions & 17 deletions

File tree

lib/shared.bash

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -300,37 +300,36 @@ function run_docker_compose() {
300300
export TRACEPARENT="$BUILDKITE_TRACING_TRACEPARENT"
301301
fi
302302

303-
# Set OTEL service name to match the agent's service name so docker-compose
304-
# spans appear under buildkite-agent service instead of separate "compose" service
305-
if [[ -n "${BUILDKITE_TRACING_SERVICE_NAME:-}" ]]; then
306-
export OTEL_SERVICE_NAME="${BUILDKITE_TRACING_SERVICE_NAME}"
307-
fi
308-
309303
if [[ "$disable_otel_config" == "true" ]]; then
310304
echo "~~~ :no_entry_sign: Disabling docker-compose OTEL traces"
311305

312306
# Disable OTEL for docker-compose process by unsetting all OTEL variables
313-
# We save them first so they can still be passed to containers via -e flags
314-
(/Users/user/Downloads/pipeline-1_build_1043_otel-disabled.log
315-
# Unset OTEL variables to prevent docker-compose from creating traces
307+
# Run in subshell so original environment is preserved for containers
308+
(
316309
unset TRACEPARENT
317310
unset TRACESTATE
318311
unset OTEL_EXPORTER_OTLP_ENDPOINT
319312
unset OTEL_EXPORTER_OTLP_HEADERS
320313
unset OTEL_EXPORTER_OTLP_PROTOCOL
321314
unset OTEL_SERVICE_NAME
322-
export COMPOSE_EXPERIMENTAL_OTEL=0
323315

324316
plugin_prompt_and_run "${command[@]}" "$@"
325317
)
326318
else
327-
# Let Docker Compose auto-detect OTEL configuration from environment variables
328-
# Setting OTEL_SERVICE_NAME will make compose spans appear under buildkite-agent service
329-
echo "DEBUG: Docker Compose OTEL auto-detection (not setting COMPOSE_EXPERIMENTAL_OTEL)"
330-
echo "DEBUG: TRACEPARENT=${TRACEPARENT:-NOT SET}"
331-
echo "DEBUG: OTEL_SERVICE_NAME=${OTEL_SERVICE_NAME:-NOT SET}"
332-
echo "DEBUG: OTEL_EXPORTER_OTLP_ENDPOINT=${OTEL_EXPORTER_OTLP_ENDPOINT:-NOT SET}"
333-
echo "DEBUG: OTEL_EXPORTER_OTLP_HEADERS=${OTEL_EXPORTER_OTLP_HEADERS:-NOT SET}"
319+
# Docker Compose auto-detects OTEL from environment variables
320+
# The key requirement: OTEL_EXPORTER_OTLP_ENDPOINT must be set
321+
echo "~~~ :chart_with_upwards_trend: Docker Compose OTEL tracing enabled"
322+
323+
# Verify OTEL variables are present (required for Docker Compose to create spans)
324+
if [[ -z "${OTEL_EXPORTER_OTLP_ENDPOINT:-}" ]]; then
325+
echo "⚠️ WARNING: OTEL_EXPORTER_OTLP_ENDPOINT not set - Docker Compose won't create spans"
326+
echo "⚠️ This requires Buildkite agent v3.107.2+ with propagate-agent-config-vars experiment"
327+
fi
328+
329+
echo "TRACEPARENT: ${TRACEPARENT:-NOT SET}"
330+
echo "OTEL_EXPORTER_OTLP_ENDPOINT: ${OTEL_EXPORTER_OTLP_ENDPOINT:-NOT SET}"
331+
echo "OTEL_SERVICE_NAME: ${OTEL_SERVICE_NAME:-NOT SET}"
332+
334333
plugin_prompt_and_run "${command[@]}" "$@"
335334
fi
336335
}

0 commit comments

Comments
 (0)