From ea369c96f2d09ddbc03ee08d820ba3449f54d7b6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Nov 2025 03:32:45 +0000 Subject: [PATCH 1/6] Initial plan From 6cd13b7d08ac09947fb6aa2f4221521e8a7fef5f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Nov 2025 03:40:34 +0000 Subject: [PATCH 2/6] Add OTEL documentation and configuration to DAB integration - Updated dab-config.json example to include OTEL configuration - Added comprehensive OTEL documentation to README - Explained how OTEL works with the Aspire integration - Documented advanced OTEL configuration options Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com> --- .../dab-config.json | 5 ++ .../README.md | 52 +++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/examples/data-api-builder/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.AppHost/dab-config.json b/examples/data-api-builder/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.AppHost/dab-config.json index 69d8b687c..de01b564d 100644 --- a/examples/data-api-builder/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.AppHost/dab-config.json +++ b/examples/data-api-builder/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.AppHost/dab-config.json @@ -27,6 +27,11 @@ "provider": "Simulator" }, "mode": "development" + }, + "telemetry": { + "open-telemetry": { + "enabled": true + } } }, "entities": { diff --git a/src/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder/README.md b/src/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder/README.md index 5337196f9..0a9868b78 100644 --- a/src/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder/README.md +++ b/src/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder/README.md @@ -113,6 +113,58 @@ var dab = builder.AddDataAPIBuilder("dab") .WithImageTag("latest"); ``` +### OpenTelemetry Instrumentation + +The Data API builder integration automatically configures OpenTelemetry (OTEL) instrumentation for distributed tracing and metrics. The integration uses the standard `.WithOtlpExporter()` method which sets up the necessary OTEL environment variables that Data API builder automatically recognizes. + +To enable OTEL telemetry in Data API builder, add the following configuration to your `dab-config.json` file: + +```json +{ + "runtime": { + "telemetry": { + "open-telemetry": { + "enabled": true + } + } + } +} +``` + +With this configuration, Data API builder will: +- Export traces and metrics to the Aspire dashboard via OTLP (OpenTelemetry Protocol) +- Automatically use the OTEL endpoint provided by the Aspire app host +- Include telemetry for REST and GraphQL operations, database queries, and system metrics + +#### Advanced OTEL Configuration + +Data API builder supports additional OTEL configuration options in the `dab-config.json` file: + +```json +{ + "runtime": { + "telemetry": { + "open-telemetry": { + "enabled": true, + "service-name": "my-dab-service", + "exporter-protocol": "grpc" + } + } + } +} +``` + +Available settings: +- `enabled`: Enables/disables OTEL telemetry (default: `false`) +- `service-name`: Logical name for the service in traces (optional, defaults to the resource name) +- `endpoint`: OTEL collector endpoint URL (optional, automatically set by Aspire) +- `exporter-protocol`: Choose between `grpc` or `httpprotobuf` (optional, defaults to `grpc`) +- `headers`: Custom headers for OTEL export (optional) + +> **Note**: The `endpoint` setting is automatically configured by the Aspire integration and typically doesn't need to be set manually. + +For more information about Data API builder telemetry, see the [official documentation](https://learn.microsoft.com/azure/data-api-builder/concept/monitor/open-telemetry). + ## Known Issues The current imlpementation of the Data API builder .NET Aspire integration does not support HTTPS endpoints. However, this is only a dev-time consideration. Service discovery when published can use HTTPS without any problems. From 87fda82b37e5a736dd1b6ec425bbb884f90e1fda Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Nov 2025 08:48:10 +0000 Subject: [PATCH 3/6] Update OTEL config to include all fields with env variables - Added service-name, endpoint, exporter-protocol, and headers fields - All fields use @env() syntax to reference OTEL environment variables - Updated both example dab-config.json and README documentation Co-authored-by: tommasodotNET <12819039+tommasodotNET@users.noreply.github.com> --- .../dab-config.json | 6 +++++- .../README.md | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/data-api-builder/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.AppHost/dab-config.json b/examples/data-api-builder/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.AppHost/dab-config.json index de01b564d..d2a525ef1 100644 --- a/examples/data-api-builder/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.AppHost/dab-config.json +++ b/examples/data-api-builder/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.AppHost/dab-config.json @@ -30,7 +30,11 @@ }, "telemetry": { "open-telemetry": { - "enabled": true + "enabled": true, + "service-name": "@env('OTEL_SERVICE_NAME')", + "endpoint": "@env('OTEL_EXPORTER_OTLP_ENDPOINT')", + "exporter-protocol": "grpc", + "headers": "@env('OTEL_EXPORTER_OTLP_HEADERS')" } } }, diff --git a/src/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder/README.md b/src/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder/README.md index 0a9868b78..063b71841 100644 --- a/src/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder/README.md +++ b/src/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder/README.md @@ -124,7 +124,11 @@ To enable OTEL telemetry in Data API builder, add the following configuration to "runtime": { "telemetry": { "open-telemetry": { - "enabled": true + "enabled": true, + "service-name": "@env('OTEL_SERVICE_NAME')", + "endpoint": "@env('OTEL_EXPORTER_OTLP_ENDPOINT')", + "exporter-protocol": "grpc", + "headers": "@env('OTEL_EXPORTER_OTLP_HEADERS')" } } } From 1906f4b7dffbe423846234e9cc2f743cbcce96ea Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Nov 2025 08:56:54 +0000 Subject: [PATCH 4/6] Remove redundant Advanced OTEL Configuration section - Removed duplicate Advanced OTEL Configuration section - Moved setting descriptions to main paragraph after the config example - Improved clarity by explaining the @env() syntax usage - All settings now documented in one place Co-authored-by: tommasodotNET <12819039+tommasodotNET@users.noreply.github.com> --- .../README.md | 34 ++++--------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/src/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder/README.md b/src/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder/README.md index 063b71841..a8a316f3c 100644 --- a/src/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder/README.md +++ b/src/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder/README.md @@ -135,38 +135,18 @@ To enable OTEL telemetry in Data API builder, add the following configuration to } ``` +The configuration includes the following settings: +- `enabled`: Enables/disables OTEL telemetry (default: `false`) +- `service-name`: Logical name for the service in traces. Uses the `@env('OTEL_SERVICE_NAME')` syntax to reference the environment variable automatically set by Aspire +- `endpoint`: OTEL collector endpoint URL. Uses `@env('OTEL_EXPORTER_OTLP_ENDPOINT')` to reference the Aspire-provided endpoint +- `exporter-protocol`: Protocol for exporting telemetry. Set to `grpc` for efficient binary transport +- `headers`: Custom headers for OTEL export. Uses `@env('OTEL_EXPORTER_OTLP_HEADERS')` to reference Aspire-provided headers + With this configuration, Data API builder will: - Export traces and metrics to the Aspire dashboard via OTLP (OpenTelemetry Protocol) - Automatically use the OTEL endpoint provided by the Aspire app host - Include telemetry for REST and GraphQL operations, database queries, and system metrics -#### Advanced OTEL Configuration - -Data API builder supports additional OTEL configuration options in the `dab-config.json` file: - -```json -{ - "runtime": { - "telemetry": { - "open-telemetry": { - "enabled": true, - "service-name": "my-dab-service", - "exporter-protocol": "grpc" - } - } - } -} -``` - -Available settings: -- `enabled`: Enables/disables OTEL telemetry (default: `false`) -- `service-name`: Logical name for the service in traces (optional, defaults to the resource name) -- `endpoint`: OTEL collector endpoint URL (optional, automatically set by Aspire) -- `exporter-protocol`: Choose between `grpc` or `httpprotobuf` (optional, defaults to `grpc`) -- `headers`: Custom headers for OTEL export (optional) - -> **Note**: The `endpoint` setting is automatically configured by the Aspire integration and typically doesn't need to be set manually. - For more information about Data API builder telemetry, see the [official documentation](https://learn.microsoft.com/azure/data-api-builder/concept/monitor/open-telemetry). ## Known Issues From afbade242ff80a23cd00e9c029af1da69b6f0399 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 21 Nov 2025 03:49:23 +0000 Subject: [PATCH 5/6] Set AppHost__OtlpApiKey in tests to fix CI failures - Added static constructor to AppHostTests to set AppHost__OtlpApiKey - This ensures Aspire configures OTEL headers that dab-config.json expects - Fixes CI test failures where OTEL_EXPORTER_OTLP_HEADERS was not set Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com> --- .../AppHostTests.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.Tests/AppHostTests.cs b/tests/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.Tests/AppHostTests.cs index 8b1b0d52a..987ad3c7b 100644 --- a/tests/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.Tests/AppHostTests.cs +++ b/tests/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.Tests/AppHostTests.cs @@ -8,6 +8,13 @@ namespace CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.Tests; [RequiresDocker] public class AppHostTests(AspireIntegrationTestFixture fixture) : IClassFixture> { + static AppHostTests() + { + // Set OtlpApiKey to ensure OTEL headers are configured by Aspire + // This is required for the dab-config.json which references @env('OTEL_EXPORTER_OTLP_HEADERS') + Environment.SetEnvironmentVariable("AppHost__OtlpApiKey", Guid.NewGuid().ToString()); + } + [Fact] public async Task ResourceStartsAndRespondsOk() { From 8122979dbe7099c3a9fa32681857b9d76c6317a9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 22 Nov 2025 22:17:12 +0000 Subject: [PATCH 6/6] Revert dab-config.json and AppHostTests.cs changes - Removed OTEL telemetry configuration from dab-config.json - Removed static constructor from AppHostTests.cs - Keeping only README.md documentation changes - Addresses test bootstrap issues with OTEL configuration Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com> --- .../dab-config.json | 9 --------- .../AppHostTests.cs | 7 ------- 2 files changed, 16 deletions(-) diff --git a/examples/data-api-builder/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.AppHost/dab-config.json b/examples/data-api-builder/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.AppHost/dab-config.json index d2a525ef1..69d8b687c 100644 --- a/examples/data-api-builder/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.AppHost/dab-config.json +++ b/examples/data-api-builder/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.AppHost/dab-config.json @@ -27,15 +27,6 @@ "provider": "Simulator" }, "mode": "development" - }, - "telemetry": { - "open-telemetry": { - "enabled": true, - "service-name": "@env('OTEL_SERVICE_NAME')", - "endpoint": "@env('OTEL_EXPORTER_OTLP_ENDPOINT')", - "exporter-protocol": "grpc", - "headers": "@env('OTEL_EXPORTER_OTLP_HEADERS')" - } } }, "entities": { diff --git a/tests/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.Tests/AppHostTests.cs b/tests/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.Tests/AppHostTests.cs index 987ad3c7b..8b1b0d52a 100644 --- a/tests/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.Tests/AppHostTests.cs +++ b/tests/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.Tests/AppHostTests.cs @@ -8,13 +8,6 @@ namespace CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.Tests; [RequiresDocker] public class AppHostTests(AspireIntegrationTestFixture fixture) : IClassFixture> { - static AppHostTests() - { - // Set OtlpApiKey to ensure OTEL headers are configured by Aspire - // This is required for the dab-config.json which references @env('OTEL_EXPORTER_OTLP_HEADERS') - Environment.SetEnvironmentVariable("AppHost__OtlpApiKey", Guid.NewGuid().ToString()); - } - [Fact] public async Task ResourceStartsAndRespondsOk() {