项目依赖egg框架,用alinode做的性能监控,alinode已开启,慢http日志已经有数据了,Trace一直无数据,按照阿里提供的文档https://help.aliyun.com/document_detail/72715.html,装入了文档里面的依赖,因为项目没有使用express,按照文档实例代码仿写一直未成功,请问有没有egg项目开启 Trace 的例子代码
Proposal这是在一个接口里面仿写的一段代码 `async all_timeout() { const { ctx } = this;
let req=this.ctx.request;
req.parentSpan = tracer.startSpan('根模块');
req.parentSpan.setTag(opentracing.Tags.PEER_HOSTNAME, req.hostname);
req.parentSpan.setTag(opentracing.Tags.HTTP_METHOD, req.method.toUpperCase());
req.parentSpan.setTag(opentracing.Tags.HTTP_URL, req.url);
let res =await ctx.service.repository.getAll(3000)
req.parentSpan.setTag(opentracing.Tags.HTTP_STATUS_CODE, res.statusCode);
req.parentSpan.finish(req);
let spanName = `${ctx.method} ${ctx.url}`;
const spanOptions = {
tags: {
[opentracing.Tags.HTTP_METHOD]: ctx.method,
[opentracing.Tags.HTTP_URL]: ctx.href,
},
};
const span = tracer.startSpan(spanName, spanOptions)
span.setTag('span.kind', 'server');
span.finish(req);
this.ctx.body=res
}`
按此方法执行控制台会提示 span.finish without request will cause some problem, please use "span.finish(req)..."