Use tail sampling to retain traces for AI workflow outcomes that become known after execution begins. Set the policy against the final application outcome, including failures after a successful model call. Then test a fast success, a known failure, a deadline case, and an error span that arrives after the expected decision. Query for the exact trace IDs and required spans in the backend. Maintain an independent count of completed and failed workflows, because the trace pipeline can lose data before or after sampling. OpenTelemetry sampling overview
TL;DR. An error policy can act on failure evidence that reaches the same sampling decision in time. A durable workflow outcome tells you the run failed. A backend query by trace ID tells you which diagnostic evidence survived. Hold the policy change if the designed failure examples are missing, the late case cannot be explained, or the backend read cannot distinguish sampling from export delay.
| Decision | First place to look | Evidence that changes the decision |
|---|---|---|
| Which failures should produce a retained trace? | Final application outcome and the span or attribute the policy sees | A successful provider response followed by a rejected output must exercise the intended rule |
| Is the sampler receiving enough context? | Span records on the ingress path and the mapping from trace ID to sampling instance | Missing finalizer span or split routing requires repair before changing the policy |
| Did the decision happen before the error arrived? | First arrival, qualifying span arrival, strategy, and decision timing | Inspect a bounded late-span case under the exact deployed strategy |
| Was the retained trace usable? | Backend query for the run’s trace ID and required span IDs | A root span alone may leave the workflow failure unexplained |
| What is the real failure rate? | Independently counted outcomes for the intended workflow population | Error-enriched trace selection changes the visible mix |
Decide what a useful retained trace must contain
Start with an operator facing a real diagnosis. A document workflow accepted a request, made a successful model call, and later refused to apply its result. The operator wants to distinguish a tool timeout from an invalid application result and needs to see the responsible workflow stage. A metric for model HTTP errors cannot answer that question. A trace with only the model span cannot answer it either. Define the evidence the operator would need from a retained trace before choosing a sampling policy.
Write the failure classes in application terms. The list might include rejected output after validation, a user-visible deadline exceeded, irreversible failure to perform an approved write, and a degraded answer returned after an exhausted retry policy. Each class needs a reasoning boundary: what marks the operation complete or failed, whether a fallback counts as usable output, and whether retries change the outcome population. Decide where that final state is recorded and how the trace can display the same state. A transient error recovered by retry may be valuable diagnosis, but distinguish it from a failed workflow in any report.
Choose the spans that make a retained trace actionable. A typical requirement is the workflow entry span, the finalizer span with its terminal outcome, and the span for the stage that changed the decision. For a rejection after a successful model call, the provider span and validation span may both matter because together they establish which part worked. For a deadline case, a queue wait span may explain the missed deadline even when model inference was fast. Protect the minimal detail needed to distinguish causes. A policy does not need document contents, raw prompts, credential material, or personal identifiers to retain a useful trace for the cases in this guide.
Record whether the successful diagnosis needs the entire traced lineage or only certain stages. Some models produce long traces with many background operations. An operator may be able to make the day-to-day decision from a terminal reason code and a few child spans. If a trace is truncated or filtered, decide which missing spans change that diagnosis. Backend verification must reflect this distinction. A trace is present when any indexed span can be found. It is usable for the specific investigation when the required span set and outcome attributes can also be checked.
Use the result to scope retention. A workflow with very cheap telemetry may retain all traces for a bounded window and gain less from selective tail decisions. A high-volume workflow may need to preserve every observed error signal plus a small success sample for comparison. A system that cannot send final outcome evidence along the same trace path should first repair that evidence path or rely on a deliberately separate terminal record. Increasing the number of traces exported will not recover a signal that instrumentation never supplied.
Mark the outcome where the operator can find it
A model call and its parent workflow can truthfully have different outcomes. The provider can return a successful response, the validator can reject the shape, and a fallback may still let the workflow complete with a restricted result. Mark each span according to its semantic scope. Record the application outcome on the span that owns the terminal workflow decision, using the project's agreed reason code or status convention. The OpenTelemetry trace specification describes span status and its possible values. The project's application-level classification still needs explicit design. OpenTelemetry Trace API and span status
Match that classification to the actual Collector policy. A policy that checks for an error status needs a span with the relevant status value. A workflow reason stored only as an attribute needs a policy configured to see that attribute with the correct type and accepted value. Policies can select on different parts of received telemetry. Review the exact processor version and active settings so a trace with a relevant span matches for the intended reason. If you use several OR conditions, preserve a fixture that matches each of them independently. Otherwise an error trace kept by a catch-all success rule may conceal an ineffective status policy. Collector tail sampling processor and policies
Test the resolved attribute where your policy can read it. Instrumentation libraries, redaction and transform processors can all change which value reaches sampling. Suppose the finalizer records the string “rejected” at its source. A later transformation might rename the attribute, normalize its value, or remove it. A backend trace from a separate diagnostic pipeline could still show the original string. Inspect the equivalent value at sampling ingress with a permitted test fixture or known instrumentation record. A written setting describing an attribute is weaker evidence than observing a staged span enter the relevant policy with that attribute.
Associate the trace with a workflow outcome ledger. Use only identities your application can retain safely. A fixture record can include synthetic run ID, trace ID, expected workflow outcome, required spans, relevant timestamps, and observed terminal result. Keep the authoritative outcome source separate from the sampler. That way a downstream trace loss can be measured even when the complete failed trace cannot be read. If retries produce several traces, save the relationship between one logical run, its attempts, and their trace IDs in the authorized environment. Use the run ID to count workflow customers and the attempt ID to diagnose retries.
Make one outcome positive control explicit. Send a request that succeeds at the provider and intentionally fails the staging validation afterward. Observe the provider success and workflow rejection as distinct expected results. If a trace arrives and both stages are visible with the expected attributes, you have evidence that the sampler responded to an application failure after the call. If only provider-error cases are ever tested, success at the model boundary may suppress exactly the trace you need for validation incidents.
Follow the trace from the producer to the backend
Inventory the path taken by spans, beginning at each component that can supply a required diagnostic span. A front end might send an entry span, a worker might send model and retry spans, and a finalizer might send the terminal reason. A local agent and a central Collector might use different queues and processors. The path inventory should name who owns each producer, where it exports, how a trace is assigned to a sampler instance, and where the sampler sends accepted spans. Keep topology small enough for an operator to reason about when a result is missing.
Check that the tracing context actually propagates across asynchronous boundaries. A span emitted by a finalizer with a newly created trace ID will not join the original run's root just because both records share a request ID. Capture the trace ID supplied when each required span is emitted and distinguish parent-child structure from a separately linked trace. If the architecture intentionally creates separate traces for asynchronous work, document how a design can retain and correlate both, or put a suitable completion indicator on the trace whose retention the operator depends on. Adjust the diagnosis scope to the propagation that exists. OpenTelemetry trace context and span context
Tail decisions need a sampling instance to see the relevant spans. In a horizontally scaled Collector deployment, route spans for one trace to the same tail sampler instance. Verify that routing on more than one producer, especially a separate asynchronous service that emits the terminal span. The Collector project's tail sampling notes describe the requirement that all spans for a given trace reach the same instance, and the routing exporter supports consistent distribution by a routing key where implemented. Check the actual policy, routing configuration, health changes and version, rather than assuming an arbitrary round-robin layer keeps trace affinity. Collector tail sampling requirements · Collector load balancing exporter
In a synthetic rehearsal, assign a staging trace to two services that normally export to separate agents. Capture an entry span at the first agent and a terminal span at the second. Confirm their trace IDs match and that the test evidence identifies the ingest path each span actually took. Send the pair under a stable collector membership and observe how both reach the sampler. Repeat once during a planned routing change in staging if collector replacements are part of your operating assumptions. A stable-membership pass does not establish what happens when the resolver changes its view of available instances during an active trace.
Examine upstream filtering before tuning the tail rule. An SDK head sampler can decide that a trace is not recorded or exported early in the request. A Collector processor can remove spans or their relevant attributes before tail sampling. In either case the tail decision cannot act on evidence it never receives. Record the head-sampling condition in every fixture where it changes what reaches the sampler. If you test end-to-end policy visibility using an always-recorded synthetic trace in staging, report that permission and test scope. It improves test attribution without proving complete production ingress. OpenTelemetry head and tail sampling concepts
Pin a decision strategy and its timing
A timing fixture needs an explicit clock reference. For this guide, the decision timer begins when the sampler first sees the staged trace, subject to the active processor strategy and version. Record when the incoming trace first becomes visible to the component that owns the decision. Distinguish that from user request time, application span start time, producer export time, and backend indexing time. A timestamp copied from a span may describe when work happened rather than when the sampler received that evidence. If telemetry comes from several machines, join records by identity and use comparable time references.
The Collector tail sampling processor documents the decision wait and strategies that affect evaluation of arriving span batches. It also describes handling for late spans and decision caches. Pin the release and strategy for the fixture. An in-flight trace arriving under a configured wait can be complete enough to match a keep rule before the decision, or may be missing the key evidence when evaluated. Some strategies evaluate and maintain decisions differently. Do not infer the fate of a late span solely from how many seconds it arrives afterward. Read the relevant setting and check the observed result under that setting. Collector strategies and late-span behavior
Make the decision procedure readable even to someone who does not write configurations. For this staged example, keep any trace observed with the specific application error condition or an explicit application deadline marker, with no extra probabilistic keep rule in the fixture. Record the scope of the trace population that reaches the policy, as well as any processors that precede or follow it. The change owner should be able to answer whether errors elsewhere in the trace are supposed to match, how overlapping rules combine, and whether a success control can be kept for another documented reason. This gives you enough information to set expected outcomes honestly.
For a customer operation that may run much longer than the sampling window, decide whether to retain early instrumentation, attach a useful event before the decision, use a strategy designed around your true duration, or produce linked diagnostic records. No choice should promise to capture all failures merely by placing a rule in configuration. A long streamed answer or lengthy background completion can legitimately outlast a wait chosen for ordinary synchronous inference. Treat those workloads as separate evidence groups if their timing changes the mechanism. A fixed wait suitable for one class is a hypothesis for a longer class until tested.
Run the four-trace fixture with an independent outcome ledger
In this synthetic staging exercise, an inference-backed document pipeline sends an initial span for each request promptly. A tested trace-complete policy allows ten seconds for its decision and matches expected app validation errors or a deadline marker. The fixtures intentionally avoid unrelated keep policies. Measure times from observed sampling ingress. A model result accepted by business logic, a successful model result rejected by business logic, a workflow that passes its deadline, and a delayed failure span provide four distinct cases. Record the expected application outcomes independently of export.
| Fixture | Expected application outcome | Qualifying evidence reaches sampling | Backend check |
|---|---|---|---|
| Fast accepted result | Success | No keep condition | Compare the observed drop with a healthy exporter and a passing positive control |
| Successful model return with output rejection | Failure | Finalizer reports error at four seconds | Find the exact trace ID, provider-success span, and rejection span |
| Deadline exceeded | Deadline outcome | Finalizer supplies the intended marker at seven seconds | Find the exact trace ID and the span or attribute that caused the policy to match |
| Error arrives after the decision window | Failure | Diagnostic error arrives at twelve seconds | Inspect actual decision, cache and routing behavior, then check which spans are visible |
Give every fixture a unique run ID and trace ID. Run trials sufficiently far from each other if the Collector's metric granularity cannot otherwise attribute aggregate changes. If you run them together, use safe staging inspection that can still identify where each trace went. Keep the fast-success control semantically simple. Its trace contains no failure or deadline trigger, yet the workflow outcome and trace creation are known. The acceptance rule should reject a successful result in the failure fixtures and reject a test in which positive traces cannot be recovered. A backend result saying simply that two traces were indexed fails to identify which two traces mattered.
Then replay the output rejection while altering one precondition. For example, hold back the staged finalizer delivery in the test harness while the start and provider spans arrive normally. Preserve the same application failure in the outcome ledger. This separates late delivery from a different business outcome. Check sampler ingress timestamps for the finalizer, and query both the original trace and any unexpected trace ID emitted by the finalizer. If changing the arrival order silently changes which essential spans are visible, write that limit into the policy rollout decision for workloads with comparable timing.
Use proper comparison and negative controls. One useful apparatus control drops a required span intentionally in a staging-only workflow. The verifier should describe the trace as present but inadequate, or missing if applicable, while the workflow outcome remains known. Another control rejects an irrelevant or unrelated trace that contains the same generic error status. If that second case is retained anyway under the real policy, determine whether keeping broadly scoped errors is intended. Measurement and configuration can fail in opposite directions. A reliable fixture detects both loss of required traces and a scope broad enough to conceal a broken decision rule.
Before running the fixture, decide when a readback can reasonably happen. Include decision time, expected exporter delay, and the delay allowed before the backend query is reliable under your test conditions. If the last check happens too early, an error trace may be temporarily missing despite a keep decision. At the deadline, record any known pending or retrying export as unresolved. Allow a bounded follow-up tied to the original run identity or collect evidence that the export attempt has terminally failed. Keep the initial missed deadline visible even if the diagnostic later arrives. Timely diagnosis and eventual delivery answer different operational questions.
Read the result at three separate boundaries
The first useful boundary is sampling ingress. For each required span take the strongest permitted evidence you have that it reached the relevant sampler instance under the intended trace ID. If the terminal span never reached ingress, investigate instrumentation, upstream filtering, collector delivery or identity propagation. Compare with an early span from the same run. Repair the first missing evidence before changing the sampler wait. A longer window cannot make a missing attribute or unrecorded span appear.
The second boundary is policy decision and export. Inspect the applicable Collector diagnostics for sampled and dropped outcomes, pressure, queues, retries and refused requests. Some installations only have aggregate counters ordinarily. Use those as corroboration and keep case-level decision claims bounded to what the fixture can isolate. If you cannot attribute an aggregate drop event to the exact trace, explain that uncertainty. The Collector resiliency documentation covers queueing, retry and scenarios in which telemetry can be lost.
The third boundary is the user's backend query. Search for the exact trace ID in the environment or tenant to which the staged Collector exported. Check that expected time boundaries and retention windows include the measurement. After finding the trace, read the required span IDs or types and outcome attributes used by your diagnosis. Verify direct trace lookup before assuming a broad search view indexes all attributes in the same way. If sampling retained a trace that contains only part of the diagnosis, mark the result partial and find the first missing span boundary.
A helpful decision worksheet has columns for fixture case, terminal outcome, first ingress, qualifying span ingress, sampler instance, observed decision or diagnostics, export observation, backend result, and required span set. Write down what would falsify each explanation. If the same trace ID appears with terminal evidence in sampling ingress before a timely positive decision was expected, a pure upstream-loss explanation is weak. If a keep decision is observed but the backend sees nothing while the exporter is stalled, inspect export rather than changing the application classification. Keep both the initial result and the later reconciled evidence.
Do not collapse terminal states during incident response. “Found” means you can read an attributable trace. “Partial” means the trace exists but a required span or attribute is missing. “Dropped by policy” needs evidence tied to that decision or a sufficiently isolated fixture. “Missing before sampling” requires evidence of the earliest absent boundary. “Pending or unknown” is a valid state when the available observations fit more than one explanation. Give the last one a named next action, such as checking exact-ID export or confirming ingress on the finalizer's path.
Tell late delivery apart from lost trace affinity
When the late case is missing, compare it with an early error using the same producer path. If the early positive case consistently reaches the backend with the finalizer span, the path can work in at least that timing class. For the delayed case, decide which explanation predicts a different result if you change just one input. A longer decision wait might preserve a trace whose loss came from a late qualifying span. Keeping the time constant while correcting deterministic routing might preserve a trace whose spans had been split. A structural absence of the finalizer span at its producer predicts no recovery from either change.
Verify right before drawdown. Check the staging observations for type and sequence: same trace ID, actual instance identity, exact first and qualifying arrivals, sampler configuration digest or version, and exporter readback. If the test layout changes the Collector membership midway, record the event and compare the case with stable membership rather than treating both as the same conditions. A recovered run after a combined topology and timing change cannot in itself identify which change helped.
If increasing the wait is the proposed fix, run the same failure case at its original delay against the original and candidate policies. Then run a fresh case that falls just beyond ordinary delivery patterns. Make sure the original expected positive cases and the fast-success negative case still behave as intended. A longer window may retain more late diagnostic detail, but it also holds more in-flight state and can affect the time until a trace is visible. The decision should reflect both properties. Avoid moving the deadline until every missing trace fits the new line. Unbounded in-flight work or repeated late arrivals need a more explicit design.
If routing is the proposed fix, repeat per-trace affinity checks for at least two independent producer paths. Check steady state before testing a routing change. If you can safely model membership transition, include a trace with spans emitted before and after that transition, with an outcome and readback under both versions. Do not claim recovered trace completeness from the existence of a single backend span. If the data path does not let you isolate the sampler instance, report affinity as unverified and strengthen the staging evidence before tuning further.
Hold the test tenant, policy and readback deadline fixed while diagnosing a missing rejection trace. A qualifying span arriving after the decision on the same instance points to timing. A timely span on a different instance points to trace routing. If the intended instance recorded a timely keep decision and the exporter is retrying, keep backend delivery pending and query again by the original trace ID at the agreed deadline.
Budget retention and delay as measured tradeoffs
A longer wait retains more in-flight trace state at similar arrival rates. For an initial planning approximation, multiply newly observed trace starts per second by average seconds spent awaiting decisions, under steady arrivals and a stable release. In a synthetic comparison, one hundred trace starts per second and an average ten seconds in the pending stage suggest about one thousand pending traces. At an average of twenty seconds, the same approximation gives two thousand. This is a concurrency estimate, not a memory benchmark. Trace size, span count distribution, retries, earlier decisions and the Collector version affect resource use.
Measure memory and throughput around the same timed fixture. Track arrivals, observed in-flight decisions, process memory, dropped and sampled diagnostics, exporter lag, and readback latency for the same population and time period. Run the initial test at modest representative load. Include a separate replay with realistic long trace size or concurrently active application stages. If representative traffic bursts can overflow the observed capacity, do not make a high-volume guarantee from the low-volume case. Record what happens when the Collector is pressured and what operational result tells you to revert.
Choose a scope for success sampling too. Diagnostic workflows benefit from a comparable set of non-error traces when investigating stage timing or model differences. Pick that policy based on the intended operator question and available budget. Measure how representative the sample is for the relevant slices. A retained error population cannot provide context for ordinary latency unless it includes suitable success observations. Do not promote a policy solely because it increases debug detail on the errors you can already see. Compare which failures are actionable, how much event data was exported, and how soon a human can locate the evidence.
Treat downstream delay as equally consequential. If you make the sampling wait longer and also add an expensive backend processor, a successful export could still arrive after the on-call decision deadline. Measure time from application terminal outcome to usable backend evidence, broken down by stages if evidence permits. Keep a staging scenario that exceeds the decision deadline without simulated permanent loss. This is a check of what the operator can see in time. A policy may be reasonable for offline diagnosis and insufficient for urgent response, and the article's decision rule allows that distinction.
Keep outcome counts independent from diagnostic retention
Compute failure rates using a source that counts all eligible outcomes for the defined population, or use an explicitly designed and checked sampling estimator. If one thousand staged workflow outcomes include forty failures, the failure rate in that illustrative population is four percent. An error-prioritized trace backend might contain thirty qualifying failure traces and twenty success traces from the same window. Sixty percent of those visible traces show failure, which describes the retained sample alone. Even if every one of the thirty traces is useful to diagnose a problem, that visible composition cannot substitute for the all-outcomes count.
Choose units and exclusions before comparing traces with application records. Count one logical workflow outcome if the business question concerns request outcomes, and keep attempts separate if evaluating retried internal operations. Exclude customer cancellations only if the agreed measurement defines them separately. Mark incomplete runs and time window boundaries so counts align. Two traces for two attempts of one run should help diagnosis without changing the denominator of customer-facing outcomes. If the independent ledger has unknown coverage, state that before reporting a rate. sinc-LLM on failure-rate sampling
Use a retention coverage measure when it answers a concrete operational question. For example, for eligible staged failures with a known run ID and required span list, record how many were found with adequate evidence by the readback deadline. Report that number over the number of eligible fixture failures, with the environment, policy version, and reason for loss or ambiguity. It is a measured completeness result for a specified fixture. It gives no automatic estimate for production jobs that use different trace topology, runtime versions, durations or error handling.
On rollout keep the baseline failure count and the staged comparison alongside sample volume. A decrease in visible backend errors may come from fewer actual failures, weaker instrumentation, change in sampler policy, delay, or a different workload. State which independent observation supports the interpretation. If outcome records show stable failures while required diagnostics become sparse, focus on the trace evidence path. If outcomes changed at the same time, use a comparable stable population or clearly say the effects cannot be separated from the available observations.
Record the decision and the recovery path
Save what another operator needs to repeat exactly. Include the path from each test span producer to the backend, the active Collector release and strategy, the exact policy outcome, the owning stage of each reason marker, the selected readback deadline, and the independently observed run result for each fixture. Preserve a small neutral test trace and an adverse fixture identity. Where production policy eventually differs from staging, name the difference and reassess entries that depend on it. Avoid saving raw business payloads to establish this behavior.
Hold promotion on a failed early positive result, an unexplained split trace when affinity matters, an inability to distinguish pending export from permanent loss, or loss of required spans for a workload covered by the promise. If the alert relates to current users, use the independent application records to guide diagnosis while the trace issue remains open. Prefer a previously qualified policy when its evidence still applies, and rerun the same fixture after a correction. A recovered result should name which trace arrived, which essential spans were present, and which deadline it satisfied.
Start with the validation-rejection fixture in one real staging pipeline. Record the synthetic run outcome first, then trace the finalizer marker from the producer to sampling. Query the exact trace ID at the destination. Once that positive path is visible, run the delayed-span fixture and the fast-success control. This sequence proves the diagnosis path before interpreting an absence, and it gives the operator an actionable stop point when the evidence stops.
Compare two policies without mixing their outputs
Give baseline and candidate sampling policies separate staging destinations, or label their output with a field the backend preserves and can filter. If both paths write the same spans to one indistinguishable destination, a trace kept only by the baseline could make the candidate appear to pass. Record the expected trace set per policy and check both required span coverage and duplicate exports. A common producer can make the inputs comparable, provided the duplicate feed stays inside the permitted staging scope and preserves the same timing and span identities.
For a concrete check, send one known set of synthetic traces to both decisions. Verify an early rejection in both paths, then include a delayed problem that the candidate deliberately gives more time. Query the trace and its required spans separately for each destination. If the same qualifying span appears twice in one output, inspect duplicate routes or retry effects before calling the output a fuller trace. More indexed span rows can be an artifact of repeated delivery. Use the span IDs and expected membership as the comparison.
Keep the baseline policy available until the documented recovery procedure has a verified destination read. A controller acknowledgment can show that a configuration was accepted. Sample one fresh positive fixture after returning to the baseline and verify that the replacement Collector and exporter actually delivered it.
FAQ
Will a tail sampling rule retain every failed workflow?
It can act only on the failure signal in the spans it receives and evaluates. Early sampling, split routing, late spans, policy mismatch and export issues can hide a failure. Test your exact policy and observed span arrival path. Keep an independent outcome record for complete operational counts.
Why does the model span show success when the workflow failed?
The model span describes the model request. A later validator, deadline checker or write stage can fail after that request returns successfully. Record the terminal application outcome on the appropriate span and make sure the specific failure policy sees it. Use a staging case with a successful model return and deliberately rejected business result to check both boundaries.
How long should the decision wait be?
Set an initial wait from observed arrival times of the decision-bearing spans and a diagnostic response deadline. Then test the controlled early and late cases while measuring evidence arrival, Collector capacity and exporter delay. Treat a proposed wait as a measured tradeoff under the deployment's actual strategy. For workloads much longer than the ordinary decision window, verify how a distinct policy or linked diagnostic record would satisfy the same operator need.
What if a trace is present but the important span is missing?
Treat it as a partial diagnostic. Verify whether the finalizer emitted the span, which trace ID it used, when and where it entered sampling, and whether export or backend ingestion lost it. Compare the required span set to the actual exact-ID backend result. A visible trace ID by itself cannot establish the failure cause.
Should I use the retained error traces to compute a failure rate?
Use independent outcomes for the denominator unless a separate, qualified sampling estimator accounts for selection and missing observations. A policy that preferentially keeps failures changes the composition of traces in the backend. It is suitable for diagnosing selected failures, and its selection rule needs to be part of any measurement derived from it.
Sources
- OpenTelemetry sampling concepts and limitations
- OpenTelemetry Trace API, span status and context
- OpenTelemetry Collector tail sampling processor
- OpenTelemetry Collector load balancing exporter
- OpenTelemetry Collector queues, retries and resiliency
- sinc-LLM’s guide to measuring failures from sampled traces
sinc-LLM