Skip to content

Gate sensitive data collection in AgentFrameworkInstrumentor behind environment variable#121

Open
Copilot wants to merge 3 commits intomainfrom
copilot/update-enable-instrumentation-flag
Open

Gate sensitive data collection in AgentFrameworkInstrumentor behind environment variable#121
Copilot wants to merge 3 commits intomainfrom
copilot/update-enable-instrumentation-flag

Conversation

Copy link
Copy Markdown

Copilot AI commented May 5, 2026

AgentFrameworkInstrumentor was calling enable_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 the AZURE_TRACING_GEN_AI_CONTENT_RECORDING_ENABLED environment variable (the same variable used by the Agent Framework SDK) and pass its parsed boolean value as enable_sensitive_data to enable_instrumentation(). Defaults to False when the variable is unset.
  • Updated docstring to document the environment variable and its effect on sensitive data (prompts, tool arguments, results) in emitted spans.
# Before
enable_instrumentation()

# After
enable_sensitive_data = os.environ.get("AZURE_TRACING_GEN_AI_CONTENT_RECORDING_ENABLED", "").strip().lower() in ("true", "1", "yes", "on")
enable_instrumentation(enable_sensitive_data=enable_sensitive_data)
  • tests/agent_framework/test_trace_instrumentor.py: Updated existing test to assert enable_sensitive_data=False is passed when the env var is unset. Added two new tests:
    • test_instrument_enables_sensitive_data_when_env_var_set: asserts enable_sensitive_data=True when AZURE_TRACING_GEN_AI_CONTENT_RECORDING_ENABLED=true
    • test_instrument_disables_sensitive_data_when_env_var_false: asserts enable_sensitive_data=False when the env var is explicitly false

@singankit singankit marked this pull request as ready for review May 5, 2026 21:05
Copilot AI review requested due to automatic review settings May 5, 2026 21:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 AgentFrameworkInstrumentor to call enable_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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid comment. Please add a test to validate the new behavior.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added tests in commit 07f3ac1:

  • test_instrument_calls_enable_instrumentation_when_available now asserts enable_instrumentation(enable_sensitive_data=False) when the env var is unset
  • test_instrument_enables_sensitive_data_when_env_var_set asserts enable_sensitive_data=True when AZURE_TRACING_GEN_AI_CONTENT_RECORDING_ENABLED=true
  • test_instrument_disables_sensitive_data_when_env_var_false asserts enable_sensitive_data=False when the env var is explicitly false

from agent_framework.observability import enable_instrumentation

enable_instrumentation()
enable_instrumentation(enable_sensitive_data=True)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without enabling_sensitive_data traces are not really helpful so would like it to be enabled by default

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot AI and others added 2 commits May 5, 2026 21:27
…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>
Copilot AI changed the title Enable sensitive data collection in AgentFrameworkInstrumentor Gate sensitive data collection in AgentFrameworkInstrumentor behind environment variable May 5, 2026
Copilot AI requested a review from singankit May 5, 2026 21:29
Copy link
Copy Markdown
Member

@mattmccleary mattmccleary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants