Skip to content

OpenTelemetry Traces vs. Audit Logs for AI Agents: What Each Can and Can't Prove

10 min reading

Capture the evidence behind decisions without treating verbose reasoning logs as proof of correct execution.

Page details

Blog 09 · Vikram Samal

Edition date: · 10 min read

20px

Edition dates place posts in a retrospective weekly reading sequence.

Last edited:

Sources · Technology essay

TL;DR
  • Traces describe execution paths; audit records preserve a declared accountability history.
  • Sampling and retention are explicit policies, not properties implied by a tool name.
  • Link minimal evidence and authorization records without logging private prompts by default.

The refund succeeded.
The trace was sampled out.
The approval question still needs an answer.

Hypothetical scenario. Act 3, the bad week. An auditor asks Priya who approved a Northwind refund and which policy revision the assistant consulted. Sam’s tracing dashboard has no trace for the run. The performance sampling policy was working as configured, but it was never designed to retain every approval decision.

A trace, a span and an audit event

An OpenTelemetry trace connects work performed during a request. A span represents an operation with timing, identifiers and attributes. Parent-child relationships describe nested work, while links can connect related operations outside a simple tree. This structure helps an engineer follow a request through model calls, retrieval and tool execution.

Sampling selects which trace data to retain or export. Head sampling decides early, while tail sampling considers information available after more of the trace is observed. Retention determines how long exported data remains available. Neither a fixed sampling percentage nor short retention is inherent to OpenTelemetry; both depend on the deployed collection and storage policies.

An audit event records an accountable action or decision under a declared completeness and retention contract. It needs an actor, resource, action, authorization basis and outcome, with evidence references appropriate to that decision. An audit store is not automatically truthful or tamper-proof. Its usefulness depends on trustworthy event production, access controls and protections against undetected alteration or loss.

Durable actionAudit eventsTrace referenceSampled spans
Action history remains available independently; a trace reference adds diagnostics when retained.

Ask what each record is expected to establish

A trace can show that a retrieval span preceded a model span and that a refund request waited on a provider. That is useful causal and timing evidence within the observed instrumentation. It does not necessarily establish who approved the refund, whether an approval was still valid or whether a logged success claim matches the provider’s final business state.

An audit event should identify the exact approval and action versions that were executed. If the amount or recipient changed after approval, record the new decision instead of preserving a misleading old approval reference. For Northwind, the authorization record binds the employee, order, approved amount and policy revision independently of whatever explanation the model generated.

OpenTelemetry’s trace documentation explains spans and their relationships. OWASP’s Logging Cheat Sheet distinguishes logging purposes and recommends recording enough event context while protecting sensitive data. These sources support separate record contracts; using one storage product for both does not remove the need to define those contracts explicitly.

Sampling makes completeness a calculation

Hypothetical worked example: Northwind runs 20,000 agent tasks per day and samples complete traces with an independent 5% probability. Expected retained traces are 20,000 × 0.05 = 1,000. Expected omitted traces are 20,000 − 1,000 = 19,000. A probabilistic sampler need not retain exactly those counts on a particular day.

If an auditor asks about an arbitrary completed task, the sample is not a complete task history. Raising the sampling probability improves coverage but still leaves omissions until the configured policy and delivery guarantees satisfy the audit requirement. Tail sampling can prioritize errors, yet a successful unauthorized refund is not guaranteed to look like a tracing error.

OpenTelemetry’s sampling guide describes sampling as a deliberate trade-off in observability collection. Northwind should preserve audit events for the required action population separately, then correlate them with any available traces. An absent sampled trace should mean missing diagnostic detail, not a missing payment approval record.

Describe the contracts before selecting storage

For traces, state the diagnostic purpose, sampling decision, expected coverage and retention. Sam can choose a retention window based on debugging needs and cost. For audit events, state which events must be recorded, when they become durable and how missing events are detected. Priya’s review process depends on those completeness rules rather than a dashboard’s visual richness.

The readers differ too. Engineers investigating latency need timing and dependency relationships. Authorized reviewers investigating a refund need identity, approval, policy and provider outcome. Some people can legitimately access one dataset without the other. Scope access by the information required for the task rather than granting every operator the full contents of every prompt.

A system can store audit and trace data in the same platform if it enforces distinct ingestion, retention and permission rules. Physical separation is one design option, not the definition of an audit log. Conversely, calling a table “audit_events” does not establish completeness when application workers can silently skip inserts after a local error.

Record identifiers that survive the model run

