apm-agent-go
apm-agent-go copied to clipboard
`apm.DefaultTracer` misbehaves when transport configuration is invalid
The documentation for apm.DefaultTracer says:
// The default tracer is configured via environment variables, and will always // be non-nil. If any of the environment variables are invalid, the // corresponding errors will be logged to stderr and the default values will be // used instead.
However, at the moment, if creating the transport fails (e.g. beause the URL is invalid) the default URL (http://localhost:8200
) is not used -- instead, we use a transport that discards all data:
https://github.com/elastic/apm-agent-go/blob/2e6d3cf4bd88961fbb47f72451e18e45922a81c9/tracer.go#L315-L317
Another problem is that the agent will be "active", meaning that it will create transactions and spans and inject their trace context into headers, but the events will be discarded - so distributed traces will always be broken.
If we were to change the code to match the comment, distributed traces would still be broken unless the expected URL happened to be http://localhost:8200
, which seems unlikely. I think instead we should:
- set the tracer to be inactive rather than just using a discard transport
- update the DefaultTracer comment to mention that if the transport-specific config vars are invalid, then we'll deactivate the tracer
Hi @axw, I hope this message finds you well. I'm reaching out to express my interest in contributing to the resolution of this bug. I noticed this particular issue and wanted to inquire if anyone is currently working on it. If not, I would like to take it up!
Nobody is working on this yet. We do welcome PRs though.
@dmathieu Sure! Thanks for confirming.
Hi @dmathieu created a PR for this bug fix https://github.com/elastic/apm-agent-go/pull/1618