Skip to content

Instrument an agent loop without capturing content

Select telemetry that links agent decisions and outcomes while meeting content-capture constraints.

Scenario

An internal purchasing assistant takes 18 seconds on a small fraction of requests. The team can see API timing but cannot tell which search or tool call consumed the time. The team may retain operational metadata for seven days. Request bodies and raw tool results are excluded.

Explanation

Use a trace for the request and child spans for model calls, tool calls and retrieval stages. Retain version, duration, status, stop reason and approved correlation IDs. Collect usage counters by model and route, including input, output and cache reads and writes. Join those counters to cost data under the same version and tenant dimensions.

Track why the application took a route with fields it can verify, such as the policy rule, source ID, version, tool outcome or evaluator result. Keep high-cardinality request IDs in traces and structured logs. Use bounded dimensions such as workflow, route and outcome for aggregate metrics.

Align content capture at the SDK, instrumentation, collector and storage layers. Provider retention settings, such as zero data retention, govern provider handling. Your exporters and logs have their own data paths and retention. Check an actual exported span, including failure events, to verify that redaction and retention rules hold.

Worked example

The purchasing team uses a parent request span with two search spans and a synthesis span. It records a corpus revision and cited document IDs approved for telemetry. The slow cohort shows one search retry and low cache reads after a prompt change. The team can inspect both facts without retaining queries or bids.