dd-trace-go
dd-trace-go copied to clipboard
ddtrace/tracer: do not connect to trace-agent if tracing is disabled
Version of dd-trace-go v1.52.0
Describe what happened:
I'm setting the DD_TRACE_ENABLED
environment variable to false
to deactivate any tracing behaviour for an environment where the Datadog agent is not available. However during the call of tracer.Start()
a new config will be created which as part of it will query the /info
endpoint to query the trace agents capabilities (https://github.com/DataDog/dd-trace-go/blob/main/ddtrace/tracer/option.go#L331). This will end-up in an error as the function does not have a check if tracing is enabled or not:
Datadog Tracer v1.52.0 ERROR: Loading features: Get "http://localhost:8126/info": dial tcp [::1]:8126: connect: connection refused
Describe what you expected:
The endpoint should not be queried if DD_TRACE_ENABLED
is set to false
.
Steps to reproduce the issue:
- Set
DD_TRACE_ENABLED
environment variable tofalse
- Start a minimal app
func main() { tracer.Start() defer tracer.Stop() }
- Wait for the error to be raised
I have confirmed this is a bug. To be clear, this should not negatively affect your application after startup, but it is indeed a bug.