我正试图在node-js项目中实现Jaeger。我已经在k8s中部署了这个node-js项目(使用docker映像(和Jaegaer(kubectl create-fhttps://raw.githubusercontent.com/jaegertracing/jaeger-kubernetes/master/all-in-one/jaeger-all-in-one-template.yml)
两者都单独工作,但在服务中看不到痕迹
var initTracer = require('jaeger-client').initTracer;
const opentracing = require("opentracing");
const bodyParser = require('body-parser');
var config = {
'serviceName': 'user-service',
'local_agent': {
'reporting_host': 'jaeger',
'reporting_port': '6831',
},
'reporter': {
'logSpans': true
},
'sampler': {
'type': 'probabilistic',
'param': 1.0
}
};
var options = {
'tags': {
'user-service': '1.1.2'
}
};
var tracer = initTracer(config, options);
opentracing.initGlobalTracer(tracer);
console.log(tracer);
const express = require('express');
const app = express();
app.use(bodyParser.json({ type: 'application/*+json' }));
app.get('/users/:id',(req, res) => {
const span = tracer.startSpan('get user by user_id');
res.send(JSON.stringify('hello'));
span.log({'event': 'request_end'});
span.finish();
});
// Set up server
const server = app.listen(8000, () => {
let host = server.address().address;
let port = server.address().port;
console.log('Service_1 listening at http://%s:%s', host, port);
});
您是否尝试过查看pod生成的日志?
就我而言,我得到了以下
ERROR无法刷新报告程序中的跨度:通过UDP发送跨度时出错:错误:getaddrinfo ENOTFOUNDhttp://jaeger-agent,数据包大小:984,发送的字节数:未定义
将其更改为jaeger代理对我有效。
如果有帮助的话,我已经在docker-compose.yml:中的jaeger图像下声明了这一点
+ ports: - "5775:5775/udp" - "6831:6831/udp" - "6832:6832/udp" - "5778:5778" - "16686:16686" - "14268:14268" - "9411:9411"`