Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<PackageVersion Include="MySqlConnector.Logging.Microsoft.Extensions.Logging" Version="2.1.0" />
<PackageVersion Include="NATS.Net" Version="2.6.7" />
<PackageVersion Include="Npgsql.DependencyInjection" Version="9.0.3" />
<PackageVersion Include="OpenAI" Version="2.4.0" />
<PackageVersion Include="OpenAI" Version="2.5.0" />
<PackageVersion Include="Oracle.EntityFrameworkCore" Version="8.23.90" /> <!-- Can't update to 9.x versions as those lift up LTS versions when targeting net8 -->
<PackageVersion Include="Oracle.ManagedDataAccess.OpenTelemetry" Version="23.9.0" />
<PackageVersion Include="Polly.Core" Version="8.6.3" />
Expand Down
4 changes: 2 additions & 2 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
<MicrosoftDotNetXUnitV3ExtensionsVersion>11.0.0-beta.25469.3</MicrosoftDotNetXUnitV3ExtensionsVersion>
<MicrosoftDotNetBuildTasksArchivesVersion>11.0.0-beta.25469.3</MicrosoftDotNetBuildTasksArchivesVersion>
<!-- dotnet/extensions -->
<MicrosoftExtensionsAIVersion>9.9.0</MicrosoftExtensionsAIVersion>
<MicrosoftExtensionsAIPreviewVersion>9.9.0-preview.1.25458.4</MicrosoftExtensionsAIPreviewVersion>
<MicrosoftExtensionsAIVersion>9.9.1</MicrosoftExtensionsAIVersion>
<MicrosoftExtensionsAIPreviewVersion>9.9.1-preview.1.25474.6</MicrosoftExtensionsAIPreviewVersion>
<MicrosoftExtensionsHttpResilienceVersion>9.9.0</MicrosoftExtensionsHttpResilienceVersion>
<MicrosoftExtensionsDependencyInjectionAutoActivationVersion>9.9.0</MicrosoftExtensionsDependencyInjectionAutoActivationVersion>
<MicrosoftExtensionsDiagnosticsTestingVersion>9.9.0</MicrosoftExtensionsDiagnosticsTestingVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

builder.AddServiceDefaults();

builder.AddAzureChatCompletionsClient("chat", settings => settings.EnableSensitiveTelemetryData = true)
builder.AddAzureChatCompletionsClient("chat")
.AddChatClient()
.UseFunctionInvocation();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</PropertyGroup>

<ItemGroup>
<Compile Include="..\Common\AITelemetryHelpers.cs" Link="AITelemetryHelpers.cs" />
<Compile Include="..\Common\AzureComponent.cs" Link="AzureComponent.cs" />
<Compile Include="..\Common\ConfigurationSchemaAttributes.cs" Link="ConfigurationSchemaAttributes.cs" />
<Compile Include="..\Common\HealthChecksExtensions.cs" Link="HealthChecksExtensions.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,16 @@ public sealed class ChatCompletionsClientSettings : IConnectionStringSettings
/// <value>
/// <see langword="true"/> if potentially sensitive information should be included in telemetry;
/// <see langword="false"/> if telemetry shouldn't include raw inputs and outputs.
/// The default value is <see langword="false"/>.
/// The default value is <see langword="false"/>, unless the <c>OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT</c>
/// environment variable is set to "true" (case-insensitive).
/// </value>
/// <remarks>
/// 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 <c>OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT</c>
/// environment variable to "true". Explicitly setting this property will override the environment variable.
/// </remarks>
public bool EnableSensitiveTelemetryData { get; set; }
public bool EnableSensitiveTelemetryData { get; set; } = TelemetryHelpers.EnableSensitiveDataDefault;

/// <summary>
/// Parses a connection string and populates the settings properties.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
</PropertyGroup>

<ItemGroup>
<Compile Include="..\Common\AITelemetryHelpers.cs" Link="AITelemetryHelpers.cs" />
<Compile Include="..\Common\AzureComponent.cs" Link="AzureComponent.cs" />
<Compile Include="..\Common\ConfigurationSchemaAttributes.cs" Link="ConfigurationSchemaAttributes.cs" />
<Compile Include="..\Common\HealthChecksExtensions.cs" Link="HealthChecksExtensions.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,16 @@ public sealed class AzureOpenAISettings : IConnectionStringSettings
/// <value>
/// <see langword="true"/> if potentially sensitive information should be included in telemetry;
/// <see langword="false"/> if telemetry shouldn't include raw inputs and outputs.
/// The default value is <see langword="false"/>.
/// The default value is <see langword="false"/>, unless the <c>OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT</c>
/// environment variable is set to "true" (case-insensitive).
/// </value>
/// <remarks>
/// 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 <c>OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT</c>
/// environment variable to "true". Explicitly setting this property will override the environment variable.
/// </remarks>
public bool EnableSensitiveTelemetryData { get; set; }
public bool EnableSensitiveTelemetryData { get; set; } = TelemetryHelpers.EnableSensitiveDataDefault;

void IConnectionStringSettings.ParseConnectionString(string? connectionString)
{
Expand Down
13 changes: 13 additions & 0 deletions src/Components/Common/AITelemetryHelpers.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>Gets a value indicating whether the OpenTelemetry clients should enable their EnableSensitiveData property's by default.</summary>
/// <remarks>Defaults to false. May be overridden by setting the OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT environment variable to "true".</remarks>
public static bool EnableSensitiveDataDefault { get; } =
Environment.GetEnvironmentVariable("OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT") is string envVar &&
string.Equals(envVar, "true", StringComparison.OrdinalIgnoreCase);
}
Loading