【发布时间】:2020-06-09 01:01:17
【问题描述】:
我已将 opentracing 添加到我的 Web 应用程序中,并使用 Jaeger 一体化 docker 映像作为收集器。 我在 Windows 10 (hyper-v) 上运行 docker,并且正在使用 Jaeger java 客户端。 当我在主机上本地测试 Web 应用程序时,它成功地将跟踪发送到 Jaeger 收集器 docker 实例。 但是,当我在另一个 docker 容器中运行 Web 应用程序时,Jaeger UI 中没有注册任何痕迹。
我在同一个 docker 网络上尝试了两个容器,但均未成功。 docker 容器中的 web 应用程序可以访问 dockers 中的其他服务,例如数据库和 ETCD 服务器,没有问题。
我认为我可能有错误的端口,但考虑到它在主机环境中工作的事实,我假设这些是正确的并且这是一个 docker 配置问题。 我还将 JAEGER_SAMPLER_TYPE 环境变量设置为 const 并将 JAEGER_SAMPLER_PARAM 设置为 1 以确保记录所有跟踪。
编辑 - 当我查看指标时,似乎 jaeger 正在接收跨度。我对应用程序的每次调用都会将此计数加一。
jaeger_spans_received_total{debug="false",format="proto",svc="datastore",transport="grpc"} 35
jaeger_spans_saved_by_svc_total{debug="false",result="ok",svc="datastore"} 35
jaeger_traces_received_total{debug="false",format="proto",sampler_type="const",svc="datastore",transport="grpc"} 35
jaeger_traces_saved_by_svc_total{debug="false",result="ok",sampler_type="const",svc="datastore"} 35
我还尝试了 Yuri Shkuro 所建议的示例项目Hotrod,以解决某人遇到的类似问题。结果与上面完全相同。指标显示正在接收跨度,但 UI 中未显示任何内容。 编辑 2 - 我已将其范围缩小到发生在 hyper-v windows 10 虚拟机中。
任何帮助将不胜感激。
谢谢
192.168.0.15 是主机
# deployment of jaeger
docker run --name jaeger-collector -d -p 5775:5775/udp -p 6831:6831/udp -p 6832:6832/udp -p 5778:5778 -p 16686:16686 -p 14268:14268 --network mynetwork jaegertracing/all-in-one:latest
# deployment of app
docker run --add-host etcd-01:192.168.0.15 --name datastore -d -it --rm -p 8030:8080 --network mynetwork datastore:latest
在 Java 中设置 Jaeger 跟踪器
private static io.opentracing.Tracer getJaegerTracer() {
Configuration.SamplerConfiguration samplerConfig = Configuration.SamplerConfiguration.fromEnv().withType("const").withParam(1);
Configuration.SenderConfiguration senderConfig = Configuration.SenderConfiguration.fromEnv()
.withAgentHost("192.168.0.15")
.withAgentPort(6831);
Configuration.ReporterConfiguration reporterConfig = Configuration.ReporterConfiguration.fromEnv().withLogSpans(true).withSender(senderConfig);
Configuration config = new Configuration(DatastoreConstants.SERVICE_NAME).withSampler(samplerConfig).withReporter(reporterConfig);
return config.getTracer();
}
【问题讨论】:
-
我想知道您是否有时钟问题,跨度中报告的时间戳与 UI 认为的当前时间不同,因此 UI 发送到服务器的时间窗口与跨度数据不匹配.