open-telemetry / opentelemetry-dotnet-instrumentation

OpenTelemetry .NET Automatic Instrumentation

Home Page:https://opentelemetry.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[.NET Fx] Fix redirections for `System.Diagnostics.DiagnosticSource` 4.x

Kielek opened this issue · comments

Azure.Storage.Blobs 12.17.0 and lowers together with dependencies is compiled against System.Diagnostics.DiagnosticSource 4.6.0.
It was changed in 12.18.0 by Azure/azure-sdk-for-net#37418 and bumped to 6.0.1.

Lets consider TestApplication.Azure for 2.17.0 executed on .NET Fx 4.6.2

for our release v1.1.0 without changes

<PackageReference Include="Azure.Storage.Blobs" VersionOverride="$(LibraryVersion)" />  <!-- 12.17.0 compiled against S.D.DS 4.6.0 -->
<PackageReference Include="System.Diagnostics.DiagnosticSource" /> <!-- 7.0.2 -->

In runtime it will load only System.Diagnostics.DiagnosticSource 7.0.2 from local application folder.

For our release v1.1.0 with removed reference to System.Diagnostics.DiagnosticSource

<PackageReference Include="Azure.Storage.Blobs" VersionOverride="$(LibraryVersion)" />  <!-- 12.17.0 compiled against S.D.DS 4.6.0 -->

In runtime it will load System.Diagnostics.DiagnosticSource 7.0.2 from tracer-home folder and 4.x from local application folder.

Lets consider code from this branch, commit: 3d36fed (before Azure test fix)

<PackageReference Include="Azure.Storage.Blobs" VersionOverride="$(LibraryVersion)" />  <!-- 12.17.0 compiled against S.D.DS 4.6.0 -->
<PackageReference Include="System.Diagnostics.DiagnosticSource" /> <!-- 7.0.2 -->

In runtime it will load System.Diagnostics.DiagnosticSource 8.0.0 from tracer-home folder and 7.0.2 from local application folder.

Test azure commit fix: 6a43c05

<PackageReference Include="Azure.Storage.Blobs" VersionOverride="$(LibraryVersion)" />  <!-- 12.17.0 compiled against S.D.DS 4.6.0 -->
<PackageReference Include="System.Diagnostics.DiagnosticSource" Condition=" '$(TargetFramework)' == 'net6.0' " /> <!-- N/A -->
<PackageReference Include="System.Diagnostics.DiagnosticSource" VersionOverride="8.0.0" Condition=" '$(TargetFramework)' == 'net462' and '$(LibraryVersion)' != '' and '$(LibraryVersion)'&lt;'12.18.0' " /> <!-- 8.0.0 -->

In runtime it will load System.Diagnostics.DiagnosticSource 8.0.0 from local application folder.
If we fully remove reference to System.Diagnostics.DiagnosticSource it will work similar to v1.1.0 release. In runtime it will load System.Diagnostics.DiagnosticSource 8.0.0 from tracer-home folder and 4.x from local application folder.

2 versions of the System.Diagnostics.DiagnosticSource are loaded to the same, main, app domain. It leads to the scenario where spans/activities are not registered by OpenTelemetry SDK.

'Azure.Storage.Blobs' 12.18.0+ with dependencies is compiled againsts System.Diagnostics.DiagnosticSource 6.0.1. Redirections seems to be working fine for this version. All expected spans are recorder.

Proposal:

  • Release with fixes from 6a43c05 (test) and e1bafca (documentation)
  • Based on the findings solves the issue with riderecting old System.Diagnostics.DiagnosticSource 4.x to the modern one.

Close per SIG discussion.