Skip to content

feat(trace sampler): implement error tracking standalone mode#1313

Closed
thieman wants to merge 1 commit intothieman/rare-samplerfrom
thieman/error-tracking-standalone
Closed

feat(trace sampler): implement error tracking standalone mode#1313
thieman wants to merge 1 commit intothieman/rare-samplerfrom
thieman/error-tracking-standalone

Conversation

@thieman
Copy link
Copy Markdown
Contributor

@thieman thieman commented Apr 6, 2026

Summary

Implements Error Tracking Standalone (ETS) sampling mode, matching datadog-agent/pkg/trace/agent/agent.go runSamplers.

Changes

  • mod.rs — ETS check runs at the top of run_samplers before 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 have ets_error = true set on TraceSampling.
  • saluki-core/trace/mod.rs — adds ets_error: bool to TraceSampling and sampling_mut() accessor to Trace.
  • encoders/datadog/traces/mod.rs — emits _dd.error_tracking_standalone.error = "true" as a chunk tag when ets_error is set.

Behavioral notes

  • ETS takes priority over all other samplers (rare, probabilistic, priority)
  • Error detection includes both span.error != 0 and _dd.span_events.has_exception = "true"
  • Non-error traces: dropped with no SSS or analytics event fallback
  • Error traces: routed through error sampler (TPS-limited); if kept, tagged with ETS chunk tag

Test plan

  • ets_keeps_trace_with_error — error trace kept by error sampler
  • ets_drops_trace_without_error — non-error trace dropped
  • ets_suppresses_sss_for_dropped_trace — SSS not applied when ETS drops trace
  • ets_sets_ets_error_flag_on_kept_traceets_error set on sampling metadata
  • ets_keeps_trace_with_exception_span_event — exception span events count as errors
  • ets_disabled_uses_normal_sampling — normal probabilistic path used when ETS off

Stacked on #1311.

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings April 6, 2026 17:11
@thieman thieman requested a review from a team as a code owner April 6, 2026 17:11
@dd-octo-sts dd-octo-sts bot added area/core Core functionality, event model, etc. area/components Sources, transforms, and destinations. encoder/datadog-traces Datadog Traces encoder. transform/trace-sampler Trace Sampler synchronous transform. labels Apr 6, 2026
@thieman thieman marked this pull request as draft April 6, 2026 17:11
@thieman thieman closed this Apr 6, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: bool field to TraceSampling struct to track traces sampled under ETS rules
  • Adds sampling_mut() accessor method to Trace for mutable access to sampling metadata
  • Implements ETS early-return logic in run_samplers() that checks for errors before other samplers
  • Sets ets_error=true on 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/components Sources, transforms, and destinations. area/core Core functionality, event model, etc. encoder/datadog-traces Datadog Traces encoder. transform/trace-sampler Trace Sampler synchronous transform.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants