Skip to content

Commit bbb6aac

Browse files
committed
Suppress the OTel SDK's auto-configured exporters
With the metrics and logs SDK gems loaded, `OpenTelemetry::SDK.configure` auto-installs a metrics reader and a log processor based on the OTEL_METRICS_EXPORTER / OTEL_LOGS_EXPORTER env vars, which default to "otlp" pointed at the default OTLP endpoint. Each spawns a background thread. Collector mode replaces both providers with its own right after, orphaning those threads where no shutdown can reach them. Default the env vars to "none" so the SDK skips the auto-setup; the exporters collector mode builds explicitly are the only ones that should run. User-set values still win. [skip changeset]
1 parent 0877919 commit bbb6aac

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

lib/appsignal/opentelemetry.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ def configure(config)
2424
# this preference, per the OTel spec.)
2525
ENV["OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE"] ||= "delta"
2626

27+
# With the metrics and logs SDK gems loaded, `SDK.configure` below
28+
# auto-installs a metrics reader and a log processor from these env
29+
# vars (both default to "otlp", pointed at the default OTLP
30+
# endpoint), each with its own background thread. We replace both
31+
# providers with our own right after, which would orphan those
32+
# threads -- unreachable by any shutdown. Suppress the auto-setup;
33+
# the exporters we build below are the only ones that should run.
34+
ENV["OTEL_METRICS_EXPORTER"] ||= "none"
35+
ENV["OTEL_LOGS_EXPORTER"] ||= "none"
36+
2737
require "opentelemetry/sdk"
2838
require "opentelemetry/exporter/otlp"
2939
require "opentelemetry-metrics-sdk"

0 commit comments

Comments
 (0)