Skip to content

Commit

Permalink
fix: output requestid
Browse files Browse the repository at this point in the history
  • Loading branch information
richenlin committed Jul 31, 2023
1 parent ec4d039 commit b154c9f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: richen
* @Date: 2020-11-20 17:37:32
* @LastEditors: Please set LastEditors
* @LastEditTime: 2023-07-27 23:23:00
* @LastEditTime: 2023-07-31 21:14:46
* @License: BSD (3-Clause)
* @Copyright (c) - <richenlin(at)gmail.com>
*/
Expand Down Expand Up @@ -103,15 +103,15 @@ export function Trace(options: TraceOptions, app: Koatty): Koa.Middleware {
}

let requestId = '';
if (openTrace) {
if (ctx.protocol === "grpc") {
const request: any = ctx.getMetaData("_body")[0] || {};
requestId = `${ctx.getMetaData(requestIdName)[0]}` || <string>request[requestIdName];
} else {
requestId = <string>ctx.headers[requestIdName] || <string>ctx.query[requestIdName];
}
requestId = requestId || GetTraceId(options);

if (ctx.protocol === "grpc") {
const request: any = ctx.getMetaData("_body")[0] || {};
requestId = `${ctx.getMetaData(requestIdName)[0]}` || <string>request[requestIdName];
} else {
requestId = <string>ctx.headers[requestIdName] || <string>ctx.query[requestIdName];
}
requestId = requestId || GetTraceId(options);
if (openTrace) {
let span: Span;
if (tracer) {
const wireCtx = tracer.extract(FORMAT_HTTP_HEADERS, ctx.req.headers);
Expand Down

0 comments on commit b154c9f

Please sign in to comment.