Skip to content

Conversation

martincostello
Copy link
Member

Changes

Add support for building and testing with .NET 10.

Initially using .NET 10 preview 4, will update as previews progress.

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 infra Infra work - CI/CD, code coverage, linters comp:exporter.geneva Things related to OpenTelemetry.Exporter.Geneva comp:exporter.stackdriver Things related to OpenTelemetry.Exporter.Stackdriver comp:instrumentation.aspnetcore Things related to OpenTelemetry.Instrumentation.AspNetCore comp:instrumentation.cassandra Things related to OpenTelemetry.Instrumentation.Cassandra comp:instrumentation.confluentkafka Things related to OpenTelemetry.Instrumentation.ConfluentKafka comp:instrumentation.http Things related to OpenTelemetry.Instrumentation.Http comp:instrumentation.sqlclient Things related to OpenTelemetry.Instrumentation.SqlClient comp:instrumentation.stackexchangeredis Things related to OpenTelemetry.Instrumentation.StackExchangeRedis labels Jun 9, 2025
@github-actions github-actions bot added comp:instrumentation.wcf Things related to OpenTelemetry.Instrumentation.Wcf comp:resources.processruntime Things related to OpenTelemetry.Resources.ProcessRuntime labels Jun 9, 2025
Copy link

codecov bot commented Jun 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.00%. Comparing base (e758269) to head (20cd570).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2822      +/-   ##
==========================================
- Coverage   70.04%   70.00%   -0.05%     
==========================================
  Files         429      439      +10     
  Lines       16838    16890      +52     
==========================================
+ Hits        11794    11823      +29     
- Misses       5044     5067      +23     
Flag Coverage Δ
unittests-Contrib.Shared.Tests 83.73% <ø> (ø)
unittests-Exporter.Geneva 53.47% <ø> (+0.13%) ⬆️
unittests-Exporter.InfluxDB 95.14% <ø> (ø)
unittests-Exporter.Instana 74.86% <ø> (ø)
unittests-Exporter.OneCollector 94.61% <ø> (ø)
unittests-Extensions 90.65% <ø> (ø)
unittests-Extensions.Enrichment 100.00% <ø> (ø)
unittests-Extensions.Enrichment.AspNetCore 94.11% <ø> (ø)
unittests-Extensions.Enrichment.Http 94.33% <ø> (ø)
unittests-Instrumentation.AWS 83.80% <ø> (ø)
unittests-Instrumentation.AspNet 75.18% <ø> (+0.24%) ⬆️
unittests-Instrumentation.AspNetCore 71.69% <ø> (+0.92%) ⬆️
unittests-Instrumentation.Cassandra 23.52% <ø> (?)
unittests-Instrumentation.ConfluentKafka 14.10% <ø> (ø)
unittests-Instrumentation.ElasticsearchClient 80.12% <ø> (ø)
unittests-Instrumentation.EntityFrameworkCore 80.80% <ø> (ø)
unittests-Instrumentation.EventCounters 76.36% <ø> (ø)
unittests-Instrumentation.GrpcCore 91.42% <ø> (ø)
unittests-Instrumentation.GrpcNetClient 79.61% <ø> (ø)
unittests-Instrumentation.Hangfire 84.61% <ø> (ø)
unittests-Instrumentation.Http 74.22% <100.00%> (+0.03%) ⬆️
unittests-Instrumentation.Owin 88.62% <ø> (ø)
unittests-Instrumentation.Process 100.00% <ø> (ø)
unittests-Instrumentation.Quartz 78.76% <ø> (ø)
unittests-Instrumentation.Runtime 100.00% <ø> (ø)
unittests-Instrumentation.ServiceFabricRemoting 34.54% <ø> (ø)
unittests-Instrumentation.SqlClient 87.29% <ø> (ø)
unittests-Instrumentation.StackExchangeRedis 71.80% <ø> (ø)
unittests-Instrumentation.Wcf 78.95% <ø> (+0.13%) ⬆️
unittests-OpAmp.Client 71.89% <ø> (+0.59%) ⬆️
unittests-PersistentStorage 65.88% <ø> (ø)
unittests-Resources.AWS 74.42% <ø> (ø)
unittests-Resources.Azure 85.31% <ø> (ø)
unittests-Resources.Container 67.34% <ø> (ø)
unittests-Resources.Gcp 71.42% <ø> (ø)
unittests-Resources.Host 73.91% <ø> (ø)
unittests-Resources.OperatingSystem 76.98% <ø> (ø)
unittests-Resources.Process 100.00% <ø> (ø)
unittests-Resources.ProcessRuntime 79.59% <ø> (ø)
unittests-Sampler.AWS 88.25% <ø> (ø)

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

Files with missing lines Coverage Δ
...tp/Implementation/HttpHandlerDiagnosticListener.cs 73.17% <100.00%> (+0.21%) ⬆️

... and 16 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.

@martincostello
Copy link
Member Author

martincostello commented Jun 9, 2025

