Span Gaps Turn Synthetic and Agent Passes Into SLO Lies
Many SLO programs share a quiet assumption: if the synthetic monitor is green and the test suite passes, users are fine. That assumption breaks when instrumentation has gaps between spans. A checkout flow can finish inside its latency target while a large share of that time sits in an uninstrumented queue handoff that no span describes. The synthetic passes, the latency SLI looks healthy, and the part that is degrading is invisible.
Agentic quality engineering adds a new place for these gaps. Agent workflows call a model, then tools, then the model again, often through code paths that were never instrumented: a vector store lookup, an internal API wrapped as a tool, a retry loop inside the agent framework. A synthetic check that asks the agent a question and asserts on the final answer can stay green while most of its time, and most of its failures, happen in steps the trace does not show.
This article defines span gaps, shows how to detect them in trace data and instrument the async boundaries that cause them, covers the mistakes that keep SLO teams getting burned, and applies the same checks to agent workflows.
Learn Node.js, Cucumber, GitHub Copilot, APIs, CI/CD, and modern automation by building a complete framework.
What Span Gaps Actually Are in a Trace-Backed SLO Stack
A span gap is the interval between the end timestamp of a parent span and the start timestamp of its first child span — or the silence between two sibling spans that should be contiguous. In a well-instrumented service mesh, that gap is microseconds: context propagation overhead. In a partially instrumented stack, the gap swallows entire service hops. OpenTelemetry's SDK records what it's told to record; if the message broker, the internal gRPC fan-out, or the legacy SOAP adapter isn't instrumented, those milliseconds simply don't exist in your trace.
Where this matters for SLOs: most teams define latency SLIs against the outermost span — the one their load balancer or API gateway emits. That span's duration is accurate. But the composition of that duration is opaque if child spans are missing. When you wire a Grafana SLO panel to histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[5m])), you're measuring end-to-end wall time correctly — but you have no visibility into which internal segment is degrading. A synthetic that probes the same endpoint will see the same wall time, pass its assertion, and report green while a downstream dependency quietly rots. This is the mechanism behind how span timing gaps make passing tests hide latency regressions in production.
Detecting and Instrumenting Span Gaps Before They Corrupt Your SLO Math
Start with a gap-detection query against your trace store. If you're on Tempo + Loki or Honeycomb, the approach is the same: find traces where the sum of child span durations is materially less than the root span duration. In ClickHouse with an OTel-compatible schema:
-- Find traces where time not covered by the root's direct children exceeds 200ms
WITH roots AS (
SELECT trace_id, span_id, duration_ms AS root_duration_ms
FROM otel_spans
WHERE parent_span_id = ''
AND timestamp > now() - INTERVAL 1 HOUR
)
SELECT
r.trace_id,
r.root_duration_ms,
sum(c.duration_ms) AS direct_child_ms,
r.root_duration_ms - sum(c.duration_ms) AS gap_ms
FROM roots r
LEFT JOIN otel_spans c
ON c.trace_id = r.trace_id AND c.parent_span_id = r.span_id
GROUP BY r.trace_id, r.root_duration_ms
HAVING gap_ms > 200
ORDER BY gap_ms DESC
LIMIT 50;
Only the root's direct children are summed: adding every descendant would count nested time twice. The query assumes the children run one after another; where a root fans out in parallel, children overlap and the sum can exceed the root, so compute covered time from the union of child intervals for those trace families. Run this hourly in a scheduled query and write results to a span_gap_anomalies table. A gap above 200 ms on a p95 path is a signal worth routing to a Slack channel before it becomes an SLO incident. Once you have the gap inventory, cross-reference against your synthetic test IDs. If the synthetics that probe those endpoints are passing, you've confirmed the false-green pattern.
On the instrumentation side, the fastest wins are usually at async boundaries. Add OTel context propagation to your Kafka consumers, SQS handlers, and any internal HTTP clients that aren't going through a service mesh sidecar. In Python with the OpenTelemetry SDK:
from opentelemetry import trace, propagate
def process_message(msg):
carrier = {k: v.decode() for k, v in (msg.headers or [])} # Kafka headers are (str, bytes) pairs carrying W3C traceparent
ctx = propagate.extract(carrier)
tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span("consumer.process", context=ctx) as span:
span.set_attribute("messaging.destination", msg.topic)
span.set_attribute("messaging.message_id", (msg.key or b"").decode(errors="replace"))
_do_work(msg)
That single context extraction stitches the consumer span back into the originating trace. Without it, Tempo shows a broken trace and your gap query above counts those milliseconds as uninstrumented. Instrumenting the async consumers on a service is often enough to shrink the measured gap dramatically, and doing so tends to expose the real cause of the latency, such as a downstream call that regressed over several deploys and had been hidden inside the gap.
For the SLO dashboard layer, add a Grafana panel that plots gap_ms P95 alongside your error budget burn rate. When both trend up together, you have a span-gap-driven SLO erosion event, not a genuine latency regression in instrumented code. This distinction matters for postmortems: the fix is instrumentation, not a rollback. Teams that skip this correlation end up reverting clean deploys because their pass rate drift metrics hide the real broken stage — the observability gap itself.
Where SLO-Driven Teams Keep Getting Burned by Timing Gaps
Asserting on wall time without a gap budget. Teams set latency SLOs against end-to-end duration and write synthetic assertions like assert response_time < 4000. That's necessary but not sufficient. Without a companion assertion on instrumented coverage — something like "at least 85% of root span duration must be accounted for by child spans" — you're asserting on a number that can stay green while the internal composition degrades. Add a gap-budget check to your synthetic runner and treat a gap-budget breach as a warning-level SLO event even when wall time passes.
Treating trace completeness as a deploy-time concern only. Most teams audit instrumentation during onboarding and never again. Services evolve: new async workers get added, libraries get swapped, sidecars get misconfigured after a Helm chart bump. A span gap that didn't exist in Q1 can appear in Q3 after a dependency upgrade and silently corrupt six weeks of SLO data before anyone notices. Schedule the ClickHouse gap query as a recurring CI check — not just a one-time audit — and alert when the gap P95 for any high-traffic trace family increases by more than 50 ms week-over-week.
Span gaps in agent workflows
An agent request is a trace with an unusual shape: a root span for the request, then alternating model calls and tool calls, sometimes nested inside a framework's own loop. Teams usually instrument the model call first, because that is where cost and latency are most visible. The tool calls, the retrieval step and the framework's retries are often left untraced, and that is where gaps open.
The gap query above works unchanged on these traces, and it is worth running specifically against agent request roots. A large gap on an agent trace usually means one of three things: an uninstrumented tool backend, a retry loop that runs between spans, or time spent waiting on a rate-limited model endpoint before the call span starts.
For synthetic checks against an agent, add the same gap budget recommended above, plus one agent-specific assertion: the trace must contain a span for every tool the agent reported using. If the agent's answer says it looked up an order but the trace has no matching tool span, either the instrumentation is missing or the agent did not do what it claims. Both are worth knowing.
def check_agent_trace(spans, reported_tools, root_ms, max_gap_ratio=0.15):
traced = {s["name"].removeprefix("tool ") for s in spans if s["name"].startswith("tool ")}
missing = set(reported_tools) - traced
covered = sum(s["duration_ms"] for s in spans if s["parent_is_root"])
gap_ratio = 1 - covered / root_ms if root_ms else 0
return {"missing_tool_spans": sorted(missing), "gap_ratio": round(gap_ratio, 3),
"ok": not missing and gap_ratio <= max_gap_ratio}
Report agent synthetics on two lines: whether the answer passed, and whether the trace was complete. A passing answer on an incomplete trace is the agentic version of the false green this article describes. For a related failure mode, see why passing traces hide incomplete span coverage.
The Myths That Keep Synthetic Pass Signals Untrustworthy
Myth: a passing synthetic means the SLO is healthy. A synthetic probes a path. It measures what it can observe — typically the HTTP response from an edge endpoint. It has no view into whether the trace backing that response is complete. A 200 OK in 3.9 seconds satisfies a 4-second SLO assertion regardless of whether 600 ms of that time is an uninstrumented queue. The synthetic is not lying; it's just answering a narrower question than you're asking it. The fix is to read test results as more than a pass/fail signal — attach trace IDs to synthetic runs so you can inspect coverage on demand.
Myth: 100% pass rate on synthetics validates your error budget math. Pass rate is a frequency metric. SLO burn rate is a time-weighted latency and availability metric. They measure different things and can diverge significantly when timing gaps exist. A synthetic suite with a 100% pass rate running against an endpoint with a 340 ms span gap is producing a clean signal about availability while producing no signal at all about the latency SLI. Teams conflate these because both live on the same dashboard and both trend green. Keep them in separate panels with explicit labels about what each one is — and is not — measuring.
Span gaps are an instrumentation debt problem masquerading as a testing problem. The corrective path is mechanical: run the gap-detection query, rank gaps by P95 impact on your highest-traffic trace families, instrument the top three async boundaries, and add a gap-budget assertion to your synthetic suite. Once gap_ms is tracked alongside burn rate in Grafana, your SLO dashboard reflects reality instead of reflecting the limits of your instrumentation. Start with the ClickHouse query above — the first run usually surfaces a surprise.
Note: This article is for informational purposes only and is not a substitute for professional advice. If you need guidance on specific situations described in this article, consider consulting a qualified professional.