diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreInstrumentationTracerProviderBuilderExtensions.cs b/src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreInstrumentationTracerProviderBuilderExtensions.cs index 8b2a728b5e..f44442a9ef 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreInstrumentationTracerProviderBuilderExtensions.cs +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreInstrumentationTracerProviderBuilderExtensions.cs @@ -120,7 +120,7 @@ private static void AddAspNetCoreInstrumentationSources( } else { - builder.AddSource(HttpInListener.ActivitySourceName); + builder.AddSource(HttpInListener.ActivitySource.Name); builder.AddLegacySource(HttpInListener.ActivityOperationName); // for the activities created by AspNetCore } diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md index 89bcc1fdfb..bbddaafeae 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md @@ -8,6 +8,9 @@ AppContext switch to `false` (its default value is `true`). ([#3993](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/3993)) +* Add instrumentation schema URL to traces for `netstandard2.0`. + ([#4066](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/4066)) + ## 1.15.2 Released 2026-Apr-21 diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs index cb1eb98e71..43f461c6a5 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs @@ -3,7 +3,6 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -using System.Reflection; using System.Runtime.CompilerServices; using Microsoft.AspNetCore.Http; using OpenTelemetry.Context.Propagation; @@ -23,12 +22,8 @@ internal class HttpInListener : ListenerHandler // https://github.com/dotnet/aspnetcore/blob/8d6554e655b64da75b71e0e20d6db54a3ba8d2fb/src/Hosting/Hosting/src/GenericHost/GenericWebHostBuilder.cs#L85 internal const string AspNetCoreActivitySourceName = "Microsoft.AspNetCore"; - internal static readonly AssemblyName AssemblyName = typeof(HttpInListener).Assembly.GetName(); -#pragma warning disable IDE0370 // Suppression is unnecessary - internal static readonly string ActivitySourceName = AssemblyName.Name!; - 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); + internal static readonly ActivitySource ActivitySource = ActivitySourceFactory.Create(SemanticConventionsVersion); internal static readonly bool Net7OrGreater = Environment.Version.Major >= 7; internal static readonly bool Net10OrGreater = Environment.Version.Major >= 10; diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/OpenTelemetry.Instrumentation.AspNetCore.csproj b/src/OpenTelemetry.Instrumentation.AspNetCore/OpenTelemetry.Instrumentation.AspNetCore.csproj index b90ef7efbc..f9b570708e 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/OpenTelemetry.Instrumentation.AspNetCore.csproj +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/OpenTelemetry.Instrumentation.AspNetCore.csproj @@ -13,15 +13,17 @@ - - - - - + + + + + + + diff --git a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs index 48dd47f26a..68853382f2 100644 --- a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs +++ b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs @@ -8,7 +8,6 @@ using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.RateLimiting; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using OpenTelemetry.Metrics; using OpenTelemetry.Trace;