如何使用 OpenTelemetry 和 Main App 在任何数据库中保存行跟踪数据

问题描述

我们如何使用 openTelemetry 和导出器作为 AddOtlpExporter 在任何数据库中保存行跟踪数据

在我的应用程序中添加了以下 nuget 包 OpenTelemetry.Exporter.OpenTelemetryProtocol(1.0.1 OpenTelemetry(1.0.1)

我的应用程序是带有 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 : 您可以从链接中找到代码: https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/examples/Console/InstrumentationWithActivitySource.cs

http://localhost:54300/WeatherForecast/GetTrace 这个简单的 web api 返回字符串

我想将跟踪原始数据接收到此 API 中

你能帮我如何接收原始数据以便我可以保存到数据库中吗? 我不想使用 AddZipkinExporter 或其他一些工具来接收跟踪/日志数据。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)