When OpenTelemetry tail sampling misses a known error trace, follow its trace ID from the application to the customer-run Collector and then to Jaeger. The SDK may have dropped the request at the head, the sampler may have decided before the ERROR span arrived, or that span may have gone to a different sampler. If the span reached the right sampler in time, check its actual status and look for the same span ID in the sampler’s output before investigating downstream delivery.
The Collector config, timings and outcomes below are illustrative. They run on loopback only. You'll send example traces for a fast success, a fast error, a slow success and a delayed error. Compare what the SDK records with what each Collector instance receives and exports, then use the same evidence to decide where to look when a trace is missing from Jaeger.
If you still need to add instrumentation or wire up tracing, start with the OpenTelemetry distributed tracing implementation guide.
Contents
Define error, slow and ordinary requests
Start with one failed operation whose approximate time and service you know. Get the trace ID from the application or a correlated log if you have it, and identify the span that should carry the failure. A request can have a server span, a database span and several downstream spans. The failing operation might be a child while its parent completes successfully after a retry. Find the failing span by its span ID if you can. A trace ID match alone can leave you looking at a trace whose most important span is missing.
Three expected policy outcomes
The policy outcomes and later timings in this post are illustrative. This example Collector uses three positive policies. The status policy matches when any span available to the sampler has status ERROR. An exception event by itself leaves the span’s status dependent on the instrumentation. Check the span’s status.code as well as its events and attributes. If the instrumentation calls the operation a failure but the emitted status is UNSET, the status policy has no match.
The latency policy uses the elapsed time from the earliest span start to the latest span end in the data available at the decision. This example sets a 500 ms threshold. A 900 ms success qualifies on elapsed time. A 100 ms success qualifies only if the probabilistic policy selects it. That policy is a top-level 5% baseline. It can match any trace ID, and its extra contribution is a sample of the traces the error and latency policies would otherwise leave out. Evaluate the conditions together. For these three keep rules, the listed order does not matter. A match on any of them keeps the trace. See the Collector Contrib v0.128.0 tail sampling processor documentation.
Local Collector setup
Use OpenTelemetry Collector Contrib v0.128.0 with the following complete configuration. Save it as collector.yaml in a working directory of your choice. The OTLP/HTTP receiver listens on loopback. Its ingress pipeline sends a local debug copy before sampling. The second pipeline uses tail_sampling and sends retained spans to a separate debug exporter. The two debug streams let you check both sides by span ID. Keep detailed span logging confined to this loopback example, because it includes the contents of each span.
receivers:
otlp:
protocols:
http:
endpoint: 127.0.0.1:4318
processors:
tail_sampling:
decision_wait: 2s
num_traces: 128
decision_cache:
sampled_cache_size: 128
non_sampled_cache_size: 128
policies:
- name: errors
type: status_code
status_code:
status_codes: [ERROR]
- name: slow
type: latency
latency:
threshold_ms: 500
- name: healthy-baseline
type: probabilistic
probabilistic:
sampling_percentage: 5
exporters:
debug/ingress:
verbosity: detailed
sampling_initial: 1
sampling_thereafter: 1
debug/kept:
verbosity: detailed
sampling_initial: 1
sampling_thereafter: 1
service:
telemetry:
metrics:
level: none
pipelines:
traces/ingress:
receivers: [otlp]
exporters: [debug/ingress]
traces:
receivers: [otlp]
processors: [tail_sampling]
exporters: [debug/kept]
For a deterministic run, save the following copy as collector-a.yaml before you start the Collector. It omits the four-line healthy-baseline policy, so the remaining error and latency rules give you a fixed comparison for each input. With the baseline enabled in collector.yaml, an ordinary trace can go either way, so a fast success in the output is compatible with the policy. A handful of trace IDs gives you a way to check individual decisions. Measuring the sampling proportion would require a larger set of distinct IDs.
receivers:
otlp:
protocols:
http:
endpoint: 127.0.0.1:4318
processors:
tail_sampling:
decision_wait: 2s
num_traces: 128
decision_cache:
sampled_cache_size: 128
non_sampled_cache_size: 128
policies:
- name: errors
type: status_code
status_code:
status_codes: [ERROR]
- name: slow
type: latency
latency:
threshold_ms: 500
exporters:
debug/ingress:
verbosity: detailed
sampling_initial: 1
sampling_thereafter: 1
debug/kept:
verbosity: detailed
sampling_initial: 1
sampling_thereafter: 1
service:
telemetry:
metrics:
level: none
pipelines:
traces/ingress:
receivers: [otlp]
exporters: [debug/ingress]
traces:
receivers: [otlp]
processors: [tail_sampling]
exporters: [debug/kept]
otelcol-contrib --version
otelcol-contrib validate --config=collector.yaml
otelcol-contrib validate --config=collector-a.yaml
otelcol-contrib --config=collector-a.yaml > sampler-a.log 2>&1
Keep the Collector binary on your path and run these commands from the directory where you saved the files. Keep A running in one terminal while you send traces. In a second terminal, use a Python environment with opentelemetry-sdk==1.34.0 and the script listed below. To exercise the routing failure as well, start B in its own terminal using the edited copy, then pass --split. Stop the local processes after you’ve inspected the logs.
# Optional sampler B, in its own terminal
sed 's/127\.0\.0\.1:4318/127.0.0.1:14318/' collector-a.yaml > collector-b.yaml
otelcol-contrib validate --config=collector-b.yaml
otelcol-contrib --config=collector-b.yaml > sampler-b.log 2>&1
# In another terminal, after saving send_traces.py
python3 send_traces.py
# With both A and B running, use this command for the split case
# python3 send_traces.py --split
Save the following script as send_traces.py in the same directory. It records example spans in the SDK and holds them until their scheduled OTLP sends. It prints each span’s trace ID, span ID, status, destination and expected export for the deterministic configuration. HTTP acknowledgements are printed as separate lines. Use debug/ingress to confirm receiver-side arrival and debug/kept to check the sampler’s output. Search both log files for a trace ID from the script output, then compare the span IDs under each exporter. Wait for the decision window to elapse on both instances before treating a missing output as evidence.
#!/usr/bin/env python3
"""Send illustrative traces to a local Collector over OTLP/HTTP."""
import argparse
import json
import time
from contextlib import closing
from http.client import HTTPConnection
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter
from opentelemetry.sdk.trace.sampling import ALWAYS_OFF, ALWAYS_ON
from opentelemetry.trace import Status, StatusCode
PORTS = {"A": 4318, "B": 14318}
def span_payload(span):
row = {
"traceId": f"{span.context.trace_id:032x}",
"spanId": f"{span.context.span_id:016x}",
"name": span.name,
"startTimeUnixNano": str(span.start_time),
"endTimeUnixNano": str(span.end_time),
"status": {"code": span.status.status_code.value},
}
if span.parent:
row["parentSpanId"] = f"{span.parent.span_id:016x}"
return row
def send(sampler, spans):
body = json.dumps({
"resourceSpans": [{
"resource": {
"attributes": [{
"key": "service.name",
"value": {"stringValue": "checkout-example"},
}],
},
"scopeSpans": [{"scope": {"name": "loopback-example"}, "spans": spans}],
}],
})
with closing(HTTPConnection("127.0.0.1", PORTS[sampler], timeout=3)) as conn:
conn.request("POST", "/v1/traces", body, {"Content-Type": "application/json"})
response = conn.getresponse()
reply = response.read()
if response.status != 200:
raise RuntimeError(f"{sampler}: HTTP {response.status}: {reply!r}")
rejected = int(json.loads(reply or "{}").get("partialSuccess", {}).get("rejectedSpans", 0) or 0)
if rejected:
raise RuntimeError(f"{sampler} rejected {rejected} spans")
def log(**fields):
print(json.dumps(fields), flush=True)
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--split", action="store_true")
args = parser.parse_args()
recorded = InMemorySpanExporter()
provider = TracerProvider(sampler=ALWAYS_ON)
provider.add_span_processor(SimpleSpanProcessor(recorded))
tracer = provider.get_tracer("example")
off_recorded = InMemorySpanExporter()
off_provider = TracerProvider(sampler=ALWAYS_OFF)
off_provider.add_span_processor(SimpleSpanProcessor(off_recorded))
off_tracer = off_provider.get_tracer("example")
epoch = time.time_ns() - 1_000_000_000
def record(name, end_ms, *, sdk=tracer, parent=None, start_ms=0, error=False):
context = trace.set_span_in_context(parent) if parent else None
span = sdk.start_span(name, context=context, start_time=epoch + start_ms * 1_000_000)
if error:
span.set_status(Status(StatusCode.ERROR))
span.end(end_time=epoch + end_ms * 1_000_000)
return span
record("fast-success", 100)
record("fast-error", 100, error=True)
record("slow-success", 900)
late_root = record("late-root", 150)
record("late-error-child", 80, parent=late_root, start_ms=40, error=True)
if args.split:
split_root = record("split-root", 150)
record("split-error-child", 80, parent=split_root, start_ms=40, error=True)
rows = {span.name: span_payload(span) for span in recorded.get_finished_spans()}
def post(sampler, expected, names):
spans = [rows[name] for name in names]
for row in spans:
log(event="span", sampler=sampler, expected_export=expected[row["name"]], **row)
send(sampler, spans)
log(event="http-ack", sampler=sampler, spans=names)
ordinary = {
"fast-success": False,
"fast-error": True,
"slow-success": True,
"late-root": False,
}
if args.split:
ordinary["split-root"] = False
started = time.monotonic()
post("A", ordinary, list(ordinary))
if args.split:
post("B", {"split-error-child": True}, ["split-error-child"])
time.sleep(max(0, 6 - (time.monotonic() - started)))
post("A", {"late-error-child": False}, ["late-error-child"])
off = record("fast-error", 100, sdk=off_tracer, error=True)
if off_recorded.get_finished_spans() or off.get_span_context().trace_flags.sampled:
raise RuntimeError("always_off unexpectedly produced a sampled span")
log(
event="span",
name="fast-error-always-off",
traceId=f"{off.get_span_context().trace_id:032x}",
sdk_sampler="always_off",
expected_export=False,
)
provider.shutdown()
off_provider.shutdown()
if __name__ == "__main__":
main()
Place decisions where the evidence still exists
SDK head sampling
The head sampler decides at span creation, when the request is starting. An SDK head decision that drops the request leaves the tail sampler without those spans. If the request failed later, the tail sampler still has nothing to evaluate. The example script also records a fast error under the SDK’s always_off sampler. It prints that attempt’s trace ID, the SDK exports no span, and no OTLP request is sent for that attempt. A valid trace ID in a log can therefore coexist with no trace data. See OpenTelemetry’s head and tail sampling documentation.
On an incident, check the effective sampler in the process that handled the request and inspect the parent context if the SDK uses a parent-based sampler. An unsampled upstream parent can affect local recording. If you already know the span was recorded, check whether the SDK handed it to its exporter, then whether the Collector received it. That extra checkpoint matters because a queue or transport failure can prevent a recorded span from arriving, and both cases look empty from the tail sampler’s side.
One trace ID, one sampler
At the sampling tier, all spans with the same trace ID need the same decision maker. Configure trace-ID-affine routing on the customer-run Collector tier upstream of the samplers. For an incident, compare receiver logs from each instance using the same trace ID and list the span IDs per instance. Check paths from every contributing service, especially if a gateway membership change overlaps the request. The fact that one OTLP request reached a sampler tells you only about the spans carried in that request.
The optional split case deliberately sends a successful root to A and its error child to B. With the baseline disabled, A has a short successful fragment and drops it. B sees the ERROR child and exports that fragment with the child’s parentSpanId set to the root’s span ID. Both decisions fit the evidence each sampler received. In a split trace, you can also lose a trace whose fragments each fail to meet the latency threshold even though the complete trace would have met it. A longer decision window on A cannot collect a span routed to B.
Choose a decision window against a late error
Arrival time vs span time
This example uses decision_wait: 2s on the customer-run Collector. The wait is tied to the first span the sampler receives for a trace, with evaluation scheduled by the processor. Span timestamps describe when the operation ran. Delivery can lag behind the operation because of batching, queues or retries. The late error in this example ends before its root ends, then arrives about six seconds after the root was sent. Its early end time will be visible in the ingress log when it arrives. The earlier sampling decision had only the root.
| Example step | Span start and end relative to the example clock | Scheduled arrival relative to first send | What to check |
|---|---|---|---|
| Send the fast success, fast error and slow success | Fast spans 0–100 ms, slow span 0–900 ms | A at approximately t+0 s | Check all three IDs at ingress. The fast error has ERROR status. |
Send late-root in the same batch | 0–150 ms | A at approximately t+0 s | The root alone is short and has status UNSET. |
| Send the split pair, if enabled | Root 0–150 ms, child 40–80 ms | Root to A in the first batch, child to B immediately after A acknowledges | Match one trace ID across the two ingress streams. Each sampler has a different span ID. |
| Allow the initial decisions to run | No span is sent at this step | Around t+2 s, subject to evaluation timing | The late trace can be evaluated using the root already in A’s buffer. |
Send late-error-child | 40–80 ms | A at approximately t+6 s | The child appears at ingress and inherits the cached drop for that trace ID. |
Repeat the fast error with always_off | Same example operation timing | No arrival | Follow the separate attempt ID in the script output. There is no SDK export for it. |
Both decision caches are set to 128 entries. In this small example the late child should find its trace’s cached drop and follow it. A late span for a cached keep can be forwarded under the existing decision. Once a previous decision is unavailable, a later span can be evaluated as a new fragment for the same trace ID. For that reason, read the sampler’s cache configuration before interpreting a late span’s outcome. To isolate timing in a follow-up, run the same send with a fresh instance and a window comfortably longer than the child’s delay. Look for the root and the child together in output. The printed expectations describe the original two-second run.
Eviction, late spans and policy misses
- Early eviction.
num_traceslimits the sampler’s trace buffer on each instance. If enough new trace IDs arrive, a buffered trace can be removed before its scheduled decision. Check buffer pressure and early-drop telemetry on the affected instance around the time the trace went missing. Pair that with trace arrival evidence. An aggregate rise in early drops cannot identify an individual victim. - Late span. The sampler made a decision using the spans available at the time. An error span with the matching ID enters the same instance after that decision. Check receiver time and the previous decision or cache behaviour, especially if the root was exported but the expected child is absent.
- Policy miss. The relevant spans arrived together before evaluation and the trace stayed in the buffer. Evaluate the actual status and observed duration against the configured policies. A fast span with an exception event and status
UNSETcan legitimately miss the error and latency conditions.
For a timing change, measure the gap from first receiver arrival to first error-span arrival on the same sampler and compare that distribution with the current decision window. Check it during bursts as well as ordinary traffic. Increasing the window holds more work in memory while decisions are pending. Review num_traces, available memory and the peak rate of new trace IDs together on each instance. The example’s capacity and delay are for isolating the cases on loopback.
Expected local decisions
These are illustrative expectations with the baseline removed and cache entries available. Compare each row with the IDs printed by the script and with the debug output. The split row applies only when you run both local instances.
| Example case | SDK recording | Arrival at each sampler | Status at decision time | Export |
|---|---|---|---|---|
| Fast success | Recorded | A gets the span. B gets none. | A sees UNSET and 100 ms. | None. No active policy matches. |
| Fast error | Recorded | A gets the span. B gets none. | A sees ERROR and 100 ms. | A exports the span by the error policy. |
| Slow success | Recorded | A gets the span. B gets none. | A sees UNSET and 900 ms. | A exports the span by the latency policy. |
| Late error | Root and child recorded | A gets the root, then the child after evaluation. B gets none. | A sees the root’s UNSET and 150 ms. | None. A drops the root and the late child follows the cached drop. |
| Split error | Root and child recorded | A gets the root. B gets the child with the same trace ID. | A sees UNSET and 150 ms. B sees ERROR and 40 ms. | B exports only the error child. A drops the root. |
Fast error with always_off | No span recorded | Neither A nor B receives a span. | No tail decision. | None. |
On your own stack, once the relevant span is present in sampler output, use the production exporter’s delivery evidence and then inspect spans and traces in Jaeger.
Interpret the result after a change
Use the local debug result to establish what the sampler passed on. For a retained span missing in Jaeger, check the production exporter’s destination, queue, retries and final outcome. Then confirm that you’re searching the intended APM stack, service and incident time window. If your customer-run Collector exports through the Logs-stack Hosted OpenTelemetry endpoint, traces require a linked APM add-on for storage. Check that link as well as the exporter’s response. Hosted OpenTelemetry signal routing describes the storage requirement.
Review the whole retained trace in Jaeger. If you expect an error child, open it and confirm its status and parent span ID. For a change to routing or wait time, also inspect a comparable normal example, such as a successful trace retained by the latency rule. Look for its expected service and span structure. A trace with the right ID and an incomplete set of spans calls for a span-by-span check across the same boundaries.
APM span counts
APM Statistics reports ingested spans by period. One request may generate several spans, and different requests may generate different numbers. Compare windows of similar length, request volume and service mix when you change sampling. A change in usage can reflect a different workload, a change in spans produced per request or a change in what reaches storage. Use the app’s request counter for request volume, and the Collector’s input, output and loss evidence for drop investigation. The share of retained traces with an error is biased by the error and latency policies. Use application request and error counters for a population error rate. See the APM Statistics guide for the available usage periods.
FAQ
Does an exception event qualify for the error rule?
The status rule checks span status. Inspect the span received by the sampler and verify that the instrumenter or SDK set ERROR for that operation. When the status is UNSET, check the latency and baseline rules separately to understand why the trace might still appear.
Should I increase decision wait or trace capacity?
Use a longer wait when the error consistently arrives on the right sampler after evaluation. Investigate capacity if traces disappear from the buffer before evaluation during bursts. If the spans land on different instances, address routing first, then recheck arrival timing on the instance that now receives the full trace.
Can I use Hosted Jaeger in the free trial?
Yes. The 14-day Logit.io free trial includes every feature, including Hosted Jaeger, APM Statistics and Hosted OpenTelemetry. No credit card is required. For trace storage through a Logs-stack Hosted OpenTelemetry endpoint, link the APM add-on to that stack.
Next steps
Take one missing error and write down the last place you can verify its trace ID and failing span ID. Recreate that failure mode on loopback, change one setting on the customer-run Collector, and check the IDs on both sides of that decision again. Once you can account for those spans, explore Logit.io Hosted Jaeger to inspect retained traces.
Unlock complete visibility with hosted ELK, Grafana, and Prometheus-backed Observability
