Skip to content

AgentFrameworkInstrumentor should support enable_sensitive_data via instrumentation_options #124

@benke520

Description

@benke520

Summary

The AgentFrameworkInstrumentor calls enable_instrumentation() with no arguments, which means enable_sensitive_data defaults to False. There is no way to pass enable_sensitive_data=True through the distro's instrumentation_options API.

Current Behavior

# In AgentFrameworkInstrumentor._instrument():
from agent_framework.observability import enable_instrumentation
enable_instrumentation()  # No kwargs forwarded

The only ways to enable sensitive data capture are:

  1. Set ENABLE_SENSITIVE_DATA=true env var before use_microsoft_opentelemetry() is called (ordering-dependent, undocumented)
  2. Call enable_instrumentation(enable_sensitive_data=True) separately after setup (bypasses the distro API)

Expected Behavior

instrumentation_options should support forwarding enable_sensitive_data to enable_instrumentation():

use_microsoft_opentelemetry(
    instrumentation_options={
        "agent_framework": {"enabled": True, "enable_sensitive_data": True}
    },
)

This would keep the default as False (secure by default) while providing a discoverable, documented opt-in path through the existing API surface.

Suggested Fix

In AgentFrameworkInstrumentor._instrument(), read the option from kwargs and forward it:

def _instrument(self, **kwargs: Any) -> None:
    try:
        from agent_framework.observability import enable_instrumentation

        options = kwargs.get("instrumentation_options", {}).get("agent_framework", {})
        enable_sensitive_data = options.get("enable_sensitive_data", False)
        enable_instrumentation(enable_sensitive_data=enable_sensitive_data)
        self._af_instrumentation_enabled = True
    except ImportError as exc:
        ...

Note: The distro's _setup_instrumentations currently calls instrumentor().instrument(skip_dep_check=True) without forwarding instrumentation_options, so the plumbing to pass options through would also need updating in _distro.py.

Rationale

  • The distro is meant to be the single-entry-point setup API. Abstracting enabled but not enable_sensitive_data is inconsistent.
  • The env var workaround has a subtle ordering dependency that's easy to get wrong.
  • Default remains secure (False); this just adds discoverability.

Environment

  • microsoft-opentelemetry 1.0.0
  • agent-framework 1.2.2
  • Python 3.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions