distributed-trace-for-nodejs
v1.0.5
Published
this is a inner module of nodejs, record express route to zipkin
Downloads
7
Readme
本包用来对node的express项目进行zipkin跟踪。
使用方法:
1.添加npm包依赖
"distributed-trace-for-nodejs":"1.0.4"
2.添加代码
var zipkin = require("distributed-trace-for-nodejs");
zipkin.init({
zipkinUrl : "http://172.19.100.22:9001",
serviceName : "eageye_rest"
});
3.在合适的位置添加express路由
app.all("*" , zipkin.trace);
4.在向外部发送rest请求的请求头中添加spanid和traceid
requestHeaders = zipkin.toRequestHeader(req , requestHeaders);
其中req是express的request对象,requestHeaders是请求头对象
特殊说明:
init中支持的选项:
//服务器端口号,不传的时候使用 req.socket.localPort 获取
port : 80,
//是否在控制台上打印,方便调试
debugTrace : false,
//记录到zipkin的项目标识,一般写作xxx_rest,其中xxx是项目名
serviceName : "rest",
//zipkin的post接口地址
zipkinUrl : "http://172.19.100.22:9001"