Home > Enterprise >  How to test OpenTelemetry console exporter on web api dll application
How to test OpenTelemetry console exporter on web api dll application

Time:01-27

I have strange situation where I need to test OpenTelemetry on old, soon to be decommissioned Web API, that is written in .NET 4.6.2. To be worse, it is DLL application, it is not exe. By running it from Visual Studio 2019, I don't see any traces in Output window in Visual Studio after I hit application's endpoint (I get result in Postman, though).

So, I am not sure if I configured everything properly, even though I followed official documentation. So far, I guess that I am not testing it properly, but I am not sure how to run this application in console, similar as .NET Core apps are run with dotnet run command.

Does anyone have an idea how to test it?

I know that this is kinda general question, but I am interested whether someone had similar experience with OpenTelemetry and .NET 4.6.2.

Any suggestion is more than welcome.

CodePudding user response:

I hope this information finds well someone who is working on soon to be decommissioned software that needs to be observed with OpenTelemetry.

What I had to do is:

_tracerProvider = Sdk.CreateTracerProviderBuilder().AddAspNetInstrumentation().AddConsoleExporter(options =>
            {
                options.Targets = OpenTelemetry.Exporter.ConsoleExporterOutputTargets.Debug;
            }).Build();

AddAspInstrumentation() had to be added. And to mention that trace provider is declared on the beginning of the class.

This part:

options.Targets = OpenTelemetry.Exporter.ConsoleExporterOutputTargets.Debug; 

Enables logging information in the Output (Debug) window. And this was my biggest problem, but going through definitions of the classes with my colleagues one by one showed that still there are possibilities and that people from OpenTelemetry had this in mind.

  • Related