Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ASP.NET Core Traces Instrumentation for .NET7+ #3231

Closed
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ for `ILOGGER` for versions older than `8.0.0`.
### Fixed

- Set `service.name` resource attribute before invoking the plugin.
- Fix ASP.NET Core traces instrumentation for .NET7. It is now using native
support by `Microsoft.AspNetCore` instead of `OpenTelemetry.Instrumentation.AspNetCore`.

## [1.2.0](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/tag/v1.2.0)

Expand Down
2 changes: 1 addition & 1 deletion build/Extensions/DepsJsonExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static void RemoveOpenTelemetryLibraries(this JsonObject depsJson)
var dependencies = depsJson.GetDependencies();
var runtimeLibraries = depsJson["libraries"].AsObject();
var keysToRemove = dependencies
.Where(x => x.Key.StartsWith("OpenTelemetry"))
.Where(x => x.Key.StartsWith("OpenTelemetry.AutoInstrumentation.AdditionalDeps"))
.Select(x => x.Key)
.ToList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<PackageReference Include="System.Diagnostics.DiagnosticSource" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" />
Copy link
Contributor

Choose a reason for hiding this comment

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

OpenTelemetry.Instrumentation.AspNetCore has a dependency on web components like Microsoft.AspNetCore.App. When AdditionalDeps is applied to other .NET type applications, it may interfere with those applications. Therefore, it is not recommended to include web components in the store for auto-instrumentation purposes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you see better idea to load dependecy targeted fo .NET7 in net7 runtime?
Based on what I see in store chnages, there is no new libraries included into it. I will double check it tommorow.

