liveBook · Manning

Sampling

As explained in Cloud Observability in Action

Sampling is the technique of selectively capturing or discarding telemetry records according to a decision policy.

Sampling selectively captures or discards telemetry records according to a decision policy. In distributed tracing, it reduces the volume of traces and spans sent for collection, ingestion, and storage. section 8.1.2 section 8.3.1

Common strategies differ in when they decide and what they can know:

  • No sampling ingests every span, which can suit development, testing, tool evaluation, or volume-neutral pricing. section 8.3.1
  • Head-based sampling decides at the request’s beginning, making implementation simpler and reducing network costs, but potentially missing downstream errors or anomalies. section 2.5.3 section 8.3.1
  • Tail-based sampling waits until the request completes, improving selection of relevant traces but requiring more state, resource usage, and a completion decision around timeouts or stragglers. section 2.5.3 section 8.3.1
  • Policies can use fixed percentages or trace characteristics such as errors, while log sampling can drop a heuristic percentage of events. section 8.1.2 section 2.3.3

A microservice request with an error

A request moves across several microservices. Head-based sampling decides at the root before downstream behavior is known and may discard the request; tail-based sampling can retain it after an error appears in a downstream span, provided the collector waits long enough to determine completion. section 8.1.2 section 8.3.1

Table 2.3 Overview of the costs of traces (view table figure)

 

Overhead

Considerations

Instrumentation

Some effort and auto-instrumentation

OpenTelemetry uptake and legacy

Agent

Sampling strategy and latency overhead

Use OpenTelemetry collector

Destination

Dedicated storage layer and query and analytics

Lots of commercial offerings and some OSS (e.g., Tempo and Jaeger)

Use the trace-cost overview to place sampling among instrumentation, agent, storage, indexing, and query costs. section 2.5.3

How Cloud Observability in Action covers it

How deep it goes
Compares no, head-based, and tail-based strategies, including decision timing, error coverage, state, latency, and timeout limitations.
Examples
Uses fixed percentages, error-bearing traces, downstream timeouts, production span volumes, and heuristic log-event pruning.
What it assumes
Assumes distributed-tracing terms such as traces, spans, requests, and context propagation, while defining sampling from its basic purpose.
What you can do after
Evaluate sampling strategies against trace relevance, network and storage cost, implementation complexity, and incomplete-request behavior.
How it connects
Connects distributed tracing with context propagation, microservices, OpenTelemetry collectors, trace storage, and log pruning.

Also explained in

Compare how 23 books explain sampling →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Cloud Observability in Action. The section links point to the parts of the book it draws on.