opentelemetry-dotnet-instrumentation icon indicating copy to clipboard operation
opentelemetry-dotnet-instrumentation copied to clipboard

Use OTel SDK's self-diagnostics - native code

Open pellared opened this issue 2 years ago • 2 comments

We should take advantage of OTel SDK's self-diagnostics for internal logging and try to adopt it in the native code.

We could do it by emitting EventSource events from the C++ code. Then we would probably need to create guidelines/tools to be able to catch these events in case the process crashes before OTel SDK's self-diagnostic is initialized (as well as to catch events that are emitted before it is initialized). Or we should have a separate mechanism for logging before OTel SDK's self-diagnostic is initialized.

pellared avatar Jul 20 '22 18:07 pellared

The native code has the ability to run before any managed code is loaded/executed. In particular the initialization code of the profiler runs before any managed code is loaded, and those initialization related logs are very important, so the solution that we choose needs to ensure that we can capture those logs.

nrcventura avatar Jul 21 '22 21:07 nrcventura

@nrcventura Q is very relevant. Initially, we could simply have a point at which the native code switches from file to EventSource. Anyway, let's record that the runtime provides support to write EventSource events from a CLR profiler. ICorProfilerInfo12 introduced such support, however, it requires .NET 5.0 and above, so it is not available on any supported .NET Framework version.

pjanotti avatar Nov 08 '22 19:11 pjanotti