-
Notifications
You must be signed in to change notification settings - Fork 839
Add OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT environment variable support to MEAI telemetry #6790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@stephentoub 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
…ent variable support Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
@copilot Move |
Co-authored-by: JamesNK <303201+JamesNK@users.noreply.github.com>
Done! I've moved the Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Product changes looks ok to me
The EnableSensitiveData_ExplicitSettingOverridesEnvironmentVariable test is setting static data so it might cause problems. Move it to another process? Delete the test? MEAI team can decide here..
There was a problem hiding this 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 adds environment variable support for controlling sensitive data capture in OpenTelemetry components and refactors the telemetry helpers for better code organization. The main goal is to enable the OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT
environment variable to control the default value of EnableSensitiveData
across telemetry clients.
Key changes:
- Added
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT
environment variable support to control sensitive data capture defaults - Renamed
LoggingHelpers
toTelemetryHelpers
and moved shared functionality to reduce code duplication - Updated all references throughout the codebase to use the new
TelemetryHelpers
class
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
TelemetryHelpers.cs | Renamed from LoggingHelpers.cs, added environment variable support for EnableSensitiveDataDefault |
OpenTelemetryConsts.cs | Added constant for the GenAI capture message content environment variable |
OpenTelemetryChatClient.cs | Updated to use TelemetryHelpers.EnableSensitiveDataDefault and improved documentation |
OpenTelemetryEmbeddingGenerator.cs | Updated to use TelemetryHelpers.EnableSensitiveDataDefault and improved documentation |
LoggingChatClient.cs | Updated reference from LoggingHelpers to TelemetryHelpers |
FunctionInvokingChatClient.cs | Updated references from LoggingHelpers to TelemetryHelpers |
LoggingImageGenerator.cs | Updated reference from LoggingHelpers to TelemetryHelpers |
LoggingSpeechToTextClient.cs | Updated reference from LoggingHelpers to TelemetryHelpers |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Changes Made
Environment Variable Support (Previously Complete)
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT
constant toOpenTelemetryConsts
OpenTelemetryChatClient
andOpenTelemetryEmbeddingGenerator
now check this environment variable during constructionEnableSensitiveData
defaults totrue
EnableSensitiveData
defaults tofalse
(preserving existing behavior)Refactoring (New Changes)
ShouldEnableSensitiveDataByDefault
method from both OpenTelemetry classes to sharedTelemetryHelpers
classLoggingHelpers
toTelemetryHelpers
to better reflect its usage for telemetry purposesLoggingHelpers
throughout the codebase to useTelemetryHelpers
Files Modified
src/Libraries/Microsoft.Extensions.AI/TelemetryHelpers.cs
(renamed from LoggingHelpers.cs)src/Libraries/Microsoft.Extensions.AI/ChatCompletion/OpenTelemetryChatClient.cs
src/Libraries/Microsoft.Extensions.AI/Embeddings/OpenTelemetryEmbeddingGenerator.cs
src/Libraries/Microsoft.Extensions.AI/ChatCompletion/LoggingChatClient.cs
src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs
src/Libraries/Microsoft.Extensions.AI/Image/LoggingImageGenerator.cs
src/Libraries/Microsoft.Extensions.AI/SpeechToText/LoggingSpeechToTextClient.cs
The refactoring eliminates code duplication while maintaining all existing functionality and test compatibility.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.
Microsoft Reviewers: Open in CodeFlow