Implement generative AI and agentic solutions 2.3 Optimize and operationalize generative AI systems
A Python agent app uses client-side tracing (GenAI tracing instrumentation, preview) with…
Study guide skill: Set up observability by implementing tracing, token analytics, safety signals, and latency breakdowns
Question B3-011
A Python agent app uses client-side tracing (GenAI tracing instrumentation, preview) with AIProjectInstrumentor, and spans with timings and token usage already appear in Application Insights. In the development environment only, developers also need to see user messages, tool call arguments, and model outputs in the traces. What should you do?
Select one answer.
Answer: C
Content recording is a separate switch: setting OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT to true before instrumenting captures message contents, tool call arguments, and model outputs. Because that data can be sensitive, Microsoft says to enable it only in development unless your compliance and privacy requirements allow it. AZURE_EXPERIMENTAL_ENABLE_GENAI_TRACING turns on tracing itself, which is already working, and Log Analytics Reader is the role people need to query telemetry, not a setting that captures content.
Deep dive
How it works
Client-side tracing with AIProjectInstrumentor has two separate switches:
- Tracing itself: in Python, set AZURE_EXPERIMENTAL_ENABLE_GENAI_TRACING to true before calling AIProjectInstrumentor().instrument(). If it isn't set, instrumentation isn't enabled and a warning is logged. Here spans with timings and token usage already arrive, so this switch is on.
- Content recording: set OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT to true before instrumenting. Content recording captures user messages, tool call arguments and model outputs.
Because that content might include sensitive user information, Microsoft is blunt: only enable content recording in development environments, and don't enable it in production unless your compliance and privacy requirements allow it. Setting the variable only in the dev environment's configuration meets the requirement.
Two details worth knowing: the variable controls recording only for the built-in traces (functions you decorate with @trace_function always trace their parameters and return values), and in C# an AppContext switch takes priority over the environment variable.
The other options, and when you'd use them
- Log Analytics Reader: That's the role people need on the connected Application Insights resource to query telemetry. It doesn't change what the app records.
- Content recording in production for everyone: It's exactly what the guidance warns against, unless compliance and privacy requirements allow it.
- AZURE_EXPERIMENTAL_ENABLE_GENAI_TRACING: It turns tracing on, and tracing is already working. It doesn't add message content.
Exam tip
Spans but no content = turn on content recording (OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT), in development only.
References
Last reviewed: