Gate sensitive data collection in AgentFrameworkInstrumentor behind environment variable#121
Gate sensitive data collection in AgentFrameworkInstrumentor behind environment variable#121
Conversation
Agent-Logs-Url: https://github.com/microsoft/opentelemetry-distro-python/sessions/baa487e4-f808-401a-bf89-e8680bf283a2 Co-authored-by: singankit <30610298+singankit@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR changes the Agent Framework instrumentor so the distro explicitly opts into sensitive span attributes from the Agent Framework SDK. In this codebase, that affects the built-in Agent Framework auto-instrumentation path used when A365 instrumentation is enabled.
Changes:
- Updated
AgentFrameworkInstrumentorto callenable_instrumentation(enable_sensitive_data=True). - Revised the instrumentor docstring to describe the new call signature.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| from agent_framework.observability import enable_instrumentation | ||
|
|
||
| enable_instrumentation() | ||
| enable_instrumentation(enable_sensitive_data=True) |
| from agent_framework.observability import enable_instrumentation | ||
|
|
||
| enable_instrumentation() | ||
| enable_instrumentation(enable_sensitive_data=True) |
There was a problem hiding this comment.
Valid comment. Please add a test to validate the new behavior.
There was a problem hiding this comment.
Added tests in commit 07f3ac1:
test_instrument_calls_enable_instrumentation_when_availablenow assertsenable_instrumentation(enable_sensitive_data=False)when the env var is unsettest_instrument_enables_sensitive_data_when_env_var_setassertsenable_sensitive_data=TruewhenAZURE_TRACING_GEN_AI_CONTENT_RECORDING_ENABLED=truetest_instrument_disables_sensitive_data_when_env_var_falseassertsenable_sensitive_data=Falsewhen the env var is explicitlyfalse
| from agent_framework.observability import enable_instrumentation | ||
|
|
||
| enable_instrumentation() | ||
| enable_instrumentation(enable_sensitive_data=True) |
There was a problem hiding this comment.
Instead of always passing in the variable to be true, we could probably read the value from the env variable, the way it is in agent framework. If the variable is not set the default value is False.
There was a problem hiding this comment.
Without enabling_sensitive_data traces are not really helpful so would like it to be enabled by default
There was a problem hiding this comment.
Done in commit 07f3ac1. enable_sensitive_data is now derived from the AZURE_TRACING_GEN_AI_CONTENT_RECORDING_ENABLED environment variable (the same one used by the Agent Framework SDK), defaulting to False when unset. Truthy values are true, 1, yes, on.
…e_sensitive_data; add tests Agent-Logs-Url: https://github.com/microsoft/opentelemetry-distro-python/sessions/1bb4ef7c-4849-4345-8180-0855b15a4d2b Co-authored-by: singankit <30610298+singankit@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/opentelemetry-distro-python/sessions/1bb4ef7c-4849-4345-8180-0855b15a4d2b Co-authored-by: singankit <30610298+singankit@users.noreply.github.com>
There was a problem hiding this comment.
Questions:
- What sensitive data is gated?
- Does this apply to Distro too? Why or why not?
- Is this coordinated with what Priyanka/Pipeline is doing? Two layer protection?
- How do customers extend / add their own rules?
- Is there a way this could be done across all instrumentation libraries to scale better?
AgentFrameworkInstrumentorwas callingenable_instrumentation()without forwarding the user's sensitive-data preference, so the Agent Framework SDK would default to suppressing sensitive span attributes.Changes
_trace_instrumentor.py: Read theAZURE_TRACING_GEN_AI_CONTENT_RECORDING_ENABLEDenvironment variable (the same variable used by the Agent Framework SDK) and pass its parsed boolean value asenable_sensitive_datatoenable_instrumentation(). Defaults toFalsewhen the variable is unset.tests/agent_framework/test_trace_instrumentor.py: Updated existing test to assertenable_sensitive_data=Falseis passed when the env var is unset. Added two new tests:test_instrument_enables_sensitive_data_when_env_var_set: assertsenable_sensitive_data=TruewhenAZURE_TRACING_GEN_AI_CONTENT_RECORDING_ENABLED=truetest_instrument_disables_sensitive_data_when_env_var_false: assertsenable_sensitive_data=Falsewhen the env var is explicitlyfalse