</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project>
<Import Project="..\Directory.Packages.props" />
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,15 @@ public static TracerProviderBuilder AddAspNetInstrumentation(TracerProviderBuild
public static TracerProviderBuilder AddAspNetCoreInstrumentation(TracerProviderBuilder builder, PluginManager pluginManager, LazyInstrumentationLoader lazyInstrumentationLoader)
{
DelayedInitialization.Traces.AddAspNetCore(lazyInstrumentationLoader, pluginManager);
return builder
.AddSource("OpenTelemetry.Instrumentation.AspNetCore")
.AddLegacySource("Microsoft.AspNetCore.Hosting.HttpRequestIn");

if (Environment.Version.Major == 6)
{
return builder
.AddSource("OpenTelemetry.Instrumentation.AspNetCore")
.AddLegacySource("Microsoft.AspNetCore.Hosting.HttpRequestIn");
}

return builder.AddSource("Microsoft.AspNetCore");
}

public static TracerProviderBuilder AddGraphQLInstrumentation(TracerProviderBuilder builder, PluginManager pluginManager, LazyInstrumentationLoader lazyInstrumentationLoader, TracerSettings tracerSettings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
/net/Grpc.Net.Client.dll,
/net/Grpc.Net.Common.dll,
/net/MongoDB.Driver.Core.Extensions.DiagnosticSources.dll,
/net/OpenTelemetry.Api.ProviderBuilderExtensions.dll,
/net/OpenTelemetry.Api.dll,
/net/OpenTelemetry.AutoInstrumentation.AspNetCoreBootstrapper.dll,
/net/OpenTelemetry.AutoInstrumentation.AspNetCoreBootstrapper.pdb,
/net/OpenTelemetry.AutoInstrumentation.Loader.dll,
Expand All @@ -25,7 +23,6 @@
/net/OpenTelemetry.Exporter.Prometheus.HttpListener.dll,
/net/OpenTelemetry.Exporter.Zipkin.dll,
/net/OpenTelemetry.Extensions.Propagators.dll,
/net/OpenTelemetry.Instrumentation.AspNetCore.dll,
/net/OpenTelemetry.Instrumentation.EntityFrameworkCore.dll,
/net/OpenTelemetry.Instrumentation.GrpcNetClient.dll,
/net/OpenTelemetry.Instrumentation.Http.dll,
Expand Down Expand Up @@ -59,6 +56,9 @@
/store/x64/net6.0/microsoft.extensions.options.configurationextensions/8.0.0/lib/net8.0/Microsoft.Extensions.Options.ConfigurationExtensions.dll,
/store/x64/net6.0/microsoft.extensions.options/8.0.0/lib/net8.0/Microsoft.Extensions.Options.dll,
/store/x64/net6.0/microsoft.extensions.primitives/8.0.0/lib/net8.0/Microsoft.Extensions.Primitives.dll,
/store/x64/net6.0/opentelemetry.api.providerbuilderextensions/1.7.0/lib/net8.0/OpenTelemetry.Api.ProviderBuilderExtensions.dll,
/store/x64/net6.0/opentelemetry.api/1.7.0/lib/net8.0/OpenTelemetry.Api.dll,
/store/x64/net6.0/opentelemetry.instrumentation.aspnetcore/1.7.0/lib/net8.0/OpenTelemetry.Instrumentation.AspNetCore.dll,
/store/x64/net6.0/system.diagnostics.diagnosticsource/8.0.0/lib/net8.0/System.Diagnostics.DiagnosticSource.dll,
/store/x64/net7.0/microsoft.extensions.configuration.abstractions/8.0.0/lib/net8.0/Microsoft.Extensions.Configuration.Abstractions.dll,
/store/x64/net7.0/microsoft.extensions.configuration.binder/8.0.0/lib/net8.0/Microsoft.Extensions.Configuration.Binder.dll,
Expand All @@ -71,6 +71,9 @@
/store/x64/net7.0/microsoft.extensions.options.configurationextensions/8.0.0/lib/net8.0/Microsoft.Extensions.Options.ConfigurationExtensions.dll,
/store/x64/net7.0/microsoft.extensions.options/8.0.0/lib/net8.0/Microsoft.Extensions.Options.dll,
/store/x64/net7.0/microsoft.extensions.primitives/8.0.0/lib/net8.0/Microsoft.Extensions.Primitives.dll,
/store/x64/net7.0/opentelemetry.api.providerbuilderextensions/1.7.0/lib/net6.0/OpenTelemetry.Api.ProviderBuilderExtensions.dll,
Kielek marked this conversation as resolved.
Show resolved Hide resolved
/store/x64/net7.0/opentelemetry.api/1.7.0/lib/net6.0/OpenTelemetry.Api.dll,
/store/x64/net7.0/opentelemetry.instrumentation.aspnetcore/1.7.0/lib/net8.0/OpenTelemetry.Instrumentation.AspNetCore.dll,
/store/x64/net7.0/system.diagnostics.diagnosticsource/8.0.0/lib/net8.0/System.Diagnostics.DiagnosticSource.dll,
/store/x64/net8.0/microsoft.extensions.configuration.abstractions/8.0.0/lib/net8.0/Microsoft.Extensions.Configuration.Abstractions.dll,
/store/x64/net8.0/microsoft.extensions.configuration.binder/8.0.0/lib/net8.0/Microsoft.Extensions.Configuration.Binder.dll,
Expand All @@ -82,5 +85,8 @@
/store/x64/net8.0/microsoft.extensions.logging/8.0.0/lib/net8.0/Microsoft.Extensions.Logging.dll,
/store/x64/net8.0/microsoft.extensions.options.configurationextensions/8.0.0/lib/net8.0/Microsoft.Extensions.Options.ConfigurationExtensions.dll,
/store/x64/net8.0/microsoft.extensions.options/8.0.0/lib/net8.0/Microsoft.Extensions.Options.dll,
/store/x64/net8.0/microsoft.extensions.primitives/8.0.0/lib/net8.0/Microsoft.Extensions.Primitives.dll
/store/x64/net8.0/microsoft.extensions.primitives/8.0.0/lib/net8.0/Microsoft.Extensions.Primitives.dll,
/store/x64/net8.0/opentelemetry.api.providerbuilderextensions/1.7.0/lib/net8.0/OpenTelemetry.Api.ProviderBuilderExtensions.dll,
/store/x64/net8.0/opentelemetry.api/1.7.0/lib/net8.0/OpenTelemetry.Api.dll,
/store/x64/net8.0/opentelemetry.instrumentation.aspnetcore/1.7.0/lib/net8.0/OpenTelemetry.Instrumentation.AspNetCore.dll
]
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
/net/Grpc.Net.Client.dll,
/net/Grpc.Net.Common.dll,
/net/MongoDB.Driver.Core.Extensions.DiagnosticSources.dll,
/net/OpenTelemetry.Api.ProviderBuilderExtensions.dll,
/net/OpenTelemetry.Api.dll,
/net/OpenTelemetry.AutoInstrumentation.AspNetCoreBootstrapper.dll,
/net/OpenTelemetry.AutoInstrumentation.AspNetCoreBootstrapper.pdb,
/net/OpenTelemetry.AutoInstrumentation.Loader.dll,
Expand All @@ -25,7 +23,6 @@
/net/OpenTelemetry.Exporter.Prometheus.HttpListener.dll,
/net/OpenTelemetry.Exporter.Zipkin.dll,
/net/OpenTelemetry.Extensions.Propagators.dll,
/net/OpenTelemetry.Instrumentation.AspNetCore.dll,
/net/OpenTelemetry.Instrumentation.EntityFrameworkCore.dll,
/net/OpenTelemetry.Instrumentation.GrpcNetClient.dll,
/net/OpenTelemetry.Instrumentation.Http.dll,
Expand Down Expand Up @@ -59,6 +56,9 @@
/store/x64/net6.0/microsoft.extensions.options.configurationextensions/8.0.0/lib/net8.0/Microsoft.Extensions.Options.ConfigurationExtensions.dll,
/store/x64/net6.0/microsoft.extensions.options/8.0.0/lib/net8.0/Microsoft.Extensions.Options.dll,
/store/x64/net6.0/microsoft.extensions.primitives/8.0.0/lib/net8.0/Microsoft.Extensions.Primitives.dll,
/store/x64/net6.0/opentelemetry.api.providerbuilderextensions/1.7.0/lib/net8.0/OpenTelemetry.Api.ProviderBuilderExtensions.dll,
/store/x64/net6.0/opentelemetry.api/1.7.0/lib/net8.0/OpenTelemetry.Api.dll,
/store/x64/net6.0/opentelemetry.instrumentation.aspnetcore/1.7.0/lib/net8.0/OpenTelemetry.Instrumentation.AspNetCore.dll,
/store/x64/net6.0/system.diagnostics.diagnosticsource/8.0.0/lib/net8.0/System.Diagnostics.DiagnosticSource.dll,
/store/x64/net7.0/microsoft.extensions.configuration.abstractions/8.0.0/lib/net8.0/Microsoft.Extensions.Configuration.Abstractions.dll,
/store/x64/net7.0/microsoft.extensions.configuration.binder/8.0.0/lib/net8.0/Microsoft.Extensions.Configuration.Binder.dll,
Expand All @@ -71,6 +71,9 @@
/store/x64/net7.0/microsoft.extensions.options.configurationextensions/8.0.0/lib/net8.0/Microsoft.Extensions.Options.ConfigurationExtensions.dll,
/store/x64/net7.0/microsoft.extensions.options/8.0.0/lib/net8.0/Microsoft.Extensions.Options.dll,
/store/x64/net7.0/microsoft.extensions.primitives/8.0.0/lib/net8.0/Microsoft.Extensions.Primitives.dll,
/store/x64/net7.0/opentelemetry.api.providerbuilderextensions/1.7.0/lib/net6.0/OpenTelemetry.Api.ProviderBuilderExtensions.dll,
/store/x64/net7.0/opentelemetry.api/1.7.0/lib/net6.0/OpenTelemetry.Api.dll,
/store/x64/net7.0/opentelemetry.instrumentation.aspnetcore/1.7.0/lib/net8.0/OpenTelemetry.Instrumentation.AspNetCore.dll,
/store/x64/net7.0/system.diagnostics.diagnosticsource/8.0.0/lib/net8.0/System.Diagnostics.DiagnosticSource.dll,
/store/x64/net8.0/microsoft.extensions.configuration.abstractions/8.0.0/lib/net8.0/Microsoft.Extensions.Configuration.Abstractions.dll,
/store/x64/net8.0/microsoft.extensions.configuration.binder/8.0.0/lib/net8.0/Microsoft.Extensions.Configuration.Binder.dll,
Expand All @@ -82,5 +85,8 @@
/store/x64/net8.0/microsoft.extensions.logging/8.0.0/lib/net8.0/Microsoft.Extensions.Logging.dll,
/store/x64/net8.0/microsoft.extensions.options.configurationextensions/8.0.0/lib/net8.0/Microsoft.Extensions.Options.ConfigurationExtensions.dll,
/store/x64/net8.0/microsoft.extensions.options/8.0.0/lib/net8.0/Microsoft.Extensions.Options.dll,
/store/x64/net8.0/microsoft.extensions.primitives/8.0.0/lib/net8.0/Microsoft.Extensions.Primitives.dll
/store/x64/net8.0/microsoft.extensions.primitives/8.0.0/lib/net8.0/Microsoft.Extensions.Primitives.dll,
/store/x64/net8.0/opentelemetry.api.providerbuilderextensions/1.7.0/lib/net8.0/OpenTelemetry.Api.ProviderBuilderExtensions.dll,
/store/x64/net8.0/opentelemetry.api/1.7.0/lib/net8.0/OpenTelemetry.Api.dll,
/store/x64/net8.0/opentelemetry.instrumentation.aspnetcore/1.7.0/lib/net8.0/OpenTelemetry.Instrumentation.AspNetCore.dll
]
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
/net/Grpc.Net.Client.dll,
/net/Grpc.Net.Common.dll,
/net/MongoDB.Driver.Core.Extensions.DiagnosticSources.dll,
/net/OpenTelemetry.Api.ProviderBuilderExtensions.dll,
/net/OpenTelemetry.Api.dll,
/net/OpenTelemetry.AutoInstrumentation.AspNetCoreBootstrapper.dll,
/net/OpenTelemetry.AutoInstrumentation.AspNetCoreBootstrapper.pdb,
/net/OpenTelemetry.AutoInstrumentation.Loader.dll,
Expand All @@ -24,7 +22,6 @@
/net/OpenTelemetry.Exporter.Prometheus.HttpListener.dll,
/net/OpenTelemetry.Exporter.Zipkin.dll,
/net/OpenTelemetry.Extensions.Propagators.dll,
/net/OpenTelemetry.Instrumentation.AspNetCore.dll,
/net/OpenTelemetry.Instrumentation.EntityFrameworkCore.dll,
/net/OpenTelemetry.Instrumentation.GrpcNetClient.dll,
/net/OpenTelemetry.Instrumentation.Http.dll,
Expand Down Expand Up @@ -59,6 +56,9 @@
/store/x64/net6.0/microsoft.extensions.options.configurationextensions/8.0.0/lib/net8.0/Microsoft.Extensions.Options.ConfigurationExtensions.dll,
/store/x64/net6.0/microsoft.extensions.options/8.0.0/lib/net8.0/Microsoft.Extensions.Options.dll,
/store/x64/net6.0/microsoft.extensions.primitives/8.0.0/lib/net8.0/Microsoft.Extensions.Primitives.dll,
/store/x64/net6.0/opentelemetry.api.providerbuilderextensions/1.7.0/lib/net8.0/OpenTelemetry.Api.ProviderBuilderExtensions.dll,
/store/x64/net6.0/opentelemetry.api/1.7.0/lib/net8.0/OpenTelemetry.Api.dll,
/store/x64/net6.0/opentelemetry.instrumentation.aspnetcore/1.7.0/lib/net8.0/OpenTelemetry.Instrumentation.AspNetCore.dll,
/store/x64/net6.0/system.diagnostics.diagnosticsource/8.0.0/lib/net8.0/System.Diagnostics.DiagnosticSource.dll,
/store/x64/net7.0/microsoft.extensions.configuration.abstractions/8.0.0/lib/net8.0/Microsoft.Extensions.Configuration.Abstractions.dll,
/store/x64/net7.0/microsoft.extensions.configuration.binder/8.0.0/lib/net8.0/Microsoft.Extensions.Configuration.Binder.dll,
Expand All @@ -71,6 +71,9 @@
/store/x64/net7.0/microsoft.extensions.options.configurationextensions/8.0.0/lib/net8.0/Microsoft.Extensions.Options.ConfigurationExtensions.dll,
/store/x64/net7.0/microsoft.extensions.options/8.0.0/lib/net8.0/Microsoft.Extensions.Options.dll,
/store/x64/net7.0/microsoft.extensions.primitives/8.0.0/lib/net8.0/Microsoft.Extensions.Primitives.dll,
/store/x64/net7.0/opentelemetry.api.providerbuilderextensions/1.7.0/lib/net6.0/OpenTelemetry.Api.ProviderBuilderExtensions.dll,
/store/x64/net7.0/opentelemetry.api/1.7.0/lib/net6.0/OpenTelemetry.Api.dll,
/store/x64/net7.0/opentelemetry.instrumentation.aspnetcore/1.7.0/lib/net8.0/OpenTelemetry.Instrumentation.AspNetCore.dll,
/store/x64/net7.0/system.diagnostics.diagnosticsource/8.0.0/lib/net8.0/System.Diagnostics.DiagnosticSource.dll,
/store/x64/net8.0/microsoft.extensions.configuration.abstractions/8.0.0/lib/net8.0/Microsoft.Extensions.Configuration.Abstractions.dll,
/store/x64/net8.0/microsoft.extensions.configuration.binder/8.0.0/lib/net8.0/Microsoft.Extensions.Configuration.Binder.dll,
Expand All @@ -82,5 +85,8 @@
/store/x64/net8.0/microsoft.extensions.logging/8.0.0/lib/net8.0/Microsoft.Extensions.Logging.dll,
/store/x64/net8.0/microsoft.extensions.options.configurationextensions/8.0.0/lib/net8.0/Microsoft.Extensions.Options.ConfigurationExtensions.dll,
/store/x64/net8.0/microsoft.extensions.options/8.0.0/lib/net8.0/Microsoft.Extensions.Options.dll,
/store/x64/net8.0/microsoft.extensions.primitives/8.0.0/lib/net8.0/Microsoft.Extensions.Primitives.dll
/store/x64/net8.0/microsoft.extensions.primitives/8.0.0/lib/net8.0/Microsoft.Extensions.Primitives.dll,
/store/x64/net8.0/opentelemetry.api.providerbuilderextensions/1.7.0/lib/net8.0/OpenTelemetry.Api.ProviderBuilderExtensions.dll,
/store/x64/net8.0/opentelemetry.api/1.7.0/lib/net8.0/OpenTelemetry.Api.dll,
/store/x64/net8.0/opentelemetry.instrumentation.aspnetcore/1.7.0/lib/net8.0/OpenTelemetry.Instrumentation.AspNetCore.dll
]
Loading
Loading