Skip to content

Commit 554de8f

Browse files
authored
fix: use originalContext for stats (#89)
1 parent 457ad18 commit 554de8f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/router.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,19 @@ export function setupRoutes(ctx: AppContext, expressApp: Express, routes: AppRou
112112
Object.assign(req.routeInfo, restRouteInfo, {handlerName, authPolicy, enableCaching});
113113

114114
res.on('finish', () => {
115-
if (req.ctx.config.appTelemetryChEnableSelfStats) {
115+
if (req.originalContext.config.appTelemetryChEnableSelfStats) {
116116
const disableSelfStats = Boolean(req.routeInfo.disableSelfStats);
117117

118118
if (!disableSelfStats) {
119-
req.ctx.stats({
119+
req.originalContext.stats({
120120
service: 'self',
121121
action: req.routeInfo.handlerName || UNNAMED_CONTROLLER,
122122
responseStatus: res.statusCode,
123-
requestId: req.ctx.get(REQUEST_ID_PARAM_NAME) || '',
123+
requestId: req.originalContext.get(REQUEST_ID_PARAM_NAME) || '',
124124
requestTime: req.originalContext.getTime(), //We have to use req.originalContext here to get full time
125125
requestMethod: req.method,
126126
requestUrl: req.originalUrl,
127-
traceId: req.ctx.getTraceId() || '',
127+
traceId: req.originalContext.getTraceId() || '',
128128
});
129129
}
130130
}

0 commit comments

Comments
 (0)