opentelemetry-dotnet-instrumentation icon indicating copy to clipboard operation
opentelemetry-dotnet-instrumentation copied to clipboard

.NET Core 3.1 - FileLoadException - Microsoft.AspNetCore.Http.Features

Open rajkumar-rangaraj opened this issue 3 years ago • 5 comments
trafficstars

Bug Report

Symptom

Describe the bug

2022-07-22T16:09:17.8886959Z:Unknown error processing event '{1}' from handler '{0}', Exception: {2}{Microsoft.AspNetCore}{Microsoft.AspNetCore.Hosting.HttpRequestIn.Start}{System.IO.FileLoadException: Could not load file or assembly 'Microsoft.AspNetCore.Http.Features, Version=3.1.22.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Could not find or load a specific file. (0x80131621) File name: 'Microsoft.AspNetCore.Http.Features, Version=3.1.22.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' ---> System.IO.FileLoadException: Could not load file or assembly 'Microsoft.AspNetCore.Http.Features, Version=3.1.22.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly) at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath) at System.Reflection.Assembly.LoadFrom(String assemblyFile) at System.Reflection.Assembly.LoadFromResolveHandler(Object sender, ResolveEventArgs args) at System.Runtime.Loader.AssemblyLoadContext.InvokeResolveEvent(ResolveEventHandler eventHandler, RuntimeAssembly assembly, String name) at OpenTelemetry.Instrumentation.AspNetCore.Implementation.HttpInListener.OnStartActivity(Activity activity, Object payload) at OpenTelemetry.Instrumentation.DiagnosticSourceListener.OnNext(KeyValuePair`2 value)

Expected behavior No exception

Screenshots If applicable, add screenshots to help explain your problem.

Runtime environment (please complete the following information):

  • OpenTelemetry Automatic Instrumentation version: 0.2.0-beta.1
  • OS: Linux (AKS)
  • .NET version: .NET Core 3.0 (3.1.12)

Additional context Add any other context about the problem here.

Reproduce

Steps to reproduce the behavior:

Adding AspNet instrumentation to .NET Core app with version less than 3.1.22 reproduce the issue. Resolution is to use the latest .NET Core 3.1 package.

rajkumar-rangaraj avatar Jul 22 '22 16:07 rajkumar-rangaraj

Quick idea: Microsoft.AspNetCore.Http.Abstractions and Microsoft.AspNetCore.Http.Features to additional dependencies or/and even auto-instrumentation "output" (so that it works for .NET Framework as well).

Reference: https://www.nuget.org/packages/OpenTelemetry.Instrumentation.AspNetCore/1.0.0-rc9.4#dependencies-body-tab

pellared avatar Jul 25 '22 05:07 pellared

Microsoft.AspNetCore.Http.Features.dll is located under tracer-home\netcoreapp3.1. I suppose that the issue could be similar to #1027

Kielek avatar Aug 09 '22 09:08 Kielek

Notes:

  • For OTel 1.3.0 the https://www.nuget.org/packages/OpenTelemetry.Instrumentation.AspNetCore/1.0.0-rc9.4#dependencies-body-tab references Microsoft.AspNetCore.Http.Features (>= 3.1.22 && < 4.0.0).
  • There is also newer release (based on OTel 1.4.0-alpha.1 https://www.nuget.org/packages/OpenTelemetry.Instrumentation.AspNetCore/1.0.0-rc9.5#dependencies-body-tab) with the same issues.
  • On the main branch in OTel SDK repository for OpenTelemetry.Instrumentation.AspNetCore there is no direct support for .NET Core 3.1. If needed, it will be supported by netstandard version.

The easiest way to fix the issue, should be to downgrade minimal version Microsoft.AspNetCore.Http.Features in OpenTelemetry.Instrumentation.AspNetCore but I do not see possibility to release 1.0.0-rc9.4.1 with downgraded dependency (rv9.5 is already released). My recommendation is to postpone fix for the issue. Either we drop direct support for .NET Core 3.1 as OTel SDK or the OpenTelemetry.Instrumentation.AspNetCore will contain reference to the older package (2.*) https://github.com/open-telemetry/opentelemetry-dotnet/blob/d1da1d66a3ab4369144e752b47f80dc1f63ae5b3/src/OpenTelemetry.Instrumentation.AspNetCore/OpenTelemetry.Instrumentation.AspNetCore.csproj#L21-L29

@rajkumar-rangaraj, what do you think?

Kielek avatar Aug 16 '22 07:08 Kielek

@Kielek, I agree with you, we should postpone the fix for the issue. The issue happens only with .NET Core 3.1 which will eventually goes out of support by the end of this year.

rajkumar-rangaraj avatar Aug 16 '22 16:08 rajkumar-rangaraj

Postopnned to 0.4.0-beta. I do not think that we will have update for 0.3.0-beta.

Kielek avatar Aug 17 '22 04:08 Kielek

We already shipped the last version with support for .NET Core 3.1 (v0.4.0-beta.1) and have the NuGet package to help with indirect dependencies. Is there anything else to do here?

pjanotti avatar Nov 16 '22 20:11 pjanotti

I think we are good to close it. I suggest to wait for @rajkumar-rangaraj to confirm.

pellared avatar Nov 16 '22 22:11 pellared

Superseded by https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/issues/1644

pellared avatar Nov 23 '22 08:11 pellared