Synthesis and Self-Test

Synthesis — How the Pieces Pay for Each Other

"no completion signal" is not a gap in the spec — it is the reason tail sampling costs gigabytes

A span is buffered in its own process until End() and only then handed to an exporter (see The Span). Nothing in the data model marks a span as last, and no process has the standing to say so — the root finishes first in wall-clock terms but its descendants keep reporting (see The Trace). So "is this trace complete?" is unanswerable by construction, and every system that needs the whole trace must substitute a timer for a signal. That single substitution is the entire cost structure of the Tail-Based Sampling part: decision_wait exists because completeness is unknowable, the buffer exists because the timer has to wait, and the buffer's size is span_rate × decision_wait × bytes_per_span because there is nothing smaller you could have kept. The collector even ships the shortcut — decision_wait_after_root_received — and defaults it to 0s, which is upstream quietly agreeing that root arrival does not mean the trace is done.

Sampling is a retention decision that the industry spent a decade misusing as a measurement decision

The two are not the same question and they have different right answers. Which stories do I keep? should be biased hard toward the rare and the broken — that is the Tail-Based Sampling part's whole argument. What is my error rate? must be computed from everything, or it is wrong by a factor you cannot recover, because the moment two services sample at different rates the weights stop composing (see Head-Based Sampling). Dapper saw this in 2010 and recorded the sampling probability alongside each trace so counts could be re-inflated; OTEP 235's ot=th: in tracestate is the same idea standardized fifteen years later, and it is still at Development status and off by default. Which is why the practical answer is not a better weighting scheme but the span_metrics connector (see What It Costs): derive rate, errors and duration from 100% of spans before the sampler, and the question stops being a trade-off. Sample what you store; never sample what you measure.

One rule, three independent enforcers, none of which will tell you that you broke it

"Span names must be low-cardinality" sounds like style advice until you notice how many unrelated subsystems are quietly load-bearing on it. Put GET /user/12345 in a span name and you (1) explode Cassandra's operation_names_v2 partition and the operation index that the Jaeger UI's dropdown reads from (see Trace Storage), (2) explode metric label cardinality in span_metrics, converting a trace-storage cost into a far more expensive time-series cost (see What It Costs), and (3) silently exceed the OTel Go Jaeger remote sampler's 256-operation cap, so adaptive sampling stops having a per-operation rate for anything (see Jaeger Architecture). Three subsystems, three different failure surfaces, zero error messages. This is the shape of almost every tracing problem: a local convenience that is fine in the process that made it and expensive in four systems downstream.

Four unrelated mechanisms that produce the identical broken picture

A trace showing A→C when you know the path is A→B→C has at least four distinct causes, and they look the same in the UI. B strips the header at a proxy (see Context Propagation). B links the OTel API without an SDK, whose no-op tracer is specified to return a non-recording span carrying the caller's SpanContext — so B is perfectly transparent and its callees attach to A's span id (see OpenTelemetry). B's BatchSpanProcessor queue overflowed at 2048 and dropped its spans without an error (see Instrumentation). Or B's spans were never sampled because the decision was made at A's root and B's exporter honoured it (see Head-Based Sampling). The data model has no way to distinguish "this hop did not happen" from "this hop was not recorded." That absence is why the Instrumentation part's coverage argument matters more than any instrumentation feature: an uninstrumented hop does not leave a labelled hole, it produces a confident, wrong graph.

Every drop in this pipeline is silent, and the defaults contradict each other

Nothing in the path from your process to your backend fails loudly. The BSP queue drops at 2048 (see Instrumentation); memory_limiter refuses data by design so the collector stays up instead of OOMing (see The Collector); the loadbalancing tier re-shards on a rolling restart and splits in-flight traces across two instances that each decide on a fragment (see The Collector, Tail-Based Sampling). The sharpest instance is a pair of shipped defaults that are mutually inconsistent: num_traces: 50000 ÷ decision_wait: 30s = 1,667 traces/s. Above that, the circular buffer evicts traces before their timer ever expires — at this guide's 10,000 req/s the buffer holds five seconds while the timer waits thirty, so roughly 83% of traces are discarded before a single policy runs. Error rates look normal. Latency looks normal. Only otelcol_processor_tail_sampling_sampling_trace_dropped_too_early knows, and nobody graphs it because the metric they were told to graph — otelcol_processor_dropped_spans — does not exist.

The index you can skip and the one you cannot

Trace storage splits cleanly along the two read shapes, and only one of them is negotiable. Get by trace ID is a point lookup that every design must serve and none can avoid — Tempo keeps bloom filters for it, and the ClickHouse exporter maintains a dedicated <table>_trace_id_ts materialized view precisely because a trace-ID lookup would otherwise scan every partition. Every index-free design eventually rebuilds a trace-ID index. What Tempo actually discarded is the search index, replacing it with parallel brute-force scans of columnar blocks — which is the right trade only because the Trace Storage part's access pattern is so lopsided that most stored traces are never read at all. And that trade is affordable only if you can find the trace ID some other way, which is why the Reading a Trace part's correlation story — trace ID on every log line, exemplars on your metrics — is not a nice-to-have but the thing that pays for the cheap storage.

Self-Test

Question 1

Define a span and a trace precisely, and say what links them. Then: your UI shows service A calling service C directly, but you know the real path is A → B → C. Give four distinct mechanisms that produce exactly this picture, and how you'd tell them apart.

Show answer

A span is one unit of work in one process: trace_id, span_id, parent_span_id, a low-cardinality name, a kind, start and end timestamps as absolute Unix nanoseconds, a status, attributes, events and links. A trace is not a stored object at all — it is what you get when a backend groups every span sharing a trace_id and reconstructs a tree by joining each span's parent_span_id to another span's span_id. The root is the span with no parent. Nobody ever builds that tree in flight; it is reassembled after the fact from independently-arriving spans (see The Span, The Trace).

The four causes of a missing middle hop: (1) a stripped header — a proxy or WAF dropped traceparent, in which case C starts a brand-new trace and you see two disconnected traces rather than a false edge (see Context Propagation). (2) B links the OTel API without an SDK — the no-op tracer is specified to return a non-recording span carrying the caller's SpanContext, so B propagates A's span id unchanged and C attaches to A. This is the one that produces a genuinely false edge in a fully "instrumented" fleet (see OpenTelemetry). (3) B's BatchSpanProcessor queue overflowed at its 2048 default and dropped spans silently under load — intermittent, load-correlated, and visible in B's own dropped-span counter (see Instrumentation). (4) B was never sampled — but note this one should be impossible if everyone honours ParentBased, so seeing it means B is running its own root sampler and ignoring the incoming flag (see Head-Based Sampling).

Telling them apart: (1) gives two traces, not one. (2) is 100% reproducible and B emits no spans ever. (3) is intermittent and correlates with B's load. (4) is 100% reproducible but B does emit spans for other traces. The deeper point is that the data model cannot distinguish "this hop did not happen" from "this hop was not recorded" — which is why an uninstrumented hop produces a confident wrong graph rather than a labelled hole (see The Trace, Instrumentation).

Question 2

Why does head-based sampling at 1% miss the traces you most want? Work the arithmetic for a bug that fires 3 times an hour. Then explain why you can't simply multiply the survivors by 100 to get your numbers back.

Show answer

