diff --git a/src/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder/README.md b/src/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder/README.md index 5337196f9..a8a316f3c 100644 --- a/src/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder/README.md +++ b/src/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder/README.md @@ -113,6 +113,42 @@ 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, + "service-name": "@env('OTEL_SERVICE_NAME')", + "endpoint": "@env('OTEL_EXPORTER_OTLP_ENDPOINT')", + "exporter-protocol": "grpc", + "headers": "@env('OTEL_EXPORTER_OTLP_HEADERS')" + } + } + } +} +``` + +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 + +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.