feat(span_processor): add debug mode for abandoned spans#107
Open
paullegranddc wants to merge 6 commits intomainfrom
Open
feat(span_processor): add debug mode for abandoned spans#107paullegranddc wants to merge 6 commits intomainfrom
paullegranddc wants to merge 6 commits intomainfrom
Conversation
# 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
bantonsson
reviewed
Nov 7, 2025
supported-configurations.json
Outdated
| "propertyKeys": ["trace_debug_open_spans"] | ||
| } | ||
| ], | ||
| "DD_TRACE_OPEN_SPAN_TIMEOUT": [ |
Collaborator
There was a problem hiding this comment.
This one is in the wrong alphabetical order. I also think it's weird that it's not named in the same way as DD_TRACE_DEBUG_OPEN_SPANS, since it's related. Naming it DD_TRACE_DEBUG_OPEN_SPANS_TIMEOUT would make more sense.
Collaborator
Author
There was a problem hiding this comment.
I agree, I picked these names because they were the ones used by the go tracer for it's debug mode
I'll probably change the timeout one to DD_TRACE_DEBUG_OPEN_SPANS_TIMEOUT, as I don't think it's that bad to have different configs between languages in this specific case
bantonsson
approved these changes
Nov 10, 2025
iunanua
reviewed
Nov 10, 2025
Comment on lines
+1047
to
+1049
| #[cfg(feature = "test-utils")] | ||
| wait_agent_info_ready: default.wait_agent_info_ready, | ||
| span_metrics_interval: default.span_metrics_interval, |
Collaborator
There was a problem hiding this comment.
is missing here a #[cfg(feature = "test-utils")]?
Suggested change
| #[cfg(feature = "test-utils")] | |
| wait_agent_info_ready: default.wait_agent_info_ready, | |
| span_metrics_interval: default.span_metrics_interval, | |
| #[cfg(feature = "test-utils")] | |
| wait_agent_info_ready: default.wait_agent_info_ready, | |
| #[cfg(feature = "test-utils")] | |
| span_metrics_interval: default.span_metrics_interval, |
iunanua
reviewed
Nov 10, 2025
Comment on lines
+1510
to
+1512
| #[cfg(feature = "test-utils")] | ||
| wait_agent_info_ready: false, | ||
| span_metrics_interval: Duration::from_secs(10), |
Collaborator
There was a problem hiding this comment.
and here?
Suggested change
| #[cfg(feature = "test-utils")] | |
| wait_agent_info_ready: false, | |
| span_metrics_interval: Duration::from_secs(10), | |
| #[cfg(feature = "test-utils")] | |
| wait_agent_info_ready: false, | |
| #[cfg(feature = "test-utils")] | |
| span_metrics_interval: Duration::from_secs(10), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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:
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