Feature request: programmatic tracer option to disable Instrumentation Telemetry (DD_INSTRUMENTATION_TELEMETRY_ENABLED)
#4921
skarthikeyan-oss
started this conversation in
Feature Request
Replies: 1 comment
|
Hi Team, Can I have an update please? |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Package Name
github.com/DataDog/dd-trace-go/v2/ddtrace/tracer
Package Version(s)
v2.7.2
Describe the feature you'd like
Instrumentation Telemetry can currently only be disabled via the environment variable
DD_INSTRUMENTATION_TELEMETRY_ENABLED=false. There is no programmatic way to disable it fromcode (e.g. a
tracer.StartOption).We maintain an internal wrapper library that initializes the tracer for our services and want it
to disable telemetry by default, without requiring every service owner to remember to export
an env var. We tried setting the env var from our wrapper's
init()before starting the tracer,but it does not work — the telemetry "enabled" decision is latched during package
initialization, before any of our code runs.
Please add a tracer start option to control instrumentation telemetry, e.g.:
Why the env var can't be set from code
internal/telemetry.Disabled()reads the env var exactly once, guarded by async.Once:The
sync.Onceis first triggered during package-variable initialization ofinternal/llmobs, which constructs telemetry metric handles at package scope:Because Go initializes imported packages (and their package-level vars) before a dependent
package's
init()body runs, thisDisabled()/sync.Oncefires before any consumerinit()can call
os.Setenv(...). By the time the env var is set, the value has already been latched tothe default (
enabled).Reproduction / proof
Tiny debug program; two breakpoints under Delve.
bp2is thesync.Oncebody inDisabled();atmainis the first line ofmain().Observed order during process startup:
internal/llmobspackage init constructs telemetry handles → triggerstelemetry.Disabled()'ssync.Once. Env var is empty → defaults to enabled.init()runs and callsos.Setenv("DD_INSTRUMENTATION_TELEMETRY_ENABLED", "false").Too late — the once already ran.
main()starts. Env var reads"false", but telemetry is already enabled and is emitted.Exporting
DD_INSTRUMENTATION_TELEMETRY_ENABLED=falsein the process environment before launchworks correctly (the once reads
"false"), which confirms the issue is purely theinit-time read ordering, not the value itself.
Proposed solution
Add a public
tracer.StartOption(and/or a field on the tracer config) so telemetry can bedisabled programmatically at tracer initialization, independent of process env:
Is your feature request related to a problem?
No response
Describe alternatives you've considered
No response
Additional context
No response
All reactions