Skip to content

[AspNetCore] Add schema URL to traces#4066

Merged
martincostello merged 8 commits intoopen-telemetry:mainfrom
martincostello:gh-4064-aspnetcore
May 4, 2026
Merged

[AspNetCore] Add schema URL to traces#4066
martincostello merged 8 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)

@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 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 75.92%. Comparing base (fd2c666) to head (0c76fe2).
⚠️ Report is 4 commits behind head on main.
✅ 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   75.93%   75.92%   -0.01%     
==========================================
  Files         466      466              
  Lines       18635    18633       -2     
==========================================
- Hits        14150    14148       -2     
  Misses       4485     4485              
Flag Coverage Δ
unittests-Instrumentation.AspNet 76.99% <ø> (ø)
unittests-Instrumentation.AspNetCore 70.62% <66.66%> (-0.18%) ⬇️

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.17% <100.00%> (-0.34%) ⬇️
...eInstrumentationTracerProviderBuilderExtensions.cs 95.55% <0.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@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.

Comment thread src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs Outdated
Comment thread src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md Outdated
Comment thread test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs Outdated
@martincostello martincostello marked this pull request as draft April 8, 2026 15:50
Add schema URL to the `ActivitySource`.

Contributes to open-telemetry#4064.
Remove redundant test code for .NET Framework.
- Make CHANGELOG more specific.
- Remove unused using statement.
Use `ActivitySourceFactory` to create the `Activity`.
@martincostello martincostello marked this pull request as ready for review April 9, 2026 09:39
Revert `sealed`.
@github-actions
Copy link
Copy Markdown
Contributor

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions Bot added the Stale label Apr 17, 2026
@martincostello martincostello added keep-open Prevents issues and pull requests being closed as stale and removed Stale labels Apr 17, 2026
@Kielek Kielek disabled auto-merge May 4, 2026 10:16
internal static readonly Version Version = AssemblyName.Version!;
#pragma warning restore IDE0370 // Suppression is unnecessary
internal static readonly ActivitySource ActivitySource = new(ActivitySourceName, Version.ToString());
internal static readonly Version SemanticConventionsVersion = new(1, 40, 0);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In general, changes LGTM. Did you have chance to validate if the it really matches 1.40.0 requirements?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As part of #3993 and #4337 yes - we fill in the compliance gaps for anything ASPNET.Core itself is missing.

@martincostello martincostello added this pull request to the merge queue May 4, 2026
Merged via the queue into open-telemetry:main with commit 49f75d8 May 4, 2026
70 checks passed
@martincostello martincostello deleted the gh-4064-aspnetcore branch May 4, 2026 11:04
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 keep-open Prevents issues and pull requests being closed as stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants