Skip to content

Commit ad9429e

Browse files
authored
Merge pull request #511 from buildkite-plugins/SUP-5138/Disable-host-otel-tracing
Remove all OTEL env vars when `disable-host-otel-tracing` is set to true
2 parents 0fab001 + 8f6c198 commit ad9429e

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

lib/shared.bash

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ function plugin_prompt_and_run() {
2020
local exit_code
2121

2222
plugin_prompt "$@"
23+
2324
"$@"
2425
exit_code=$?
2526

@@ -41,11 +42,6 @@ function plugin_read_config() {
4142
echo "${!var:-$default}"
4243
}
4344

44-
# Disable OTEL tracing for host-side commands
45-
if [[ "$(plugin_read_config DISABLE_HOST_OTEL_TRACING "false")" == "true" ]] ; then
46-
export OTEL_SDK_DISABLED=true
47-
fi
48-
4945
# Reads either a value or a list from plugin config
5046
function plugin_read_list() {
5147
prefix_read_list "BUILDKITE_PLUGIN_DOCKER_COMPOSE_$1"
@@ -296,7 +292,25 @@ function run_docker_compose() {
296292

297293
command+=(-p "$(docker_compose_project_name)")
298294

299-
plugin_prompt_and_run "${command[@]}" "$@"
295+
local disable_otel_config
296+
disable_otel_config="$(plugin_read_config DISABLE_HOST_OTEL_TRACING "false")"
297+
298+
if [[ "$disable_otel_config" == "true" ]]; then
299+
# Disable docker-compose OTEL tracing by clearing environment variables
300+
# builkite-agent spans will still be created, but this will elminate docker-compose cli/run etc spans
301+
(
302+
unset TRACEPARENT
303+
unset TRACESTATE
304+
unset OTEL_EXPORTER_OTLP_ENDPOINT
305+
unset OTEL_EXPORTER_OTLP_HEADERS
306+
unset OTEL_EXPORTER_OTLP_PROTOCOL
307+
unset OTEL_SERVICE_NAME
308+
309+
plugin_prompt_and_run "${command[@]}" "$@"
310+
)
311+
else
312+
plugin_prompt_and_run "${command[@]}" "$@"
313+
fi
300314
}
301315

302316
function in_array() {

0 commit comments

Comments
 (0)