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

Rule checking System.Diagnostics.DiagnosticSource version for net7.0 failing on correct configuration #2950

Closed
pjanotti opened this issue Sep 12, 2023 · 0 comments · Fixed by #2960
Assignees
Labels
bug Something isn't working
Milestone

Comments

@pjanotti
Copy link
Contributor

pjanotti commented Sep 12, 2023

Bug Report

Error log from user shows the issue on net6.0, however, I wasn't able to repro that

Symptom

A correct configuration on .NET 7.0 can result in the rule validating System.Diganostics.DiagnosticSource version incorrectly indicating a version problem. Example: https://cloud-native.slack.com/archives/C01NR1YLSE7/p1694097187958009

This only happens if the runtime is prior to .NET 7.0.4, all others will load a version accepted by the rule. The issue is made more visible via docker because if a cached image of something like mcr.microsoft.com/dotnet/aspnet:7.0 can have an older .NET runtime.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
Log with this problem:

2023-09-07T13:23:45.7884573Z] [Debug] Rule Engine: dotnet is not in the exclusion list. ApplicationInExcludeListRule evaluation success.
[2023-09-07T13:23:46.0068444Z] [Information] Rule Engine: MinSupportedFrameworkRule evaluation success.
[2023-09-07T13:23:46.0132213Z] [Information] Rule Engine: OpenTelemetrySdkMinimumVersionRule evaluation success.
[2023-09-07T13:23:46.0782108Z] [Error] Rule Engine: Application has direct or indirect reference to older version of System.Diagnostics.DiagnosticSource.dll 6.0.2123.36311.
[2023-09-07T13:23:46.0826856Z] [Error] Rule 'System.Diagnostics.DiagnosticSource Validator' failed: Ensure that the System.Diagnostics.DiagnosticSource version is not older than the version used by the Automatic Instrumentation
[2023-09-07T13:23:46.3057769Z] [Error] Error in StartupHook initialization: LoaderFolderLocation: /root/.otel-dotnet-auto/net
Exception: Rule Engine Failure: One or more rules failed validation. Automatic Instrumentation won't be loaded.
System.Exception: Rule Engine Failure: One or more rules failed validation. Automatic Instrumentation won't be loaded.
   at StartupHook.Initialize() in /project/src/OpenTelemetry.AutoInstrumentation.StartupHook/StartupHook.cs:line 47

Runtime environment (please complete the following information):

  • OpenTelemetry Automatic Instrumentation version: 1.0.0
  • .NET version: any .NET release that shipped a version of System.Diganostics.DiagnosticSource smaller than one shipped by auto-instrumentation.

Reproduce

Steps to reproduce the behavior:

  1. Build a console app targeting .NET 7.0 that shipped an version of S.D.DS prior to file version 7.0.423.11508. Disable roll-forward if a .NET runtime with S.D.DS greater than 7.0.423.11508 is available.
  2. Setup auto-instrumentation
  3. Run the console app.

The issue doesn't happen with TFM net6.0 because the AdditionalDeps+SharedStore causes the runtime to load the desired version. The SharedStore for net7.0 doesn't include S.D.DS assembly, since the AdditionalDeps is built using a SDK post+7.0.4, see .

Workarounds

  • Disable the rules by setting the environment variable OTEL_DOTNET_AUTO_RULE_ENGINE_ENABLED to false.
  • Update the runtime to the latest 7.* version. If using docker image like mcr.microsoft.com/dotnet/aspnet:7.0 do a docker pull to update the image to the latest runtime.

Root cause

The rule attempts to load a type from S.D.DS using only the name of the assembly, without a version, and before the AssemblyResolve callback is in place. This causes the application to load the version shipped with the runtime.

@pjanotti pjanotti self-assigned this Sep 12, 2023
@pjanotti pjanotti added the bug Something isn't working label Sep 12, 2023
@pjanotti pjanotti changed the title Rule checking System.Diagnostics.DiagnosticSource version firing on correct configuration Rule checking System.Diagnostics.DiagnosticSource version for net7.0 failing on correct configuration Sep 12, 2023
@rajkumar-rangaraj rajkumar-rangaraj added this to the 1.1.0 milestone Sep 13, 2023
@Kielek Kielek modified the milestones: 1.1.0, 1.0.1 Sep 21, 2023
@Kielek Kielek mentioned this issue Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

3 participants