Give the logical task, business action and approval stable identities. Include the trace identifier as a correlation reference when one exists. Keep the action identity available even if the tracing exporter fails or the task continues after the original request ends. A customer’s refund is not confined to the lifetime of one trace.

The event should distinguish intent, attempt and confirmed outcome. Recording a requested refund as a completed refund makes the audit trail misleading even if its bytes cannot be altered afterward. Reconciliation can append a later confirmation tied to the same action. This preserves the original uncertainty rather than rewriting history to look more decisive than it was.

A policy revision identifier is often more useful than copying the whole policy into each event. Preserve access to the corresponding immutable evidence snapshot under an appropriate retention rule. If the source can be overwritten without a revision history, an identifier alone will not let a later reviewer reconstruct what the application actually consulted.

Token attributes measure usage, not permission

OpenTelemetry’s GenAI attribute registry includes gen_ai.usage.input_tokens and gen_ai.usage.output_tokens. These attributes identify token-usage categories. They help connect model work to a request, but they do not establish answer correctness, cost without billing rules, or authorization for a tool action. The registry marks these entries as moved to the separate GenAI conventions project. Check the instrumentation’s convention version and migration status when interpreting exported fields.

Content capture deserves an explicit policy. Full prompts can contain customer messages, retrieved confidential documents and credentials mistakenly supplied by another component. Defaulting to minimal metadata reduces that exposure. When protected content is genuinely needed for investigation, use restricted evidence storage, scoped retrieval and a defined deletion or retention process.

Token totals should also be reconciled with provider billing categories before they are presented as dollars. Cached input and other categories can have different rates. A sampled set of token attributes cannot establish the complete day’s bill unless the estimation method and its uncertainty are declared. Operational diagnostics and financial accounting need compatible but separate denominators.

In the wild: tracing guidance and security logging meet

OpenTelemetry documents trace sampling and span relationships; OWASP documents logging design, protection and sensitive-data exclusions. These are real public engineering references. They do not describe a Northwind deployment or prove that a particular storage configuration meets an auditor’s requirements. The architectural conclusion is to choose evidence according to the question that must be answered later.

For external side effects, Stripe’s idempotency documentation provides a concrete provider-level operation contract. Northwind’s audit event should reference the action and confirmed provider result, not just the HTTP attempt’s local success flag. An unresolved provider call remains unresolved in the accountability record until a later observation establishes the outcome.

Losing the log is itself a state to handle

Decide what happens when the audit writer is unavailable. A high-impact action can require a durable intent record before dispatch, with later outcome events appended after reconciliation. If the policy allows delayed delivery, persist an outbox or equivalent recovery record and monitor its backlog. Treating logging failure as an ignored exception leaves no basis for claiming complete history.

Check the event sequence against an independent action population, such as recorded payment requests and provider confirmations. Sequence gaps, undelivered records and access-policy changes need their own checks. Tamper evidence should make unauthorized alteration detectable under a declared threat model; it should not be described as proof that the original event producer was honest.

Common misconceptions include assuming that an unsampled success did not happen, that full prompt capture automatically improves accountability, and that a trace identifier is an approval. Each substitutes a convenient observation for the required decision evidence. Northwind keeps the diagnostic and accountability questions connected through identifiers while preserving their distinct requirements.

Keep the evidence proportionate to the action

Read-only drafting needs less accountability machinery than a refund or disclosure of private policy. Choose the audit population from the business effect and its review requirements. Sampling ordinary performance traces can remain appropriate alongside complete durable action records. That avoids forcing every diagnostic detail into the longest-lived evidence store.

Limits: instrumentation gaps, dishonest producers, failed delivery and incomplete source history can undermine either dataset. A retained record is evidence to evaluate, not automatic proof of truth. Northwind’s decision is to retain approved action history independently of diagnostic sampling, protect the referenced evidence and make missing audit delivery visible before it disappears into routine operations.

Check yourself: otel decisions

A 5% sampler sees 20,000 runs. What retained count should be expected?

The expected count is 1,000, with 19,000 omitted. Independent probabilistic sampling does not promise exactly those counts for every batch.

A trace records a successful HTTP span. Does that prove the refund was approved?

No. Link the actual authorization and action versions, and distinguish the provider’s confirmed outcome from a local request observation.

An audit event cannot be changed after insertion. Is its content necessarily true?

No. Storage integrity does not establish the producer’s correctness or completeness. Validate the event source and reconcile the required action population.

Next read: Connect tool retries to action records.

Source: Traces — Inspect Primary Source ↗
VS
Vikram Samal

Notes on generative AI and system design.