Skip to content

[AspNetCore] Add schema URL to traces#4066

Open
martincostello wants to merge 4 commits intoopen-telemetry:mainfrom
martincostello:gh-4064-aspnetcore
Open

[AspNetCore] Add schema URL to traces#4066
martincostello wants to merge 4 commits intoopen-telemetry:mainfrom
martincostello:gh-4064-aspnetcore

Conversation

@martincostello
Copy link
Copy Markdown
Member

@martincostello martincostello commented Apr 6, 2026

Contributes to #4064.

Changes

  • Add schema URL to the ActivitySource use for netstandard2.0.
  • Remove redundant test code.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

Add schema URL to the `ActivitySource`.

Contributes to open-telemetry#4064.
@github-actions github-actions bot added the comp:instrumentation.aspnetcore Things related to OpenTelemetry.Instrumentation.AspNetCore label Apr 6, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 6, 2026

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 72.90%. Comparing base (d1717a8) to head (35a9b51).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...eInstrumentationTracerProviderBuilderExtensions.cs 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4066      +/-   ##
==========================================
+ Coverage   72.75%   72.90%   +0.15%     
==========================================
  Files         458      448      -10     
  Lines       17876    17832      -44     
==========================================
- Hits        13006    13001       -5     
+ Misses       4870     4831      -39     
Flag Coverage Δ
unittests-Instrumentation.AspNet 77.37% <ø> (ø)
unittests-Instrumentation.AspNetCore 71.05% <91.66%> (+0.60%) ⬆️
unittests-Instrumentation.Cassandra ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...tation.AspNetCore/Implementation/HttpInListener.cs 74.50% <100.00%> (+1.22%) ⬆️
...eInstrumentationTracerProviderBuilderExtensions.cs 95.74% <0.00%> (ø)

... and 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Remove redundant test code for .NET Framework.
@martincostello martincostello marked this pull request as ready for review April 6, 2026 16:28
@martincostello martincostello requested a review from a team as a code owner April 6, 2026 16:28
Copilot AI review requested due to automatic review settings April 6, 2026 16:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the ASP.NET Core instrumentation to attach an OpenTelemetry schema URL to the ActivitySource used in the legacy (non-.NET 7+) tracing path, and cleans up conditional compilation in related unit tests.

Changes:

  • Create HttpInListener.ActivitySource via ActivitySourceOptions to set TelemetrySchemaUrl (and use package version via GetPackageVersion()).
  • Update tracer provider source registration to reference HttpInListener.ActivitySource.Name in the legacy path.
  • Remove redundant #if NET guards in test code.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/OpenTelemetry.Instrumentation.AspNetCore.Tests/RouteTests/TestApplication/TestApplicationFactory.cs Removes #if NET around Minimal API MapGroup route setup.
test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs Removes #if NET guards; leaves an unused using that should be cleaned up.
test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs Simplifies assertions by removing #if NET branches for ActivitySource name/version validation.
src/OpenTelemetry.Instrumentation.AspNetCore/OpenTelemetry.Instrumentation.AspNetCore.csproj Adds AssemblyVersionExtensions.cs include to support GetPackageVersion().
src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs Introduces CreateActivitySource() using ActivitySourceOptions with schema URL + package version.
src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md Adds changelog entry for schema URL change (currently worded more broadly than the implementation scope).
src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreInstrumentationTracerProviderBuilderExtensions.cs Uses HttpInListener.ActivitySource.Name when registering sources for the legacy path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Make CHANGELOG more specific.
- Remove unused using statement.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:instrumentation.aspnetcore Things related to OpenTelemetry.Instrumentation.AspNetCore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants