-
Notifications
You must be signed in to change notification settings - Fork 1
feat(span_processor): add debug mode for abandoned spans #107
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
base: main
Are you sure you want to change the base?
feat(span_processor): add debug mode for abandoned spans #107
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
supported-configurations.json
Outdated
| "propertyKeys": ["trace_debug_open_spans"] | ||
| } | ||
| ], | ||
| "DD_TRACE_OPEN_SPAN_TIMEOUT": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
| #[cfg(feature = "test-utils")] | ||
| wait_agent_info_ready: default.wait_agent_info_ready, | ||
| span_metrics_interval: default.span_metrics_interval, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is missing here a #[cfg(feature = "test-utils")]?
| #[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, |
| #[cfg(feature = "test-utils")] | ||
| wait_agent_info_ready: false, | ||
| span_metrics_interval: Duration::from_secs(10), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here?
| #[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), |
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