Better compatibility with OpenTelemetry AutoInstrumentation

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.

Hi, @Rasmus_Kuusmann,

Thank you for reaching out to us. Integration with OpenTelemetry is a product question and I would encourage you to start up a conversation with our Product Team. @Patrick_Gilfether1 is the PM for the .NET/C# Driver. I’ll ask him to reach out to you to start a discussion.

Sincerely,
James

1 Like

Thanks for reaching out @Rasmus_Kuusmann. I’ve sent you a DM!

1 Like