DEV Community

jaryn
jaryn

Posted on

Decide Which Model Request Fields Your Logs May Persist

A model request fails and someone logs the exception object. Turning off the line that logged the prompt on the successful path might not change what the exception reporter, SDK trace exporter or retry queue retains.

Start the review with one diagnostic question. For example: “Was the rise in latency concentrated in requests of a particular size?” That question can often be answered with a size bucket, a service-controlled model alias, an outcome category and a duration. It does not require the prompt. Write the fields and their allowed values down before serializing the request. An allowed field called error_message is still an unrestricted text channel if it accepts the provider’s raw response.

Trace one failure from call to storage

Destination What to inspect
Application logs Structured fields and exception formatting
Tracing SDK instrumentation, span attributes and exporter processors
Retry or dead-letter handling Stored payload, access, expiration and deletion
Error reporting Breadcrumbs, request attachments and stack-local capture

Generate the request ID inside the service or validate its format. Keep tool and model names within a controlled vocabulary if they are logged. Hashing a raw prompt creates a stable fingerprint: equal inputs can be correlated and common inputs can be guessed. Omit the fingerprint unless a defined diagnostic genuinely needs it and its retention has been reviewed. OpenTelemetry’s sensitive-data guidance describes this limitation for predictable inputs.

Use a synthetic marker rather than a real customer record. Put a different marker in the prompt, tool arguments and a simulated provider error. Run both the success and failure paths with test exporters attached. Verify that the structured event still answers the diagnostic question and that the forbidden markers do not appear at any configured destination. Include a deliberately misconfigured test sink to show that your check can actually detect a leak. A clean application log alone says little about the exporter that never passed through the logger.

This article was created with AI assistance.

Top comments (0)