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

OpenTelemetry.AutoInstrumentation fails with console application #3911

Open
wondering639 opened this issue Dec 30, 2024 · 6 comments
Open

OpenTelemetry.AutoInstrumentation fails with console application #3911

wondering639 opened this issue Dec 30, 2024 · 6 comments

Comments

@wondering639
Copy link

Bug Report

Symptom

Describe the bug
Install the NuGet package into a "regular" (no ASP.NET or so) console application, following instructions at https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/blob/main/docs/using-the-nuget-packages.md

Expected behavior
Working instrumentation, however I am unable to start my instrumented application:

You must install or update .NET to run this application.

App: /app/MyApp.dll
Architecture: x64
Framework: 'Microsoft.AspNetCore.App', version '9.0.0' (x64)  <================ Note ASP.NET Core here, though I have a "regular" console application
.NET location: /usr/share/dotnet/

No frameworks were found.

Note the framework Microsoft.AspNetCore.App while I have a "regular" console application. Instrumentation seems to change this. Therefore it is unable to start the application, as only the regular runtime is installed in mcr.microsoft.com/dotnet/runtime:9.0.
This is what is installed in the container and is sufficient when running without instrumentation:

app@image:/app$ dotnet --list-runtimes
Microsoft.NETCore.App 9.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Side note: Interestingly, when using the "shell script installer" https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation?tab=readme-ov-file#shell-scripts everything works. However, as installing the NuGet package is the recommended way and I have access to the source code, I prefer to install the NuGet package instead of using the installer.

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

Runtime environment (please complete the following information):

  • OpenTelemetry Automatic Instrumentation version: OpenTelemetry.AutoInstrumentation 1.9.0
  • OS: Docker image mcr.microsoft.com/dotnet/runtime:9.0
  • .NET version: 9

Additional context
Add any other context about the problem here.

Reproduce

Steps to reproduce the behavior:

  1. Create console application, including Host.CreateApplicationBuilder; based on worker template
  2. Install OpenTelemetry.AutoInstrumentation
  3. Run, in my case inside docker.
  4. Note it will fail to run with instrumentation, expecting a ASP.Net runtime. See Expected behavior for details.
@wondering639
Copy link
Author

Did some further testing with a new project without docker. This makes it also easier to demonstrate the issue:

  1. dotnet new worker
    The dependencies in Jetbrains Rider now look like this:
    image

Once I add OpenTelemetry.AutoInstrumentation, they look like this:
image
Note how frameworks now additionally contains Microsoft.AspNetCore.App.

@RassK
Copy link
Contributor

RassK commented Jan 2, 2025

May try to skip the ASP.NET Core instrumentation
https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/blob/main/docs/using-the-nuget-packages.md#using-the-nuget-packages

... although for sure it's not going to change installed deps.

@wondering639
Copy link
Author

yeah, I think the instrumentation is not the issue, but the dependency on Microsoft.AspNetCore.App. Interestingly the script version seems to have no issues with that, so I hope this can be optimized.

@RassK
Copy link
Contributor

RassK commented Jan 6, 2025

Yes, just the AspNetCore instrumentation should be lazy loaded. At least on the runtime it should not crash then.
NuGet package has to ship with certain dependency requirements, that should be the difference.

SkippedInstrumentations should make it not to load ASP.NET Core as a dependency.

@wondering639
Copy link
Author

Maybe two NuGet packages can be greated, something like
OpenTelemetry.AutoInstrumentation.Console and OpenTelemetry.AutoInstrumentation.AspNet or so?

@RassK
Copy link
Contributor

RassK commented Jan 7, 2025

Unfortunately these are not the only issues. It will bring anyway max set of packages and the dependencies (some by the reference and not physically).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants