From 0124828f6c78acf5971727910d743e146beb41e7 Mon Sep 17 00:00:00 2001 From: Zhiyuan Liang Date: Thu, 15 May 2025 11:27:57 +0800 Subject: [PATCH 1/5] add tracing support for Azure App Configuration component --- Directory.Packages.props | 4 ++-- .../AspireAppConfigurationExtensions.cs | 7 +++++++ .../AzureAppConfigurationSettings.cs | 8 ++++++++ .../ConfigurationSchema.json | 5 +++++ .../ConfigurationTests.cs | 5 +++-- .../ConformanceTests.cs | 20 +++++++++---------- 6 files changed, 35 insertions(+), 14 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index b2ff25ad569..5a02e530588 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -26,8 +26,8 @@ - - + + diff --git a/src/Components/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration/AspireAppConfigurationExtensions.cs b/src/Components/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration/AspireAppConfigurationExtensions.cs index 803d90e466a..da292eaba69 100644 --- a/src/Components/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration/AspireAppConfigurationExtensions.cs +++ b/src/Components/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration/AspireAppConfigurationExtensions.cs @@ -61,5 +61,12 @@ public static void AddAzureAppConfiguration( settings.Optional); builder.Services.AddAzureAppConfiguration(); // register IConfigurationRefresherProvider service + + if (!settings.DisableTracing) + { + builder.Services.AddOpenTelemetry() + .WithTracing(traceBuilder => + traceBuilder.AddSource(["Microsoft.Extensions.Configuration.AzureAppConfiguration"])); + } } } diff --git a/src/Components/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationSettings.cs b/src/Components/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationSettings.cs index 446639687a9..756398814a7 100644 --- a/src/Components/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationSettings.cs +++ b/src/Components/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationSettings.cs @@ -28,6 +28,14 @@ public sealed class AzureAppConfigurationSettings : IConnectionStringSettings /// public bool Optional { get; set; } + /// + /// Gets or sets a boolean value that indicates whether the OpenTelemetry tracing is disabled or not. + /// + /// + /// The default value is . + /// + public bool DisableTracing { get; set; } + void IConnectionStringSettings.ParseConnectionString(string? connectionString) { if (!string.IsNullOrEmpty(connectionString) && diff --git a/src/Components/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration/ConfigurationSchema.json b/src/Components/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration/ConfigurationSchema.json index 248a28ed985..956d13a7648 100644 --- a/src/Components/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration/ConfigurationSchema.json +++ b/src/Components/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration/ConfigurationSchema.json @@ -25,6 +25,11 @@ "AzureAppConfiguration": { "type": "object", "properties": { + "DisableTracing": { + "type": "boolean", + "description": "Gets or sets a boolean value that indicates whether the OpenTelemetry tracing is disabled or not.", + "default": false + }, "Endpoint": { "type": "string", "format": "uri", diff --git a/tests/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration.Tests/ConfigurationTests.cs b/tests/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration.Tests/ConfigurationTests.cs index 49ee121899f..fbbae412a0b 100644 --- a/tests/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration.Tests/ConfigurationTests.cs +++ b/tests/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration.Tests/ConfigurationTests.cs @@ -11,6 +11,7 @@ public class ConfigurationTests public void EndpointUriIsNullByDefault() => Assert.Null(new AzureAppConfigurationSettings().Endpoint); - // WIP: https://github.com/Azure/AppConfiguration-DotnetProvider/pull/645 - // Tracing will be supported in the next 8.2.0 release + [Fact] + public void TracingIsEnabledByDefault() + => Assert.False(new AzureAppConfigurationSettings().DisableTracing); } diff --git a/tests/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration.Tests/ConformanceTests.cs b/tests/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration.Tests/ConformanceTests.cs index dffa9c1c517..033daffeb06 100644 --- a/tests/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration.Tests/ConformanceTests.cs +++ b/tests/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration.Tests/ConformanceTests.cs @@ -33,7 +33,8 @@ public class ConformanceTests : ConformanceTests new[] { ("""{"Aspire": { "Microsoft": { "Extensions": { "Configuration": { "AzureAppConfiguration": { "Endpoint": "YOUR_URI"}}}}}}""", "Value does not match format \"uri\""), - ("""{"Aspire": { "Microsoft": { "Extensions": { "Configuration": { "AzureAppConfiguration": { "Endpoint": "http://YOUR_URI", "Optional": "true"}}}}}}""", "Value is \"string\" but should be \"boolean\"") + ("""{"Aspire": { "Microsoft": { "Extensions": { "Configuration": { "AzureAppConfiguration": { "Endpoint": "http://YOUR_URI", "Optional": "true"}}}}}}""", "Value is \"string\" but should be \"boolean\""), + ("""{"Aspire": { "Microsoft": { "Extensions": { "Configuration": { "AzureAppConfiguration": { "Endpoint": "http://YOUR_URI", "DisableTracing": "true"}}}}}}""", "Value is \"string\" but should be \"boolean\""), }; protected override void SetHealthCheck(AzureAppConfigurationSettings options, bool enabled) @@ -89,19 +91,17 @@ protected override void SetMetrics(AzureAppConfigurationSettings options, bool e => throw new NotImplementedException(); protected override void SetTracing(AzureAppConfigurationSettings options, bool enabled) - // WIP: https://github.com/Azure/AppConfiguration-DotnetProvider/pull/645 - // Will be supported in the next 8.2.0 release - => throw new NotImplementedException(); + => options.DisableTracing = !enabled; protected override void TriggerActivity(IConfigurationRefresherProvider service) - // WIP: https://github.com/Azure/AppConfiguration-DotnetProvider/pull/645 - // Will be supported in the next 8.2.0 release - => throw new NotImplementedException(); + { + Thread.Sleep(1000); + service.Refreshers.First().RefreshAsync().ConfigureAwait(false).GetAwaiter().GetResult(); + } [Fact] public void TracingEnablesTheRightActivitySource() - // WIP: Waiting for App Configuration Provider 8.2.0 release - => RemoteExecutor.Invoke(() => /*ActivitySourceTest(key: null)*/ null).Dispose(); + => RemoteExecutor.Invoke(() => ActivitySourceTest(key: null)).Dispose(); internal sealed class EmptyTokenCredential : TokenCredential { From 47d06cae5d069cd55659bf7293c5f9647a5f8275 Mon Sep 17 00:00:00 2001 From: Zhiyuan Liang Date: Thu, 15 May 2025 11:33:54 +0800 Subject: [PATCH 2/5] avoid using Thread.Sleep --- .../ConformanceTests.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration.Tests/ConformanceTests.cs b/tests/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration.Tests/ConformanceTests.cs index 033daffeb06..65ba558867a 100644 --- a/tests/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration.Tests/ConformanceTests.cs +++ b/tests/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration.Tests/ConformanceTests.cs @@ -95,7 +95,8 @@ protected override void SetTracing(AzureAppConfigurationSettings options, bool e protected override void TriggerActivity(IConfigurationRefresherProvider service) { - Thread.Sleep(1000); + // wait for 1 seconds to ensure the refresh interval is exceeded + Task.Delay(1000).ConfigureAwait(false).GetAwaiter().GetResult(); service.Refreshers.First().RefreshAsync().ConfigureAwait(false).GetAwaiter().GetResult(); } From 1d61a74e3f6d35cefbab5dba4aff4a4f03f34fbf Mon Sep 17 00:00:00 2001 From: Zhiyuan Liang Date: Thu, 15 May 2025 13:50:50 +0800 Subject: [PATCH 3/5] update progress --- src/Components/Aspire_Components_Progress.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Components/Aspire_Components_Progress.md b/src/Components/Aspire_Components_Progress.md index 4c742aac166..cddf73993bd 100644 --- a/src/Components/Aspire_Components_Progress.md +++ b/src/Components/Aspire_Components_Progress.md @@ -10,9 +10,9 @@ These integrations should follow the [.NET Aspire Integration Requirements](#net | Microsoft.Data.SqlClient | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ✅ | | Microsoft.EntityFramework.Cosmos | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | | Microsoft.EntityFrameworkCore.SqlServer | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | -| Microsoft.Extensions.Configuration.AzureAppConfiguration | ✅ | ✅ | ✅ | ✅ | ✅ | | ❌ | | +| Microsoft.Extensions.Configuration.AzureAppConfiguration | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | | | MongoDB.Driver | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | -| Azure.AI.Inference | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | +| Azure.AI.Inference | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | | Azure.AI.OpenAI | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | | Azure.Data.Tables | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | | Azure.Messaging.EventHubs | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | | From 2ddd37f5a36f956fd1631abad5f8683ef00116f9 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Thu, 15 May 2025 09:41:57 -0500 Subject: [PATCH 4/5] Remove unnecessary dependency --- Directory.Packages.props | 3 +-- .../cdk/CdkSample.ApiService/CdkSample.ApiService.csproj | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 5a02e530588..208f6f5cd22 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -26,12 +26,11 @@ - - + diff --git a/playground/cdk/CdkSample.ApiService/CdkSample.ApiService.csproj b/playground/cdk/CdkSample.ApiService/CdkSample.ApiService.csproj index 24fe9fc900a..0d2733fd22d 100644 --- a/playground/cdk/CdkSample.ApiService/CdkSample.ApiService.csproj +++ b/playground/cdk/CdkSample.ApiService/CdkSample.ApiService.csproj @@ -19,9 +19,9 @@ + - From 29e39e168c005a2a40b731e4b8f205bd1ae68868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Ros?= Date: Thu, 15 May 2025 09:03:11 -0700 Subject: [PATCH 5/5] Update readme --- .../README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration/README.md b/src/Components/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration/README.md index 2038a3be9e8..16cffc84ebe 100644 --- a/src/Components/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration/README.md +++ b/src/Components/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration/README.md @@ -1,6 +1,6 @@ # Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration -Retrieves configuration settings from Azure App Configuration to use in your application. Registers Azure App Configuration service as a configuration source. Enables corresponding logging. +Retrieves configuration settings from Azure App Configuration to use in your application. Registers Azure App Configuration service as a configuration source. Enables corresponding logging and telemetry. ## Getting started