liveBook · Manning

Head-based sampling

As explained in Cloud Observability in Action

Head-based sampling is a tracing sampling strategy that makes a capture decision before a trace is complete.

Head-based sampling, also called up-front sampling, decides whether to emit a trace at the beginning of a request, typically at its root span. The decision is simple and must be propagated globally across the request. section 2.5.3 section 8.3.1

Use it when a straightforward sampling policy and controlled network cost matter:

  • An agent can discard a fixed number of traces before downstream services emit their spans. section 2.5.3
  • The trade-off is visibility: because downstream errors and anomalies are not yet known, valuable traces may be discarded. section 8.3.1
  • Compared with tail-based sampling, the approach uses less state and usually reduces setup and resource complexity. section 2.5.3

A distributed request

A root span makes the capture decision before a request reaches several downstream services. If a later service fails, the trace is unavailable when the initial decision discarded it; if retained, its spans can be collected across the request path. 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 compare agent sampling overhead with instrumentation and destination costs. section 2.5.3

How Cloud Observability in Action covers it

How deep it goes
Explains root-span decisions, global propagation, and trade-offs, but defers detailed implementation.
Examples
Uses fixed trace discards and downstream failures to illustrate cost control and missed evidence.
What it assumes
Assumes basic distributed tracing concepts such as requests, spans, agents, and downstream services.
What you can do after
Evaluate whether simple up-front capture control outweighs the risk of missing downstream problems.
How it connects
Connects distributed tracing with spans, root spans, context propagation, and tail-based 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.