Bha*_*esh 8 node.js istio jaeger
我有 3 个服务 A、B 和 C。我编写了调用 A -> B -> C 的 API。我已经按照 Istio 官方文档(https://istio.io/latest/docs/tasks )中给出的方式安装了 Jaeger /可观察性/分布式跟踪/jaeger/)。我的 Jaeger 仪表板已启动,它也显示了跟踪,但没有任何跟踪的跨度超过 2 个。我可以在 Docker 桌面日志中看到我的 API 正在跨服务调用。
我尝试在所有 NodeJS 服务中设置 jaeger-client 。我尝试了https://github.com/jaegertracing/jaeger-client-node上给出的 prom-client 代码(我还使用 istio 插件安装了 grafana、kiali 和 prometheus)。这也不起作用,然后我尝试了https://edspencer.net/2020/10/13/distributed-tracing-with-node-js/中给出的传播标头。这是我添加的代码:
const {initTracer} = require('jaeger-client')
const app = express();
const config = {
serviceName: 'service-a',
reporter: {
logSpans: true,
collectorEndpoint: 'http://jaeger-collector.istio-system.svc:14268/api/traces',
},
sampler: {
type: 'const',
param: 1
}
};
const options = {
tags: {
'gateway.version': '1.0.0'
}
};
const tracer = initTracer(config, options);
app.use((req, res, next) => {
req.rootSpan = tracer.startSpan(req.originalUrl)
tracer.inject(req.rootSpan, "http_headers", req.headers)
res.on("finish", () => {
req.rootSpan.finish()
})
next()
})
Run Code Online (Sandbox Code Playgroud)
但这也没有帮助。Jaeger 仪表板上的痕迹与没有这些解决方案时出现的痕迹相同。
我认为 istio sidecar 应该自动向 jaeger 发送痕迹,但我不确定。有人在 Istio 中使用 NodeJS 中的服务设置 Jaeger 吗?请帮忙。
| 归档时间: |
|
| 查看次数: |
737 次 |
| 最近记录: |