Need to investigate macOS test failure with .NET 10. I don't have a Macbook so might be tricky:

[xUnit.net 00:00:00.10]   Finished:    OpenTelemetry.Resources.OperatingSystem.Tests
  Failed OpenTelemetry.Resources.OperatingSystem.Test.OperatingSystemDetectorTests.TestOperatingSystemAttributes [7 ms]
  Error Message:
Test Run Failed.
   Assert.Contains() Failure: Sub-string not found
String:    "macOS 14.7.6"
Not found: "Darwin"
  Stack Trace:
     at OpenTelemetry.Resources.OperatingSystem.Test.OperatingSystemDetectorTests.TestOperatingSystemAttributes() in /Users/runner/work/opentelemetry-dotnet-contrib/opentelemetry-dotnet-contrib/test/OpenTelemetry.Resources.OperatingSystem.Tests/OperatingSystemDetectorTests.cs:line 49
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

@martincostello
Copy link
Member Author

Need to investigate macOS test failure with .NET 10

Due to changes in dotnet/runtime#113041.

@github-actions github-actions bot added the comp:resources.operatingsystem Things related to OpenTelemetry.Resources.OperatingSystem label Jun 9, 2025
@github-actions github-actions bot added the comp:instrumentation.hangfire Things related to OpenTelemetry.Instrumentation.Hangfire label Jun 11, 2025
Copy link
Contributor

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

martincostello added a commit to martincostello/opentelemetry-dotnet-contrib that referenced this pull request Sep 10, 2025
Cherry-pick various changes from open-telemetry#2822:

- Fix incorrect version comment on CodeQL actions.
- Explicitly disable use of pre-release .NET SDK versions.
- Fix incorrect comment.
- Make System.Text.Json package reference conditional to avoid explicit dependency when the package in "in-box".
- Fix typo in test name.
- Add support for a maximum version for routing test cases.
- Allow the metric path for routing test cases to diverge from the activity path.
@martincostello martincostello mentioned this pull request Sep 10, 2025
4 tasks
@github-actions github-actions bot removed comp:exporter.geneva Things related to OpenTelemetry.Exporter.Geneva comp:resources.aws Things related to OpenTelemetry.Resources.AWS comp:instrumentation.sqlclient Things related to OpenTelemetry.Instrumentation.SqlClient labels Sep 10, 2025
Add support for building and testing with .NET 10, initially using .NET 10 preview 4.
Update expected description for macOS with .NET 10.
Update to preview 5 of .NET 10.
Update to preview 6 of .NET 10.
Fix another NU1510 warning.
Fix AoT NU1510 warnings.
Fix another NU1510 warning about `System.Text.Json`.
Move comments.
Update to preview 5 for Cassandra and update digests.
Update to preview 7 of .NET 10.
- Add test for Blazor activities in .NET 10.
- Fix typos.
- Update to release candidate 1 of .NET 10.
- Remove obsolete `IWebHost` usage.
Update globla.json so that actions/setup-dotnet works correctly with rc.1 vs preview.7.
Fix test broken by change in behaviour in .NET 10.
@joegoldman2
Copy link
Contributor

@martincostello with dotnet/runtime#116269 and dotnet/runtime#115959 available in .NET 10, the HttpClient native instrumentation now records exceptions. I think you can condition the following lines to apply them only for versions before 10:

if (requestTaskStatus != TaskStatus.RanToCompletion)
{
if (requestTaskStatus == TaskStatus.Canceled)
{
if (currentStatusCode == ActivityStatusCode.Unset)
{
// Task cancellation won't trigger the OnException so set the span error information here
// This can be either TaskCanceled or OperationCanceled but there is no way to figure out which one it is,
// so let's use the most common case as error type
activity.SetStatus(ActivityStatusCode.Error, "Task Canceled");
activity.SetTag(SemanticConventions.AttributeErrorType, typeof(TaskCanceledException).FullName);
}
}
else if (requestTaskStatus != TaskStatus.Faulted)
{
if (currentStatusCode == ActivityStatusCode.Unset)
{
// Faults are handled in OnException and should already have a span.Status of Error w/ Description.
activity.SetStatus(ActivityStatusCode.Error);
}
}
}

In the same way that some attributes are set only for versions before 9 (because runtime does it from this version):

When running under .NET 10 skip code that duplicates built-in functionality.
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 comp:instrumentation.cassandra Things related to OpenTelemetry.Instrumentation.Cassandra comp:instrumentation.confluentkafka Things related to OpenTelemetry.Instrumentation.ConfluentKafka comp:instrumentation.http Things related to OpenTelemetry.Instrumentation.Http comp:instrumentation.stackexchangeredis Things related to OpenTelemetry.Instrumentation.StackExchangeRedis comp:resources.operatingsystem Things related to OpenTelemetry.Resources.OperatingSystem infra Infra work - CI/CD, code coverage, linters keep-open Prevents issues and pull requests being closed as stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants