Skip to content

Reducing transitive dependency closure of System.Diagnostics.DiagnosticSource #42244

@macrogreg

Description

@macrogreg

This is a question / suggestion / request about the current RC of System.Diagnostics.DiagnosticSource.

Auto-instrumentation scenarios require an in-proc agent / tracer to load DiagnosticSource dynamically while performing non-trivial logic to avoid potential versioning conflicts with assemblies referenced by the application being instrumented. The logic would be considerably simpler and more robust if the DiagnosticSource-assembly itself did not have any additional dependencies.

On the recent NetFx and Net Core versions the System.Diagnostics.DiagnosticSource-NuGet depends on System.Memory.(When targeting older Net Core and Net Standard flavors there are more NuGet dependencies.) In turn, System.Memory requires (depending on the targeted runtime version): System.Runtime.CompilerServices.Unsafe, System.Buffers and System.Numerics.Vectors. Older runtime flavors require more.

I am guessing that the dependencies are on actor types rather than on data exchange types on public APIs. If so, it should be possible to build the types that are referenced from System.Memory and System.Runtime.CompilerServices.Unsafe directly into the DiagnosticSource-assembly (copy code or, better, just reference the respective sources at Framework build time). That way DiagnosticSource-assembly would not contain any downstream dependencies.

This would considerably simplify scenarios where an auto-instrumentation agent needs to dynamically load DiagnosticSource (and all its dependencies) without causing versioning conflicts with the instrumented application.

@noahfalk and @davmason have context on the related discussion in the OTel SIG.

This should be a build-logic change only. Can this be considered for Net 5?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions