我无法使用 httpprotobuf 协议发送数据,但使用 grpc 协议一切正常
otel.WithTracing(tracing =>
{
tracing.AddAspNetCoreInstrumentation();
tracing.AddHttpClientInstrumentation();
tracing.AddSource("CustomActivityName");
tracing.AddOtlpExporter(otlpOptions =>
{
otlpOptions.Endpoint = new Uri("http://otel-url:4318/");
otlpOptions.Protocol = OtlpExportProtocol.HttpProtobuf;
});
tracing.AddConsoleExporter();
});
我有点困惑,因为我没有看到任何错误日志
根据出口商自述文件:
使用 OtlpExportProtocol.HttpProtobuf 时,必须提供完整的 URL,包括信号特定的路径 v1/{signal}。例如,对于跟踪,完整的 URL 将类似于 http://your-custom-endpoint/v1/traces。
在你的情况下,这将是:
otel.WithTracing(tracing =>
{
tracing.AddAspNetCoreInstrumentation();
tracing.AddHttpClientInstrumentation();
tracing.AddSource("CustomActivityName");
tracing.AddOtlpExporter(otlpOptions =>
{
otlpOptions.Endpoint = new Uri("http://otel-url:4318/v1/traces");
otlpOptions.Protocol = OtlpExportProtocol.HttpProtobuf;
});
tracing.AddConsoleExporter();
});