feat(trace sampler): implement error tracking standalone mode#1313
Closed
thieman wants to merge 1 commit intothieman/rare-samplerfrom
Closed
feat(trace sampler): implement error tracking standalone mode#1313thieman wants to merge 1 commit intothieman/rare-samplerfrom
thieman wants to merge 1 commit intothieman/rare-samplerfrom
Conversation
Implements the ETS sampling path from datadog-agent/pkg/trace/agent/agent.go: - In run_samplers: ETS check runs at the very top (before rare/probabilistic). Traces with errors (including exception span events) are routed exclusively to the error sampler; traces without errors are dropped immediately. - In process_trace: dropped ETS traces suppress SSS and analytics events. - When ETS keeps a trace, sets ets_error=true on TraceSampling so the encoder emits _dd.error_tracking_standalone.error="true" as a chunk tag. - Adds ets_error field to TraceSampling and sampling_mut() accessor to Trace. - Updates the DD traces encoder to emit the ETS chunk tag when set. 6 new tests: error kept, no-error dropped, SSS suppressed, ets_error flag set, exception span events treated as errors, ETS disabled uses normal path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR implements Error Tracking Standalone (ETS) sampling mode, a feature that prioritizes sampling of traces containing errors while suppressing Single Span Sampling (SSS) and analytics events for dropped traces. When ETS is enabled, it takes precedence over all other samplers (rare, probabilistic, priority), and all non-error traces are immediately dropped without further sampling attempts.
Changes:
- Adds
ets_error: boolfield toTraceSamplingstruct to track traces sampled under ETS rules - Adds
sampling_mut()accessor method toTracefor mutable access to sampling metadata - Implements ETS early-return logic in
run_samplers()that checks for errors before other samplers - Sets
ets_error=trueon kept error traces and suppresses SSS/analytics for dropped traces - Encoder emits
_dd.error_tracking_standalone.error = "true"chunk tag for kept ETS traces
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/saluki-core/src/data_model/event/trace/mod.rs | Adds ets_error field to TraceSampling and sampling_mut() accessor method to Trace |
| lib/saluki-components/src/transforms/trace_sampler/mod.rs | Implements ETS check at top of run_samplers, sets flag on kept traces, suppresses SSS/analytics for dropped traces, and adds 6 comprehensive tests |
| lib/saluki-components/src/encoders/datadog/traces/mod.rs | Unpacks ets_error flag from sampling metadata and emits it as a chunk tag when set |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Implements Error Tracking Standalone (ETS) sampling mode, matching
datadog-agent/pkg/trace/agent/agent.gorunSamplers.Changes
mod.rs— ETS check runs at the top ofrun_samplersbefore all other samplers. Traces containing errors (including exception span events) are routed to the error sampler; non-error traces are dropped immediately. Dropped ETS traces suppress SSS and analytics events. Kept ETS traces haveets_error = trueset onTraceSampling.saluki-core/trace/mod.rs— addsets_error: booltoTraceSamplingandsampling_mut()accessor toTrace.encoders/datadog/traces/mod.rs— emits_dd.error_tracking_standalone.error = "true"as a chunk tag whenets_erroris set.Behavioral notes
span.error != 0and_dd.span_events.has_exception = "true"Test plan
ets_keeps_trace_with_error— error trace kept by error samplerets_drops_trace_without_error— non-error trace droppedets_suppresses_sss_for_dropped_trace— SSS not applied when ETS drops traceets_sets_ets_error_flag_on_kept_trace—ets_errorset on sampling metadataets_keeps_trace_with_exception_span_event— exception span events count as errorsets_disabled_uses_normal_sampling— normal probabilistic path used when ETS offStacked on #1311.
🤖 Generated with Claude Code