Papers
Topics
Authors
Recent
Assistant
AI Research Assistant
Well-researched responses based on relevant abstracts and paper content.
Custom Instructions Pro
Preferences or requirements that you'd like Emergent Mind to consider when generating responses.
Gemini 2.5 Flash
Gemini 2.5 Flash 70 tok/s
Gemini 2.5 Pro 55 tok/s Pro
GPT-5 Medium 14 tok/s Pro
GPT-5 High 14 tok/s Pro
GPT-4o 72 tok/s Pro
Kimi K2 191 tok/s Pro
GPT OSS 120B 449 tok/s Pro
Claude Sonnet 4 37 tok/s Pro
2000 character limit reached

Trace Sampling 2.0: Fine-Grained Distributed Tracing

Updated 20 September 2025
  • Trace Sampling 2.0 is a modern tracing approach that selectively retains key diagnostic spans, enabling detailed analysis while reducing storage overhead.
  • It employs static analysis with CSCFG and anomaly ranking via revised Z-scores to partition traces into Dominant Span Sets for precision sampling.
  • Empirical results, such as 81.2% reduction in trace size and 98.1% faulty span coverage, confirm its efficiency and enhanced root cause analysis capabilities.

Trace Sampling 2.0 is a modern paradigm for distributed tracing and data-driven machine learning workflows that prioritizes the retention, selection, and compression of application traces under stringent storage, efficiency, and diagnostic requirements. Unlike early approaches that made coarse, binary decisions at the whole-trace level, Trace Sampling 2.0 introduces fine-grained, structure-aware techniques—often leveraging static code analysis, feature clustering, and flexible aggregation strategies—to maximize observability and analytical value while maintaining tractability at scale.

1. Paradigm Shift: From Trace-level to Span-level Sampling

Traditional distributed tracing frameworks apply a “1 or 0” strategy, in which each trace is either fully retained or entirely discarded based on simple criteria (such as latency or anomalous events). Trace Sampling 2.0 fundamentally alters this practice by enabling span-level sampling, allowing for selective retention of the most diagnostically useful components—spans—within each trace.

This method is exemplified by Autoscope, which introduces Dominant Span Set (DSS) partitioning. Here, the trace is algorithmically decomposed according to execution dependencies inferred from code structure, where only critical spans within each DSS are preserved. This fine-grained control addresses the limitations of discarding normal traces and ensures the retention of structural integrity and comparative debugging information.

2. Code Knowledge Enhanced Sampling Methodology

A core innovation in Trace Sampling 2.0 is the use of static analysis to extract application execution logic. Autoscope, as a representative system, constructs a Call-Site Control Flow Graph (CSCFG) that focuses on function call blocks within the application. Each span in the distributed trace is mapped to its invocation site, allowing the sampling algorithm to divide the trace into branch-dependent segments (DSS).

Sampling decisions are thus informed not only by runtime metrics but by structural code knowledge. For each DSS (representing, for example, alternate execution branches like seat selection in ticketing microservices), spans are ranked based on anomalous behavior (quantified by a revised Z-score), and only those indicative of branch or performance deviations are retained. This structural awareness is critical for ensuring that trace reconstruction and downstream analytics remain valid and comprehensive.

3. Span Selection, Anomaly Ranking, and Compression

Trace Sampling 2.0 employs rigorous statistical tools for span selection within each DSS. Anomaly ranking utilizes a revised Z-score formula:

Zi=ximedian(X)MADZ_i = \frac{x_i - \operatorname{median}(X)}{\mathrm{MAD}}

where xix_i denotes the selected span’s duration (excluding child spans), and

MAD=median(ximedian(X))\mathrm{MAD} = \operatorname{median}(|x_i - \operatorname{median}(X)|)

over a sliding window of instances of the same span type.

The method maintains a user-defined sampling quota per DSS, enforcing minimum coverage for each code branch regardless of overall sampling rate. This approach yields a compressed trace representation, typically recording a single representative span per DSS, resulting in significant reductions in trace size—Autoscope’s evaluation reports an 81.2% decrease—while retaining nearly all faulty spans (98.1% coverage).

4. Structural Consistency and Trace Reassembly

By retaining the mapping from spans to code branches, Trace Sampling 2.0 maintains the structural integrity of traces, allowing complete logical path reconstruction. Even when only a subset of spans is stored, the underlying execution sequence and branch decisions are preserved, supporting downstream operations such as root cause analysis (RCA) and comparative investigations.

The partitioning algorithm, guided by mutual dominance relations between spans, ensures that all execution branches are represented, avoiding the loss of context that plagues earlier trace-level approaches.

5. Empirical Evaluation, Performance, and Impact

Autoscope was evaluated on microservice benchmarks including Train Ticket and Social Network applications using end-to-end traces from OpenTelemetry and Grafana Tempo. Experimental design incorporated fault injection to rigorously assess coverage and diagnostic utility.

Key metrics include:

  • Sampling Ratio: Fraction of retained spans versus total spans (lower is better).
  • Faulty Span Coverage: Fraction of faulty spans observed despite compression (98.1% with Autoscope).
  • Root Cause Analysis Utility: Downstream improvements (8.3% average gain in MRR) in fault localization tasks.

Compared with state-of-the-art methods like Perch, Sifter, and TraceMesh, as well as span-only latency deviation techniques (e.g., Log²), Autoscope demonstrated superior trace compression and fault span retention.

6. Broader Implications and Future Directions

Trace Sampling 2.0 marks a substantive evolution in distributed systems observability and storage management:

  • It enables all traces to be represented, supporting robust RCA and comparative studies between normal and faulty executions.
  • Backend storage and network overhead are significantly reduced, with negligible impact on RCA efficacy or system monitoring capabilities.

Potential future enhancements include adaptive CSCFG construction to accommodate evolving application logic, integration of advanced ML-based anomaly detection, dynamic quota allocation for DSS, and hybridization with traditional trace-level filters.

7. Technical Summary and Formulas

Conceptual advances in Trace Sampling 2.0 are underpinned by:

  • Code-guided DSS partitioning for span-level selection.
  • Median–MAD–based anomaly scoring for robust outlier detection.
  • Minimal coverage quotas to avoid missing critical faults.
  • Structural mapping via CSCFG and static/dynamic analysis.

Representative formulas:

  • Revised Z-score for span anomaly ranking:

Zi=ximedian(X)MADZ_i = \frac{x_i - \operatorname{median}(X)}{\mathrm{MAD}}

  • Median Absolute Deviation:

MAD=median(ximedian(X))\mathrm{MAD} = \operatorname{median}(|x_i - \operatorname{median}(X)|)

These methodological and technical contributions position Trace Sampling 2.0 as an advanced approach for efficient, comprehensive, and structure-preserving distributed tracing, enabling scalable observability and effective system diagnosis in modern microservice environments (Wu et al., 17 Sep 2025).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)
Forward Email Streamline Icon: https://streamlinehq.com

Follow Topic

Get notified by email when new papers are published related to Trace Sampling 2.0.

Don't miss out on important new AI/ML research

See which papers are being discussed right now on X, Reddit, and more:

“Emergent Mind helps me see which AI papers have caught fire online.”

Philip

Philip

Creator, AI Explained on YouTube