-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Log ancestors of current span when anomaly found (#796)
Datadog believes that a lingering unfinished celery span from a previous request might be becoming the active context for all future Django requests, causing them to become parented to it. To gather evidence, we'll need to learn not just what the trace root span is, but whether there are unexpected intermediary spans as well. There may be a great many ancestors, especially with the trace concatenation in play, so we'll walk upwards from the current span towards the root until a limit is reached. This should allow us to find if the current Django request's span has a parent, and what it is. - New setting `DATADOG_DIAGNOSTICS_LOG_SPAN_DEPTH` to control walk depth - Move anomaly logging to its own method. - Log ancestry of N proximal spans, and adjust formatting of logging to be more compact. Changes relating to testing: - Add comment on how to do manual testing -- calling finish() on the root span lets us fake an anomaly. - Lift `current_span` to early in `log_diagnostics`. This is helpful during manual testing when `DD_DJANGO_INSTRUMENT_MIDDLEWARE=false`, because in that case, the current span *is* the root span. But finishing that span means we can no longer call current_root_span to retrieve it! Retrieving it before that point allows this trick to still work with our code. - Need to move middleware setup out of `setUp` method because we need to be able to adjust Django settings before the middleware is constructed. `run_middleware` now takes an optional `middleware` param. - Add intermediary span in unit tests so that truncation can be more clearly observed, and to help demonstrate that walk and print order is as expected. - Rename test local-root span to be in line with other naming. Don't need the "test_" prefix.
- Loading branch information
Showing
4 changed files
with
101 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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