ddtrace/tracer: add abandoned spans debugger#2188
Conversation
BenchmarksBenchmark execution time: 2023-08-31 11:14:54 Comparing candidate commit 74c22fd in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 40 metrics, 1 unstable metrics. |
c9de9c8 to
f535f24
Compare
8d9bac9 to
7802c36
Compare
ahmed-mez
left a comment
There was a problem hiding this comment.
Looks great! Let's just make sure we agree on introducing generics with the team before merging it.
Co-authored-by: Ahmed Mezghani <[email protected]>
…ic implementation" This reverts commit 21ba29c.
ae4ffdd to
cd4c5f0
Compare
|
/merge |
|
🚂 MergeQueue Pull request added to the queue. This build is going to start soon! (estimated merge in less than 0s) you can cancel this operation by commenting your pull request with |
|
🚨 MergeQueue Gitlab CI pipeline didn't start for this change If you need support, contact us on slack #ci-interfaces with those details! |
|
The MergeQueue failed due to some mismatch between Github and Gitlab repositories. CI is working on it. |
# Motivation This feature is inspired from the go tracer DataDog/dd-trace-go#2188 It's hard to understand and locate spans that are never finished. This PR adds a debug mode to the tracer that will track the age and root span name of traces, and * log warnings from time to time if the traces are older than some amount of time. * log warning if some traces are still open during tracer shutdown # Implementation This feature should not add any cost to the tracer if it is not enabled, but requires storing some extra data associated with each trace. In order to not use any extra memory if the feature is not enabled, I track it in an additional registry which is only used in debug mode. This registry tracks the root span name, and the age of the trace. The debug mode is controlled by 2 new configurations: * DD_TRACE_DEBUG_OPEN_SPANS * DD_TRACE_OPEN_SPAN_TIMEOUT In order to test this feature correctly, I added extra code to intercept and store logs during integration tests. This is done through a thread local Logger, which is overridden and propagated locally during tests. Everything is hidden behind the test-utils feature and should thus be zero cost
What does this PR do?
Refactors and fixes concurrency issues in #2149.
For context, the original PR described the feature as "a debugging mode that the user can configure for finding and logging old, unfinished spans".
The issues fixed are:
-countbecause oflogSizeglobal variable, as it was modified in the last subtest and never reverted to its original value.The refactoring was mainly done in the data structures holding the spans, creating an evolution of the original ones that now avoid iterating over lists, and has reduced complexity.
Reviewer's Checklist
For Datadog employees:
@DataDog/security-design-and-guidance.Unsure? Have a question? Request a review!