Skip to content

.NET: Use OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT to control sensitive data capture in telemetry #5873

@singankit

Description

@singankit

Summary

The agent framework should respect the OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT environment variable to control whether sensitive data (raw inputs/outputs) is included in telemetry, consistent with the approach used in Microsoft.Extensions.AI.OpenTelemetryChatClient.

Reference

See: https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.ai.opentelemetrychatclient.enablesensitivedata?view=net-10.0-pp

Desired Behavior

  • By default, telemetry should include metadata (e.g., token counts) but not raw inputs and outputs (message content, function call arguments, function call results).
  • If the environment variable OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT is set to "true" (case-insensitive), sensitive data should be captured in telemetry.
  • An explicit programmatic override (e.g., a property or configuration option) should take precedence over the environment variable.

Why

This aligns with the OpenTelemetry GenAI semantic conventions and provides a standardized, user-controlled mechanism for opting into sensitive data capture — important for debugging while maintaining privacy by default.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions