From 03bf05ecc32bc2d8dfdaf8b128d28d318fed0e20 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 26 Sep 2025 04:30:29 +0000 Subject: [PATCH 1/4] Initial plan From af0b4d2e8afc24dbdf887f4b7acfce5f6ccc7371 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 26 Sep 2025 04:46:33 +0000 Subject: [PATCH 2/4] Update Microsoft.Extensions.AI packages to 9.9.1 and OpenAI to 2.5.0 Co-authored-by: JamesNK <303201+JamesNK@users.noreply.github.com> --- Directory.Packages.props | 2 +- eng/Versions.props | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 620d2d57dad..76c6d5f4a16 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -102,7 +102,7 @@ - + diff --git a/eng/Versions.props b/eng/Versions.props index b4305da9776..3eeed805756 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -41,8 +41,8 @@ 11.0.0-beta.25457.1 11.0.0-beta.25457.1 - 9.9.0 - 9.9.0-preview.1.25458.4 + 9.9.1 + 9.9.1-preview.1.25474.6 9.9.0 9.9.0 9.9.0 From 527283c0a8b8bdd67a6122171ee4093faac693b6 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Fri, 26 Sep 2025 13:33:19 +0800 Subject: [PATCH 3/4] Update AI integrations to use env var for defaults --- .../GitHubModelsEndToEnd.WebStory/Program.cs | 2 +- .../Aspire.Azure.AI.Inference.csproj | 1 + .../ChatCompletionsClientSettings.cs | 7 +++++-- .../Aspire.Azure.AI.OpenAI.csproj | 1 + .../Aspire.Azure.AI.OpenAI/AzureOpenAISettings.cs | 7 +++++-- src/Components/Common/AITelemetryHelpers.cs | 13 +++++++++++++ 6 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 src/Components/Common/AITelemetryHelpers.cs diff --git a/playground/GitHubModelsEndToEnd/GitHubModelsEndToEnd.WebStory/Program.cs b/playground/GitHubModelsEndToEnd/GitHubModelsEndToEnd.WebStory/Program.cs index 8d472616f68..1e019a25635 100644 --- a/playground/GitHubModelsEndToEnd/GitHubModelsEndToEnd.WebStory/Program.cs +++ b/playground/GitHubModelsEndToEnd/GitHubModelsEndToEnd.WebStory/Program.cs @@ -8,7 +8,7 @@ builder.AddServiceDefaults(); -builder.AddAzureChatCompletionsClient("chat", settings => settings.EnableSensitiveTelemetryData = true) +builder.AddAzureChatCompletionsClient("chat") .AddChatClient() .UseFunctionInvocation(); diff --git a/src/Components/Aspire.Azure.AI.Inference/Aspire.Azure.AI.Inference.csproj b/src/Components/Aspire.Azure.AI.Inference/Aspire.Azure.AI.Inference.csproj index 298f6deefd2..1845c9398b7 100644 --- a/src/Components/Aspire.Azure.AI.Inference/Aspire.Azure.AI.Inference.csproj +++ b/src/Components/Aspire.Azure.AI.Inference/Aspire.Azure.AI.Inference.csproj @@ -13,6 +13,7 @@ + diff --git a/src/Components/Aspire.Azure.AI.Inference/ChatCompletionsClientSettings.cs b/src/Components/Aspire.Azure.AI.Inference/ChatCompletionsClientSettings.cs index 56794af9b24..e9f0a355c21 100644 --- a/src/Components/Aspire.Azure.AI.Inference/ChatCompletionsClientSettings.cs +++ b/src/Components/Aspire.Azure.AI.Inference/ChatCompletionsClientSettings.cs @@ -68,13 +68,16 @@ public sealed class ChatCompletionsClientSettings : IConnectionStringSettings /// /// if potentially sensitive information should be included in telemetry; /// if telemetry shouldn't include raw inputs and outputs. - /// The default value is . + /// The default value is , unless the OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT + /// environment variable is set to "true" (case-insensitive). /// /// /// By default, telemetry includes metadata, such as token counts, but not raw inputs /// and outputs, such as message content, function call arguments, and function call results. + /// The default value can be overridden by setting the OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT + /// environment variable to "true". Explicitly setting this property will override the environment variable. /// - public bool EnableSensitiveTelemetryData { get; set; } + public bool EnableSensitiveTelemetryData { get; set; } = TelemetryHelpers.EnableSensitiveDataDefault; /// /// Parses a connection string and populates the settings properties. diff --git a/src/Components/Aspire.Azure.AI.OpenAI/Aspire.Azure.AI.OpenAI.csproj b/src/Components/Aspire.Azure.AI.OpenAI/Aspire.Azure.AI.OpenAI.csproj index 979b678061e..914f194dc47 100644 --- a/src/Components/Aspire.Azure.AI.OpenAI/Aspire.Azure.AI.OpenAI.csproj +++ b/src/Components/Aspire.Azure.AI.OpenAI/Aspire.Azure.AI.OpenAI.csproj @@ -14,6 +14,7 @@ + diff --git a/src/Components/Aspire.Azure.AI.OpenAI/AzureOpenAISettings.cs b/src/Components/Aspire.Azure.AI.OpenAI/AzureOpenAISettings.cs index 7139088c1b8..9567af410d1 100644 --- a/src/Components/Aspire.Azure.AI.OpenAI/AzureOpenAISettings.cs +++ b/src/Components/Aspire.Azure.AI.OpenAI/AzureOpenAISettings.cs @@ -67,13 +67,16 @@ public sealed class AzureOpenAISettings : IConnectionStringSettings /// /// if potentially sensitive information should be included in telemetry; /// if telemetry shouldn't include raw inputs and outputs. - /// The default value is . + /// The default value is , unless the OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT + /// environment variable is set to "true" (case-insensitive). /// /// /// By default, telemetry includes metadata, such as token counts, but not raw inputs /// and outputs, such as message content, function call arguments, and function call results. + /// The default value can be overridden by setting the OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT + /// environment variable to "true". Explicitly setting this property will override the environment variable. /// - public bool EnableSensitiveTelemetryData { get; set; } + public bool EnableSensitiveTelemetryData { get; set; } = TelemetryHelpers.EnableSensitiveDataDefault; void IConnectionStringSettings.ParseConnectionString(string? connectionString) { diff --git a/src/Components/Common/AITelemetryHelpers.cs b/src/Components/Common/AITelemetryHelpers.cs new file mode 100644 index 00000000000..fda99999d27 --- /dev/null +++ b/src/Components/Common/AITelemetryHelpers.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Aspire; + +internal static class TelemetryHelpers +{ + /// Gets a value indicating whether the OpenTelemetry clients should enable their EnableSensitiveData property's by default. + /// Defaults to false. May be overridden by setting the OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT environment variable to "true". + public static bool EnableSensitiveDataDefault { get; } = + Environment.GetEnvironmentVariable("OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT") is string envVar && + string.Equals(envVar, "true", StringComparison.OrdinalIgnoreCase); +} From db81f4684ca70ad5cac96bc183d47ce2c61fa6b1 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Fri, 26 Sep 2025 13:58:35 +0800 Subject: [PATCH 4/4] Apply suggestion from @JamesNK --- src/Components/Common/AITelemetryHelpers.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Components/Common/AITelemetryHelpers.cs b/src/Components/Common/AITelemetryHelpers.cs index fda99999d27..acc378786dc 100644 --- a/src/Components/Common/AITelemetryHelpers.cs +++ b/src/Components/Common/AITelemetryHelpers.cs @@ -6,7 +6,10 @@ namespace Aspire; internal static class TelemetryHelpers { /// Gets a value indicating whether the OpenTelemetry clients should enable their EnableSensitiveData property's by default. - /// Defaults to false. May be overridden by setting the OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT environment variable to "true". + /// + /// Defaults to false. May be overridden by setting the OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT environment variable to "true". + /// Mirrors Microsoft.Extensions.AI default: https://github.com/dotnet/extensions/blob/c4e57fb1e6b8403a527ea3cd737f1146dcbc1f31/src/Libraries/Microsoft.Extensions.AI/TelemetryHelpers.cs#L14 + /// public static bool EnableSensitiveDataDefault { get; } = Environment.GetEnvironmentVariable("OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT") is string envVar && string.Equals(envVar, "true", StringComparison.OrdinalIgnoreCase);