Skip to content

Commit

Permalink
fix: add tags
Browse files Browse the repository at this point in the history
  • Loading branch information
linyyyang committed Feb 21, 2023
1 parent 7e98919 commit 220e45c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
"husky": "^4.x.x",
"jest": "^29.x.x",
"jest-html-reporters": "^3.x.x",
"opentracing": "^0.14.7",
"rollup": "^3.x.x",
"rollup-plugin-typescript2": "^0.x.x",
"standard-version": "^9.x.x",
Expand All @@ -89,6 +88,7 @@
"koatty_core": "^1.x.x",
"koatty_exception": "^1.x.x",
"koatty_lib": "^1.x.x",
"opentracing": "^0.14.7",
"uuid": "^9.0.0"
},
"peerDependencies": {
Expand All @@ -97,4 +97,4 @@
"koatty_exception": "^1.x.x",
"koatty_lib": "^1.x.x"
}
}
}
4 changes: 2 additions & 2 deletions src/index.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-02-21 15:46:15
* @LastEditTime: 2023-02-21 15:58:50
* @License: BSD (3-Clause)
* @Copyright (c) - <richenlin(at)gmail.com>
*/
Expand Down Expand Up @@ -83,7 +83,6 @@ export function Trace(options: TraceOptions, app: Koatty): Koa.Middleware {
const respWapper = async (requestId: string, span?: Span) => {
// metadata
ctx.setMetaData(options.HeaderName, requestId);
span.addTags({ requestIdName: requestId });

if (ctx.protocol === "grpc") {
// allow bypassing koa
Expand Down Expand Up @@ -120,6 +119,7 @@ export function Trace(options: TraceOptions, app: Koatty): Koa.Middleware {
} else {
span = tracer.startSpan(serviceName);
}
span.addTags({ requestId });

return asyncLocalStorage.run(requestId, () => {
const asyncResource = createAsyncResource();
Expand Down

0 comments on commit 220e45c

Please sign in to comment.