Closed
Description
issue
It happens because of event finish
order.
In handler:
https://github.com/getsentry/sentry-javascript/blob/master/packages/node/src/handlers.ts#L65
In express
https://github.com/getsentry/sentry-javascript/blob/master/packages/tracing/src/integrations/express.ts#L121
The handlers
listener fires before express
, as result the last spin has been filtered in:
https://github.com/getsentry/sentry-javascript/blob/master/packages/tracing/src/transaction.ts#L90
because the last span still doesn't have the endTimestamp
2 options to fix this issue:
- use
close
listener instead offinish
inhandlers.ts
. Theclose
event runs afterfinish
.
res.once('close', () => {
transaction.setHttpStatus(res.statusCode);
transaction.finish();
});
- finish all spans if
transaction.finish();
runs
const finishedSpans = this.spanRecorder ? this.spanRecorder.spans
.reduce((spans, s) => {
!s.endTimestamp && s.finish();
s !== this && spans.push(s);
return spans;
}, []) : [];
Let me know which option is best for you.
Metadata
Metadata
Assignees
Labels
No labels