Claude Agent SDK result messages expose usage, cost, session, and completion status; OpenTelemetry export connects agent activity to application traces and metrics. Cost is an outcome dimension, not merely a bill. Correlate it with task success, tool calls, latency, retries, cache behavior, model use, tenant, and deployment version—without exporting sensitive content by default.
You will collect per-run usage, enforce a budget, and design telemetry that answers operational questions while respecting data governance.
On every final result, normalize:
Check official docs for exact message fields. Failed runs may still consume tokens and cost, so record usage before classifying the outcome.
Configure max_turns and max_budget_usd on ClaudeAgentOptions, then add harness limits for wall time, tool calls, fan-out, output bytes, and retry count. Budget exhaustion is a classified non-success outcome—not an exception to hide and not permission to restart with a fresh budget.
Propagate an application correlation ID into agent telemetry using supported tags/environment configuration. Attribute work to pseudonymous user/tenant identifiers only when governance permits it.
Default to metadata rather than full prompts, file content, tool results, or secrets. Configure the SDK’s sensitive-data export controls, redact at the source, restrict collector access, encrypt transport/storage, and apply retention. Test redaction with seeded canary secrets.
Failure injection: Put a fake secret in a tool result and inspect logs, spans, errors, and exported events. The test fails if the canary appears anywhere outside the controlled fixture.
Define SLOs and alerts for SupportOps. Include burn-rate alerts, high-cost failure detection, stuck-session detection, and a runbook owner for each alert.