-
Notifications
You must be signed in to change notification settings - Fork 436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: tracer: Warn when developer code does not close all spans #2064
Comments
This seems like a good idea and would serve well as a debugging tool for when people run into this issue. A few implementation ideas from our proposal review meeting:
|
The second option sounds sufficient assuming the developer has turned on trace debug logging as the start/finish of spans will be logged, but agreed that it is not as user-friendly as seeing the names of the spans that it is waiting on - especially if that could be a warning without trace debugging on. Is there unacceptable overhead in storing which spans have been started from that trace? Perhaps if the tracer kept a slice of started spans rather than traces it would be able to look it up dynamically when the situation occurs? For context, these are the modifications to logging I made temporarily to diagnose the issue on our end - seeing that finished and started counts mismatched |
I think we can do the second option, and if we find a trace that's older than X time, we can iterate its spans (it keeps a list of them) and print out the ones that are not closed. Would that solution work for you? The implementation details might change (keep a big slice vs some more performant concurrency-safe data structure) but I think the concept is actionable. |
I'm going to mark this as accepted. We plan on doing this in the near future (next few weeks). We will follow up with details. |
@adammw We implemented the proposed feature. It'll be available in the upcoming v1.55.0 release. Docs will be updated here at the release. Anyway, I paste here the relevant info so you can read it beforehand: Abandoned span logsThe Datadog Go Tracer also supports logging for potentially abandoned spans. To enable this debug mode in Go, set the environment variable You can also enable debugging abandoned spans during the package main
import (
"time"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
)
func main() {
tracer.Start(tracer.WithDebugSpansMode(10 * time.Minute))
defer tracer.Stop()
} |
We recently spent a lot of developer and support time investigating why certain traces weren't being sent to APM only to find that the tracing library was still waiting for the full trace to complete as there were spans created that were never finished.
It would be a helpful feature if the library could enact some sort of configurable timeout that if a trace is not finished in a certain amount of time, to log that a misconfiguration is possible and which spans the library is waiting on to finish to finalise the trace.
The feature as suggested in #1428 may also have helped mask the issue so we could still continue to get usable data in spite of the unfinished spans.
The text was updated successfully, but these errors were encountered: