{"canonical_url":"https://engineer.company/glossary/telemetry-sampling/","content_markdown":"# Telemetry sampling\n\n## What it is\n\nTelemetry sampling selects a portion of a stream of observations for collection\nor retention. A busy service can produce many traces, events or log records\nwhile it works. Sampling can keep a useful portion within a manageable\nprocessing and storage budget. A sampling policy describes what can be kept,\nwhen the decision happens and which questions the retained observations can help\nanswer.\n\nWith trace sampling, a head decision happens early, often when a request begins\na trace. It can use attributes available at that time and may follow a decision\npassed from another component. A tail policy can decide later, after seeing more\nof the trace. It can keep examples based on the final outcome, latency or other\ninformation that appears during the operation. It needs time and resources to\ncollect enough spans before deciding.\n\nSampling can be random, rule-based or a combination. A broad sample can describe\ncommon work. A targeted sample can help find rare failures. The appropriate\npolicy depends on which evidence a team needs and what changes the policy makes\nto the retained population. A retained sample can describe examples more\ncompletely than it describes the true frequency of all outcomes.\n\n## Why it matters\n\nDetailed tracing requires processing, network capacity and storage. Collecting\nevery data point can compete with the service it describes. A sampling policy\ncan keep enough examples available for diagnosis and reserve capacity for work\nthat needs more attention. It gives a team a way to make those decisions as\ntraffic changes.\n\nRare failures deserve particular care. If a service keeps a very small random\nportion of traces, an error that occurs infrequently may have no retained\nexample during an incident. A tail policy can keep selected failures once their\nresult is known. This improves diagnostic evidence. It can also change the\ndistribution in storage because the policy retains more failures than ordinary\nsuccesses. Publish reliability counts using a measurement designed for that\npurpose.\n\nThink about how evidence remains useful across a system. If one service keeps\none span and another decides independently to remove the span connected to it,\nthe result can be hard to follow. Use propagation and consistent decisions where\ncomplete traces matter. Some transitions call for separate policies, such as\nwhen traffic crosses an organisational or privacy boundary. Define which\ninformation can be shared and how a receiver starts its own internal\nobservation.\n\n## What it looks like in practice\n\nImagine a trace pipeline for API requests. Use a modest baseline sample for\nordinary requests. Give a later decision process a policy to retain traces with\nan error or a performance problem the team can investigate. Inject a controlled\nerror after an upstream hop and a slow response whose final status is\nsuccessful. Check how each appears in the retained traces, including the spans\nthat were needed to explain why it happened.\n\nSet a realistic time for a trace to arrive at the decision point. A collector\nmight see a request's initial spans long before slower work finishes. A finite\ndecision buffer can protect the telemetry service. Measure late arrivals,\ndiscarded data and how long each retained trace takes to appear. If events often\nreach the collector out of order, exercise a deliberately delayed span and\ndecide which partial results can still be useful.\n\nEngineer's\n[first-party monitoring case study](/portfolio/built-first-party-error-monitoring-and-tracing/)\ndescribes OpenTelemetry traces, sanitised alerts and a heartbeat for the\nobservation pipeline itself. A sampling policy belongs inside the same operating\ndiscipline. The illustrative test checks both an application's retained details\nand what the pipeline reports when its own capacity is exhausted. A missing\ntrace needs an explanation people can observe.\n\nKeep independent aggregate measurements where the service needs an overall rate.\nFor example, counters recorded at the user-facing request boundary can describe\nthe proportion of failures. A curated set of traces can then explain particular\nfailures. Verify both using injected traffic and a known number of outcomes,\nwith the sampling policy active.\n\n## Where it goes wrong\n\nA common mistake is to treat the retained trace set as a census. If the policy\nkeeps nearly every failed request and only a small portion of successes, a graph\nbuilt from those records can overstate the overall failure rate. Document that\nbias and provide the population measurement from another signal. A sample's\nuseful size is tied to the question it answers.\n\nTail decisions can also increase the cost of a collector during an incident. If\nmany traces suddenly qualify for retention, the downstream store can become the\nbottleneck. Define what happens when buffers fill, and test a burst of failures\nwithout depending on a healthy baseline. Use the same trace identity throughout\nthe processing path where a complete trace is needed.\n\nConsider obligations that require a complete record, such as a durable\napplication audit trail or a completed job's status. Those records have a\nseparate lifecycle and need a clear storage and retention contract. Configure\nsampling at the layer that owns diagnostic evidence, then test that the required\nproduct record remains available whether a corresponding trace is kept or\ndropped. If the team needs a statistical estimate from a sample, establish the\nsampling method and inclusion probabilities before interpreting it.\n\nFinally, preserve useful provenance when changing policies. Record the version\nof the rule and relevant periods when it was active. A policy change can reduce\nthe number of stored traces. Compare a stable aggregate measure before\nattributing that decline to the product. A reliable sampling design gives\noperators usable diagnostic examples and an explicit indication of the evidence\nthat was missed or filtered.\n\n## Further reading\n\n- [OpenTelemetry sampling](https://opentelemetry.io/docs/concepts/sampling/).\n  Describes head and tail policies and their trade-offs.\n- [OpenTelemetry trace SDK sampling](https://opentelemetry.io/docs/specs/otel/trace/sdk/#sampling).\n  Specifies decisions and the data available to SDK samplers.\n- [OpenTelemetry Collector tail sampling processor](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/tailsamplingprocessor).\n  Documents a practical collector implementation and its limits.\n\n\u003chttps://engineer.company/glossary/telemetry-sampling/\u003e\n","date_modified":"2026-11-25T07:18:46Z","description":"Compare head and tail selection for traces and see why a diagnostic sample can bias a reliability estimate.","formats":{"gemtext":"https://engineer.company/glossary/telemetry-sampling/index.gmi","gopher":"https://engineer.company/glossary/telemetry-sampling/gophermap","html":"https://engineer.company/glossary/telemetry-sampling/","json":"https://engineer.company/glossary/telemetry-sampling/index.json","markdown":"https://engineer.company/glossary/telemetry-sampling/index.md","pdf":"https://engineer.company/glossary/telemetry-sampling/index.pdf"},"kind":"page","language":"en","title":"What is telemetry sampling?","url":"https://engineer.company/glossary/telemetry-sampling/","version":1}