0

How can we saved row trace data in any database using openTelemetry and exporter as AddOtlpExporter

below nuget package added in my app OpenTelemetry.Exporter.OpenTelemetryProtocol(1.0.1 OpenTelemetry(1.0.1)

my app is class library with Target Framework .netstandard2.0

 // Enable OpenTelemetry for the sources "Samples.SampleServer" and "Samples.SampleClient"
            // and use OTLP exporter.
             var openTelemetry = Sdk.CreateTracerProviderBuilder()
                    .AddSource("Samples.SampleClient", "Samples.SampleServer")
                    .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("otlp-test"))                   
                    .AddOtlpExporter(opt => opt.Endpoint = new Uri("http://localhost:54300/WeatherForecast/GetTrace"))
                    .Build();

using (var sample = new InstrumentationWithActivitySource())
                {
                    sample.Start();
                }

InstrumentationWithActivitySource : you can find code from link : https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/examples/Console/InstrumentationWithActivitySource.cs

http://localhost:54300/WeatherForecast/GetTrace This simple web api which return string

I would like to revceive trace raw data into this API

Can you please help me how can I receive raw data so that i can save into database. I don't want to use AddZipkinExporter or some other tool to receive trace/log data.

Vasu
  • 1

1 Answers1

0

Otlp exporter export traces through gRPC channel so you need to have gRPC server to receive traces. What you can do is you can use otlp collector in between so your application will send traces to otpl-collector over gRPC channel, and you can configure otlp collector to export traces in HTTP format with help of otlphttp exporter.

Configure your web-service URI in exporter in collector configuration as below.

exporters:
  otlphttp:
    endpoint: https://example.com:55681/v1/traces

Use this proto to deserialize API input and then you can store it in the database in your desired format.

Gaurang
  • 106
  • 7