Summary
OpenTelemetry AutoInstrumentation has issues supporting libs with custom bootstrapping, external libs, etc.
I’m researching currently if it’s possible for library authors to address some feedback for better compatibility.
Basic example
There are 2 ways to make automatic instrumentation easier for us to implement:
Activity creation ON by default (Preferred)
A library should always try to create activities by default. If there is no listener, no activities are created (this is System.Diagnostics.DiagnosticSource
behaviour).
Major examples: ASP.NET Core, HttpClient
Activity creation ON by calling initializer
In any case if library authors do not want to create activities by default (overhead caused by architecture, etc), it is the backup behaviour how AutoInstrumentation can still easily wire up activity creation.
A library should contain specialized type for bootstrapping Auto Instrumentation:
namespace OpenTelemetry.AutoInstrumentation;
internal class Initializer
{
public static void EnableAutoInstrumentation(InstrumentationOptions options)
{
// Library owner implements bootstrapping
}
}
Motivation
This proposal is opened for feedback to research generic / easy patterns how to enable automatic instrumentation for libraries.