Emit otel from Cosmos Db Preview Emulator#15671
Emit otel from Cosmos Db Preview Emulator#15671afscrome wants to merge 1 commit intomicrosoft:mainfrom
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15671Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15671" |
There was a problem hiding this comment.
Pull request overview
Updates the Azure Cosmos DB Linux-based preview emulator integration to emit OpenTelemetry telemetry by default when run under Aspire, aligning emulator behavior with other OTLP-enabled resources.
Changes:
- Enable OTLP exporter wiring for the Cosmos DB preview emulator via
WithOtlpExporter()andENABLE_OTLP_EXPORTER=true. - Update the emulator surrogate resource type declaration to include
IResourceWithEnvironment. - Switch the Cosmos end-to-end playground app host to use
RunAsPreviewEmulator().
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBExtensions.cs | Enables OTLP exporter + emulator-specific env var for the preview emulator path. |
| src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBEmulatorResource.cs | Adjusts implemented interfaces for the emulator wrapper resource. |
| playground/CosmosEndToEnd/CosmosEndToEnd.AppHost/Program.cs | Moves the playground to the preview emulator to exercise the updated behavior. |
| emulatorSurrogateBuilder.WithOtlpExporter() | ||
| .WithEnvironment("ENABLE_OTLP_EXPORTER", "true"); |
There was a problem hiding this comment.
The new default OTLP configuration for the preview emulator (WithOtlpExporter + ENABLE_OTLP_EXPORTER) isn’t covered by the existing CosmosDB extension tests. Please add a test that verifies RunAsPreviewEmulator registers OTLP exporter configuration (e.g., presence of OtlpExporterAnnotation / environment callback) and that the ENABLE_OTLP_EXPORTER environment variable is set for the preview emulator container.
| var cosmos = builder.AddAzureCosmosDB("cosmos") | ||
| .RunAsPreviewEmulator(); | ||
|
|
There was a problem hiding this comment.
The PR description notes that validating OTLP emission currently requires running the preview emulator with a specific image tag (via the configureContainer callback). This playground update switches to RunAsPreviewEmulator but doesn’t set the image tag, so it won’t exercise the intended scenario until the default tag includes the required build. Consider updating this call to pass a configureContainer callback that sets the image tag (or add a comment explaining why the playground intentionally uses the default tag).
Description
Update the cosmos preview emulator to emit open telemetry by default.
Note, this change currently requires a preview build of the preview emulator
x => x.WithImageTag("vnext-EN20260331pre"). To test this, you can update the playground app to specify that version. See Azure/azure-cosmos-db-emulator-docker#277 for more details.Fixes #15592, #13136
cc @lionelc @udsmicrosoft
Checklist