xa-grpc-tracker
xa grpc tracker plugin which can generate a new tracker object for each ctx, ctx.request and ctx.response instance automatically.
Install
$ npm i xa-grpc-tracker --save
Usage
// {app_root}/config/plugin.jsexportsxaGrpcTracker = enable: true package: 'xa-grpc-tracker';
Configuration
// {app_root}/config/config.default.jsexportsxaGrpcTracker = debug: false // 是否开启debug日志 port: 50051 // grpc服务监听端口 url: 'http://10.12.31.175:18166/lqm/spanReport' // 链路监控API地址;
see config/config.default.js for more detail.
Example
// {app_root}/controller/index.js const Controller = Controller; /** * Get tracker class through this.ctx. * * @memberof HomeController */ async { const mockGrpcRequest = dln: 'grpc-dln' span_name: 'server_span_name' span_id: chance parent_id: chance trace_id: chance ; const xaGrpcTracker = thisctx; const trackerServer = thisctx mockGrpcRequest; const span_name = 'client_span_name'; const dln span_id: parent_id trace_id = trackerServertrackerParams; const trackerClient = thisctx dln span_name parent_id trace_id ; trackerServer; // some async calls... trackerClient; // some sync calls... trackerClient; // some sync calls... trackerServer; thisctxbody = trackerServertrackerParams; } moduleexports = HomeController;
Questions & Suggestions
Please open an issue here.