404human Projects Writing Build logs Learning Books Progress
Rust · Zola
zsh · 404human@dev:~ Tab complete · ↑↓ history · type help

AI observability: why telemetry must show gaps

What AI observability actually needs in production—per-operation timelines, explicit gap markers when events drop, secret redaction, and real bugs.

Published
Read time
6 min read
Kind
guide
Topics

Most AI observability tools look impressive in a demo: neat green trace waterfalls, token charts, latency histograms, and prompt playgrounds. Then traffic spikes, a collector drops 3% of batches, or a single bad payload causes an ingest 500—and the dashboard quietly draws a clean line right through the missing events.

In ordinary web apps, losing 2% of sampled HTTP spans is fine. In an AI agent that calls tools, retries writes, and spawns background jobs, silent telemetry loss is actively dangerous. If your trace shows two tool calls when the agent actually executed four—and one of the dropped events was a payment retry or a refused permission—your observability dashboard just misled the operator investigating an incident.

That is the core principle behind AI Operations Layer, the Rust + PostgreSQL + SvelteKit telemetry system we are building in public: telemetry is evidence, not authority. When events go missing or get refused, the timeline must show how many and where as an explicit gap instead of pretending the record is complete.

What makes AI observability different from traditional APM

Standard APM tracks deterministic RPC trees: service A calls service B, returns 200, done. AI operations break four assumptions built into classic tracing:

DimensionTraditional web APMProduction AI agent observability
Control flowFixed call graph known from codeNon-deterministic loop: the model picks 0 to N tools dynamically
Failure modesHTTP 5xx, exceptions, timeoutsSilent wrong answers, hallucinated tool arguments, tool 200 OK carrying a failed job record, unexecuted completion claims
OutcomesSucceeded or failedSucceeded, failed, retried, or uncertain (worker crashed mid-tool call—did the external side effect commit?)
Data riskStructured metadata, predictable PII fieldsArbitrary user prompts, retrieved docs, and raw tool outputs that can accidentally carry API keys or tokens

Because of those differences, the primary unit of AI observability shouldn’t be isolated LLM completions. It should be one operation timeline tying together the user trigger, every model turn, every tool call, every retry, every background job transition, and every telemetry gap into a single ordered view.

Operation op_01J9...  (status: completed_with_gaps)
  10:04:01.012  model.call       qwen3:8b       812 tokens   410 ms   ok
  10:04:01.430  tool.call        search_docs    2,140 B       38 ms   ok
  10:04:01.471  [TELEMETRY GAP]  2 events shed by collector (10:04:01.47–10:04:02.10)
  10:04:02.115  tool.call        create_draft   draft_94      52 ms   ok
  10:04:02.680  model.call       qwen3:8b       940 tokens   510 ms   ok

An operator reading that timeline knows immediately both what succeeded and where the evidence has a hole.

Four real bugs we hit building an AI observability collector

Building our own collector (A0 done twice: one bad character lost a whole batch) surfaced four production failure modes that apply whether you build your own AI observability pipeline or evaluate commercial AI observability tools:

1. One bad event poisoned an entire batch

An event containing a single NUL byte (\0) caused PostgreSQL to reject the entire ingest batch with a 500—silently losing every healthy operation bundled in the same HTTP request.

Fix: Treat a bad event as that event’s problem, never the batch’s. Refuse the malformed event by name, store the rest of the batch, record the refusal count as a visible gap on the operation timeline, and have the SDK sanitize NUL bytes and bisect refused batches down to the single offending event.

2. Unauthenticated floods can exhaust collector memory

Because observability collectors sit on the hot path of every agent request, they are easy to overwhelm if authentication happens after reading request bodies. On our Mac M2 Pro (12 cores, 32 GiB), 256 unauthenticated connections sending ~1 MB bodies spiked collector memory from 6.4 MiB to 266.0 MiB and stalled clients.

Fix: Validate API keys from HTTP headers before reading a single byte of the body, return 401 immediately on unknown keys, enforce a global in-flight body memory budget (32 MiB in our collector), and set write-stall deadlines (10 seconds) so slow readers cannot pin every server slot. After that fix, the exact same 256-connection flood stayed at 6.4 → 12.3 MiB, and fresh health checks answered immediately even when connection slots were full of non-readers.

3. Secret redaction leaks across unexpected encodings

In AI observability, prompts and tool outputs routinely pick up stray credentials—from debug logs, HTTP headers, or environment dumps. When a second independent reviewer attacked our initial redactor, 11 of 13 realistic secret shapes leaked through, including camelCase keys, Ruby hashes, escaped JSON strings, URL-encoded values, and raw Authorization header lines.

Fix: Redact inside the SDK before data leaves the host and again at ingest, test against encoded/escaped variants, and document honestly that pattern-based redaction is partial defense-in-depth—not permission to pass raw secrets into agent tool outputs (see AI agent security: threat model and defenses).

4. Under real load, shedding happens—make it honest

When we ran our first 1,000,000-event ingest test on a busy machine (load average jumping from ~6 to 28 while another test suite started), 999,630 events were offered, 963,050 were accepted and durably stored, and 36,580 events (3,658 batches) were explicitly shed with an answer.

That run failed our throughput bar—and proved the exact point of gap-aware design. Because the SDK never blocks the host application (using a bounded queue and a circuit breaker backing off from 0.5 to 5 seconds) and reports every shed window explicitly, the host stayed responsive and operators could see the exact 36,580-event gap instead of trusting an incomplete trace.

How to evaluate AI observability tools (or design your own)

Whether you pick an open-source tool, a hosted vendor, or build a thin collector over PostgreSQL, check these seven questions before wiring it into production agents:

  1. Does the SDK fail open without blocking your app? If the collector goes down, your agent must keep running with a bounded queue and circuit breaker—never hanging user requests waiting on telemetry.
  2. Are dropped or refused events shown explicitly as gaps? Ask what happens when the collector returns 429 or 500—does the UI show a gap marker with counts and time bounds, or pretend nothing happened?
  3. Can one operation timeline span model calls, tools, and async jobs? LLM-only prompt loggers miss the half of the bug that happened inside your tool handler or background queue (see how to build an AI agent without a framework).
  4. Does it separate “estimated cost” from “reconciled provider billing”? Token estimates drift when retries, prompt caching (KV cache explained), or truncated streams happen.
  5. How does it handle partial/uncertain outcomes? If a worker dies mid-tool-call, can the timeline mark the step uncertain instead of guessing failed or succeeded?
  6. Is secret redaction tested on escaped and URL-encoded payloads? Don’t settle for a naive api_key= regex.
  7. Are audit and denial logs isolated from normal ingest traffic? Give security/audit writes their own database pool so a flood of normal traces or invalid tokens cannot block an access revocation.

Frequently asked questions

What is AI observability? AI observability is the practice of recording and inspecting the full execution path of AI-powered operations—model calls, token usage, latency, tool invocations, retries, errors, and missing telemetry—so engineers can debug wrong outputs, control cost, and verify what an agent actually did in production.

Is OpenTelemetry enough for AI agent observability? OpenTelemetry is a solid transport and span standard (especially with GenAI semantic conventions), and it pairs well with existing backend traces. You still need to add the AI-specific guarantees on top: strict payload byte caps, multi-shape secret redaction, explicit gap reporting when queues shed events, and clear separation between what a model claimed and what tools executed.

Should I log full prompts and tool outputs in production? Only with strict bounds, retention limits, and tested secret/PII redaction—and ideally configurable per route or tenant. Logging unbounded raw tool outputs bloats storage fast and turns your observability database into a high-value credential leak target.

Related reading