The decision is made at the root span, before any downstream call has been issued — before the latency exists and before any error has occurred. The sampler therefore cannot condition on the only two properties that make a trace worth keeping, so the best it can do is a weighted coin flip on the trace_id (see Head-Based Sampling). The arithmetic: a bug firing 3×/hour, each occurrence kept independently with p=0.01, gives P(zero captured in the hour you're paged) = 0.99³ ≈ 97%. Expected wait to capture one is ~33 hours. You will be asked to explain an outage using an empty result set.

The asymmetry is the real content: normal traces are abundant and interchangeable — the 500,000th successful checkout teaches you nothing — while rare traces carry all the information. Uniform sampling spends the entire budget on the category with no information content. It is not that 1% is too low; it is that "uniform" is the wrong shape.

Why ×100 doesn't restore the numbers: it works only if you know the rate, and the rate stops being knowable the moment two services or two endpoints sample differently — the weights no longer compose, and nothing in the span tells you which weight applied. That is exactly what Dapper solved in 2010 by recording the sampling probability alongside each trace, and what OTEP 235 re-standardizes as ot=th: in tracestate — still at Development status and off by default (see Context Propagation, Head-Based Sampling). One extra trap: consistent sampling assumes trace IDs are uniformly random, and AWS X-Ray IDs are not — they are epoch-seconds plus 24 random hex — so hashing them for a sampling decision is unsound. That is precisely why Trace Context Level 2 adds a flag asserting the ID's randomness. The honest answer is that counts belong in metrics derived from 100% of spans (see What It Costs), not in sampled traces at all.

Question 3

Write out a traceparent header and name every field. Which field makes a sampling decision irreversible 22 services later? And why is if (header.length == 55) parse() a bug?

Show answer

Four hyphen-separated hex fields: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01 — version (2 hex), trace-id (32 hex / 16 bytes, must not be all zeros), parent-id (16 hex / 8 bytes), trace-flags (2 hex). The third field is officially parent-id, and the name is the mechanism: it always carries the sender's own span id, which the receiver adopts as its parent. That is the entire linking mechanism of the Trace part, in one field, on the wire (see Context Propagation).

trace-flags is the irreversible one. Bit 0 (01) is sampled. A head sampler at the root sets it once, and every downstream service running the default ParentBased sampler honours it — which is exactly what you want for consistency (per-service coin flips would give you complete traces with probability p^40) and exactly what dooms you at 1%: a decision taken before anything happened binds 22 services that later learn the request failed (see Head-Based Sampling). Note the spec calls the bit a recommendation, not a guarantee; a receiver may decide otherwise, which is what makes Q1's fourth failure mode possible.

length == 55 is a bug because 55 is a minimum, not an equality. The spec's forward-compatibility rule is that a future version may append fields, and a parser must still read the fields it knows rather than reject the header. Hard-coding equality means your service silently starts breaking traces the day anything upstream emits version 01. (Related and worth knowing: tracestate is capped at 32 list-members with a 512-character propagation floor, and baggage — a separate header and a separate concept — is bounded at 64 members / 8192 bytes and is attacker-controllable across a trust boundary.)

Question 4

How does OpenTelemetry separate instrumentation from backend, mechanically? Name the specific property that made third-party libraries willing to adopt it — and say honestly where the vendor portability stops.

Show answer

Three layers with a deliberate dependency direction. The API is what a library author codes against; the SDK is what the application owner installs and configures (samplers, processors, limits); the exporter chooses the wire format and destination. A library depends on the API only — a separately versioned, stable artifact with a long-term compatibility contract — and therefore never picks a backend for its users (see OpenTelemetry).

The load-bearing property is that the API ships a no-op implementation by default. An HTTP client or a database driver can call tracer.Start(...) unconditionally; if the application never installs an SDK it costs approximately nothing and emits nothing. Without that, adding tracing to a library would force a full runtime on every downstream application, which library authors refuse — and that is precisely what sank OpenCensus's API, which was fused to its SDK. OpenTracing had the separation but no data model and no collector, so you could swap tracers and still find one wrote http.status_code and another http.status: portability of the call site without portability of the meaning. OTel took OpenCensus's implementation, OpenTracing's separation, and added the thing neither had — versioned semantic conventions.

Where it stops: you keep your instrumentation code, semantic conventions, OTLP, and collector config. You do not keep the query language (TraceQL vs Jaeger tag search vs a vendor's own), dashboards, alert definitions, saved views, trace-to-log correlation wiring, or anything built on proprietary derived data. OTel commoditized collection and moved the lock-in up the stack to query and analysis. That is still the win that matters, because the historically expensive part was re-instrumenting — and a collector can dual-export to two backends at once, which makes a real bake-off possible for the first time.

Question 5

You enable the collector's tail_sampling processor with stock defaults at 10,000 req/s, with a policy that keeps 100% of error traces. Trace volume drops far more than expected, no error metric moves, and a week later a bad deploy detonates your bill. Explain both failures.

Show answer

Failure one — the defaults contradict each other. num_traces defaults to 50,000 and decision_wait to 30s. The processor holds a circular buffer of traces, so the two defaults are only consistent up to 50,000 ÷ 30 = 1,667 traces/s. At 10,000 req/s the buffer holds about five seconds of traffic while the timer waits thirty, so traces are evicted by the ring before their decision timer ever fires — roughly 83% of traces are discarded before a single policy is evaluated, including the error traces your policy was written to guarantee (see Tail-Based Sampling). Nothing errors: this is the buffer working as designed. The only signal is otelcol_processor_tail_sampling_sampling_trace_dropped_too_early, and the metric most runbooks tell you to watch — otelcol_processor_dropped_spans — does not exist at all; per-signal processor counters were replaced by generic incoming_items/outgoing_items, where a drop is the difference (see The Collector). Fix: raise num_traces to cover peak_traces_per_sec × decision_wait with headroom, and size the RAM for it — span_rate × decision_wait × bytes_per_span, which here is gigabytes, continuously.

Failure two — "keep 100% of errors" is an unbounded cost function evaluated exactly when the system is on fire. On a normal day errors are 0.1% of traffic and the policy is nearly free. A deploy that fails 100% of requests makes it a 100%-retention policy at 400,000 spans/s, and you ship your entire firehose to a per-GB-billed vendor during the hour you are least able to notice. The fix is a composite policy with a rate_limiting guard as a backstop, so the error policy degrades to "all the errors we can afford" instead of "all of them." Related trap worth naming: decision_cache defaults to 0, so a span arriving after its trace was decided doesn't join that decision — it opens a new 30-second buffer entry and is judged alone, as a fragment.

Question 6

Your tracing bill must come down 70% and you may not lose the ability to alert on error rate or p99. Give your ordering, and explain why "set the sample rate to 0.1%" is the wrong first move even though it would hit the number.

Show answer

The ordering follows from the fact that the bill is four different costs with four different levers (see What It Costs): SDK/agent CPU and RSS inside your processes, network egress (cross-AZ is billed both directions), backend ingest, and storage × retention. Sampling touches them differently — only head sampling stops a span being built at all, while tail sampling still transports 100% of spans to the decision point and saves only ingest and storage.

First, decouple measurement from retention. Put the span_metrics connector ahead of any sampler so rate, errors and duration histograms are derived from 100% of spans. Now alerting no longer depends on what you keep, and every subsequent cut is safe. Skipping this step is what makes every other step risky (see What It Costs). Second, drop what has no value at any sample rate — health checks, readiness probes and metrics-scrape spans are frequently a large share of volume and zero share of insight, and the filter processor removes them before egress, hitting the CPU and egress buckets that sampling never touches. Third, truncate the fat attributes — full SQL text, request bodies, stack traces on non-error spans — which cuts bytes/span across every bucket at once. Fourth, tier retention: error traces 30 days, sampled-normal 7, mapped straight onto the tail-sampling policy that produced them. Only then touch the sample rate, and make it tail-based or hybrid so the cut falls on the interchangeable traces.

Why 0.1% first is wrong: it hits the number by deleting evidence rather than waste, it makes Q2's capture probability catastrophic (a 3×/hour bug becomes a ~99.7% chance of nothing), and if any dashboard or alert is computed from trace counts rather than span-derived metrics, you have just silently changed every one of those numbers by a factor of ten. Cut waste before you cut evidence, and never let the thing you alert on depend on the thing you sample.