Spring 引导和 opentelemetry:未实现:未知服务 opentelemetry.proto.collector.metrics。v1.MetricsService

Spring boot and opentelemetry: UNIMPLEMENTED: unknown service opentelemetry.proto.collector.metrics.v1.MetricsService

我正在尝试将 opentelemetry 与 jaeger 集成到我的 spring 引导应用程序中。我在我的本地机器上是 运行 jaeger(以二进制启动而不是 docker),我正在使用以下命令启动我的 spring 启动应用程序:

java -javaagent:/Users/<user-name>/temp/opentelemetry-javaagent-all.jar -Dotel.traces.exporter=jaeger -Dotel.exporter.jaeger.endpoint=localhost:14250 -Dotel.resource.attributes=service.name=playground-app -Dotel.javaagent.debug=false -Dotel.metrics.exporter=jaeger -Dotel.exporter.otlp.endpoint=localhost:14250 -Dotel.exporter.otlp.traces.endpoint=localhost:14250 -Dotel.exporter.otlp.metrics.endpoint=localhost:14250 -jar playground-app-0.0.1-SNAPSHOT.jar

当我到达终点时,我在命令行上收到以下错误:

[opentelemetry.auto.trace 2021-11-15 17:11:29:043 +0530] [grpc-default-executor-0] WARN io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter - Failed to export spans. Error message: UNIMPLEMENTED: unknown service opentelemetry.proto.collector.trace.v1.TraceService

其次是

[opentelemetry.auto.trace 2021-11-15 17:12:08:513 +0530] [grpc-default-executor-0] WARN io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporter - Failed to export metrics io.grpc.StatusRuntimeException: UNIMPLEMENTED: unknown service opentelemetry.proto.collector.metrics.v1.MetricsService at io.grpc.Status.asRuntimeException(Status.java:533) at io.grpc.stub.ClientCalls$UnaryStreamToFuture.onClose(ClientCalls.java:533) at io.grpc.internal.DelayedClientCall$DelayedListener.run(DelayedClientCall.java:464) at io.grpc.internal.DelayedClientCall$DelayedListener.delayOrExecute(DelayedClientCall.java:428) at io.grpc.internal.DelayedClientCall$DelayedListener.onClose(DelayedClientCall.java:461) at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:617) at io.grpc.internal.ClientCallImpl.access0(ClientCallImpl.java:70) at io.grpc.internal.ClientCallImpl$ClientStreamListenerImplStreamClosed.runInternal(ClientCallImpl.java:803) at io.grpc.internal.ClientCallImpl$ClientStreamListenerImplStreamClosed.runInContext(ClientCallImpl.java:782) at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829)

这是 build.gradle

中的依赖项部分
implementation platform("io.opentelemetry:opentelemetry-bom:1.9.0")
implementation platform('io.opentelemetry:opentelemetry-bom-alpha:1.9.0-alpha')

implementation('io.opentelemetry:opentelemetry-api')
implementation('io.opentelemetry:opentelemetry-api-metrics')
implementation group: 'io.opentelemetry', name: 'opentelemetry-proto', version: '1.7.1-alpha'

我在网上找不到关于此问题的任何信息。知道我做错了什么。对于此集成,我没有在我的应用程序中进行任何其他更改。

我的猜测:

-Dotel.metrics.exporter=jaeger 是个问题。我目前只看到了 prometheus metrics exporter(如果您使用的是 https://github.com/open-telemetry/opentelemetry-java-instrumentation)。没有 jaeger 指标导出器。

我也不明白为什么您需要 OTLP 端点(OTLP != Jaeger)。我会删除它们:

-Dotel.exporter.otlp.endpoint=localhost:14250 
-Dotel.exporter.otlp.traces.endpoint=localhost:14250 
-Dotel.exporter.otlp.metrics.endpoint=localhost:14250

简单配置:

-Dotel.traces.exporter=jaeger 
-Dotel.exporter.jaeger.endpoint=http://localhost:14250  
-Dotel.resource.attributes=service.name=playground-app 

作为起点应该没问题。