Add default OTEL telemetry settings to dab init config generation#3162
Open
Add default OTEL telemetry settings to dab init config generation#3162
dab init config generation#3162Conversation
Co-authored-by: JerryNixon <1749983+JerryNixon@users.noreply.github.com>
…sertion Co-authored-by: JerryNixon <1749983+JerryNixon@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add default OpenTelemetry settings to dab init
Add default OTEL telemetry settings to Feb 25, 2026
dab init config generation
JerryNixon
approved these changes
Feb 26, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates dab init config generation to include default OpenTelemetry settings (via @env() references to standard OTEL_* environment variables) and refreshes CLI tests/snapshots to reflect the new generated config shape.
Changes:
- Add default
runtime.telemetry.open-telemetryblock to init-generatedRuntimeConfig. - Update CLI E2E tests to tolerate unset OTEL_* env vars during deserialization and adjust assertions for non-null telemetry.
- Refresh Verify snapshots for init-generated configs to include the new telemetry section.
Reviewed changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Cli/ConfigGenerator.cs | Adds default OpenTelemetry telemetry options to the RuntimeConfig produced by dab init. |
| src/Cli.Tests/EndToEndTests.cs | Updates env-var replacement settings and telemetry assertions to accommodate new init defaults. |
| src/Cli.Tests/Snapshots/EndToEndTests.TestInitForCosmosDBNoSql.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.CosmosDbNoSqlDatabase.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.CosmosDbPostgreSqlDatabase.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.EnsureCorrectConfigGenerationWithDifferentAuthenticationProviders_171ea8114ff71814.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.EnsureCorrectConfigGenerationWithDifferentAuthenticationProviders_2df7a1794712f154.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.EnsureCorrectConfigGenerationWithDifferentAuthenticationProviders_59fe1a10aa78899d.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.EnsureCorrectConfigGenerationWithDifferentAuthenticationProviders_b95b637ea87f16a7.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.EnsureCorrectConfigGenerationWithDifferentAuthenticationProviders_daacbd948b7ef72f.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.GraphQLPathWithoutStartingSlashWillHaveItAdded.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.MsSQLDatabase.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.RestPathWithoutStartingSlashWillHaveItAdded.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.TestInitializingConfigWithoutConnectionString.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.TestSpecialCharactersInConnectionString.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_0546bef37027a950.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_0ac567dd32a2e8f5.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_0c06949221514e77.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_18667ab7db033e9d.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_2f42f44c328eb020.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_3243d3f3441fdcc1.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_53350b8b47df2112.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_6584e0ec46b8a11d.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_81cc88db3d4eecfb.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_8ea187616dbb5577.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_905845c29560a3ef.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_b2fd24fab5b80917.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_bd7cd088755287c9.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_d2eccba2f836b380.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_d463eed7fe5e4bbe.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_d5520dd5c33f7b8d.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_eab4a6010e602b59.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
| src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_ecaa688829b4030e.verified.txt | Snapshot updated to include Telemetry.OpenTelemetry section. |
… OTLP endpoint URI before setup Co-authored-by: Aniruddh25 <3513779+Aniruddh25@users.noreply.github.com>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why make this change?
dab initgenerates config with no telemetry section, requiring users to manually edit config or rundab add-telemetryto enable standard OpenTelemetry workflows. This is friction for .NET/Aspire and containerized scenarios where OTEL env vars are already set by the orchestrator.What is this change?
Adds default OpenTelemetry config to
TryCreateRuntimeConfig()using@env()references for standard OTEL environment variables. The generated config now includes:Additionally, runtime config loading and OTLP exporter setup are hardened to gracefully handle missing OTEL env vars:
src/Cli/ConfigGenerator.cs— AddedTelemetryOptionswithOpenTelemetryOptionsto theRuntimeConfigconstructed during init.src/Config/FileSystemRuntimeConfigLoader.cs— ChangedTryLoadKnownConfigto useEnvironmentVariableReplacementFailureMode.Ignoreso missing@env()env vars don't crash config loading — they remain as literal@env(...)strings.src/Service/Startup.cs— AddedUri.TryCreatevalidation in the OTLP exporter setup guard condition. If the endpoint is null, empty, or an unresolved@env(...)placeholder (not a valid URI), OTLP exporter setup is skipped entirely and a warning is logged. Updated warning message to reference "endpoint URI" instead of "connection string".src/Service/Program.cs— Applied the sameUri.TryCreatevalidation for the logger factory OTLP setup, replacing the previous!string.IsNullOrWhiteSpace+new Uri()pattern.src/Cli.Tests/EndToEndTests.cs— E2E tests that deserialize init-generated config withdoReplaceEnvVar: truenow useEnvironmentVariableReplacementFailureMode.Ignorematching production behavior.TestAddTelemetryassertion updated since telemetry is no longer null after init.How was this tested?
All 43
InitTestspass.EndToEndTests.TestInitForCosmosDBNoSqlpasses. E2E tests forTestInitializingRestAndGraphQLGlobalSettings,TestEnablingMultipleCreateOperation, andTestAddTelemetryupdated to accommodate new defaults.Sample Request(s)
dab init --database-type mssql --connection-string "Server=localhost;Database=mydb;"Generated
dab-config.jsonnow includes thetelemetry.open-telemetrysection with@env()references. If the OTEL env vars are set at runtime (e.g., by Aspire or a container orchestrator), telemetry export works automatically. If unset, the@env()values remain as literal strings, the endpoint failsUri.TryCreatevalidation, and OTLP setup is gracefully skipped.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.