Home > OS >  How can I export opentelemetry data into a file without a backend collector for testing
How can I export opentelemetry data into a file without a backend collector for testing

Time:03-09

I have a c# application using OpenTelemetry.

There are different exporters for different backend collectors (like Jaeger)

But in my dev environment, there is no such backend service set up.

Although I can use console exporter, but it will be mixed with my other messages.

I also tried Otlp Exporter

.AddOtlpExporter(options => options.Endpoint = new Uri(@"C:\temp\a.txt"))

but returns the following error

System.NotSupportedException: 'Endpoint URI scheme (file) is not supported. Currently only "http" and "https" are supported.'

It seems that a file schema is not supported at the moment.

Is there any way I can simply output it to a file for easy testing and debugging?

CodePudding user response:

You can always write your own exporter. it should be fairly simple to implement, you can use the console exporter as a template and just write to a file instead of the console.

https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry.Exporter.Console/ConsoleActivityExporter.cs

  • Related