An AI feature often includes request validation, retrieval, one or more model calls, tools, and response rendering. Logging only the final HTTP status hides which step failed and what it cost. A trace should show the workflow without turning user prompts into permanent telemetry by default.
Instrument the stages
Record a trace ID, workflow name, model/provider identifier, latency by stage, retry count, token or usage totals where available, and normalized failure category. Distinguish provider timeout, rate limit, invalid response, tool failure, and user cancellation. Do not log API keys, hidden system prompts, or raw personal content unless an explicit policy and user expectation allow it.
Track cost alongside quality and latency. A cheaper response that fails the task is not necessarily an improvement. Use sampled, permission-safe evaluations and retain the model version and prompt/schema revision needed to reproduce a behavior. Redact or aggregate data before it enters dashboards.
Alert on product impact
Alert on sustained failure rates, queue age, and unexpected cost changes rather than a single provider error. Define a fallback path and make it visible in telemetry when used. If the interface returns partial output, record that state distinctly from success.
Test provider outages, tool timeouts, retries, malformed output, and cancellation. Observability should help answer: which step failed, who was affected, what fallback occurred, and whether recovery happened—without exposing more user data than the team needs.
Keep useful signals without retaining private prompts
A model-assisted summary can spend time in a queue, in an outbound provider call, and in the final response check. Record those spans separately and attach the operation, provider, outcome, and model identifier where you can make them stable and bounded. If the provider reports token counts, store the counts and their meaning without reconstructing the input from private logs.
OpenTelemetry publishes generative AI semantic conventions covering spans, metrics, and events. Check the stability status of the fields you adopt. Before estimating cost, look up the actual billing unit for input, output, caching or images, and keep the rate card effective date with the calculation. Tokens used, billable usage and invoice cost are different signals. OpenTelemetry GenAI conventions
Worked example
Use low-cardinality fields for grouping and publish numeric timings and counts only when your instrumentation captures them. This event shape represents a timeout category with the provider identifier and token counts unknown.
json{"operation":"article-summary","outcome":"provider_timeout","provider":null,"model":null,"inputTokens":null,"outputTokens":null}




Community
Discussion
Loading comments…