Skip to content

Demonstrate application-owned OpenTelemetry providers - #11525

Merged
Amaury Levé (Evangelink) merged 2 commits into
microsoft:dev/amauryleve/split-telemetry-resourcesfrom
Evangelink:dev/amauryleve/validate-telemetry-topology
Sep 25, 2026
Merged

Amaury Levé (Evangelink) merged 2 commits into
microsoft:dev/amauryleve/split-telemetry-resourcesfrom
Evangelink:dev/amauryleve/validate-telemetry-topology

Conversation

@Evangelink

Copy link
Copy Markdown
Member

This follow-up to #11505 demonstrates the intended composition model when a test application already owns its OpenTelemetry providers through HostApplicationBuilder. MTP activates and emits diagnostics, while the application remains responsible for provider, exporter, resource, and lifetime ownership.

Approach

  • Update the public MTPOTel sample to configure application-owned tracing and metrics, subscribe with AddTestingPlatformInstrumentation(), and activate MTP diagnostics with AddTestingPlatformDiagnostics().
  • Use focused test and CI resource helpers so the application's service.name, host, OS, and process identity remain intact.
  • Add a package-consuming acceptance test that captures both MTP diagnostics and a custom activity created inside test execution, verifies test.run.duration, and checks the trace and metric resources.
  • Preserve ambient W3C trace context when MTP starts an activity without an explicit parent. Explicit external parent IDs keep their existing behavior.
  • Document the provider ownership model and make the sample discoverable.

Trace topology

The application-owned root activity contains the MTP builder and run. During test execution, the custom application activity and MTP's asynchronously produced test-result activity share the same trace and are siblings under TestFramework. The test asserts this architecturally valid relationship rather than forcing the result span to be a child of ambient user test code, which would be unsafe with parallel and asynchronous result processing.

Validation

  • Build.cmd -pack -bl
  • Focused OpenTelemetry unit tests on net8.0 and net9.0: 25/25 passed on each
  • Package-consuming OpenTelemetry acceptance test on net11.0: 1/1 passed
  • Public MTPOTel sample on net9.0: 5/5 passed, including five custom test activities
  • Build.cmd -rebuild -bl
  • git diff --check

The full Build.cmd -test -bl run passed the changed areas but encountered unrelated environment-sensitive NamedPipeServerSecurityTests failures on Windows due to OS error 1346 being surfaced as IOException instead of UnauthorizedAccessException.

@github-actions github-actions Bot added the state/needs-review Awaiting review from the team. label Sep 25, 2026
@Evangelink
Amaury Levé (Evangelink) force-pushed the dev/amauryleve/split-telemetry-resources branch from c8799a2 to c5ab62e Compare September 25, 2026 10:38
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@Evangelink
Amaury Levé (Evangelink) force-pushed the dev/amauryleve/validate-telemetry-topology branch from 0b90a4f to 1bf7feb Compare September 25, 2026 10:52
@github-actions github-actions Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Sep 25, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Sep 25, 2026
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/needs-review Awaiting review from the team. labels Sep 25, 2026
@Evangelink
Amaury Levé (Evangelink) merged commit 446870e into microsoft:dev/amauryleve/split-telemetry-resources Sep 25, 2026
34 of 36 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/validate-telemetry-topology branch September 25, 2026 11:46
@microsoft-github-policy-service microsoft-github-policy-service Bot removed the state/approved Proposal approved; ready for implementation. label Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants