You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore(tracing): simplify trace sampling and span aggregation (#12749)
## Motivation
This PR improves the isolation of tracing components by removing direct
references from the Tracer to several components, including
DatadogSampler, TraceSamplingProcessor, TraceTagsProcessor, TraceWriter
as well as partial flushing, trace agent and StatsD connection
configurations. Instead, these components will now be defined where they
are used. This change eliminates unnecessary attributes and ensures a
single source of truth for each component.
## Changes
- Moves the Tracer._writer to the SpanAggregator. The Tracer object no
longer directly configure the submission of spans to the agent. This
functionality is fully delegated to the SpanAggregator.
- Introduces Tracer._span_aggregator, moving SpanAggregator to its own
property for faster access to DatadogSampler and AgentWriter.
- Removes partial flush attributes from Tracer; partial flushing is now
only defined in the SpanAggregator.
- Moves Tracer._agent_response_callback(), Tracer._use_sync_mode() and
Tracer._use_log_writer() to the SpanAggregator. The tracer no longer
directly references the agent writer.
- Removes Tracer._compute_stats property,
`ddtrace.config._compute_stats` (the global config) is now used
directly. This ensures the global tracer always uses up to date
configurations.
- Moves TraceSamplingProcessor and TraceTagsProcessor initialization to
SpanAggregator.
- Centralizes all sampling logic in the TraceSamplingProcessor. This
includes agent based, user-defined, dynamic, and single-span sampling.
- **Core Enhancement: Ensures `Tracer.sample(...)` can access the
SpanAggregator and the TraceSampling processor in constant time.**
## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))
## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
---------
Co-authored-by: Emmett Butler <[email protected]>
0 commit comments