Skip to content

Commit e58a8de

Browse files
committed
ref: Mark failed transactions
1 parent 74eacc0 commit e58a8de

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

packages/node/src/handlers.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ export function tracingHandler(): (
3737
hub.configureScope(scope => {
3838
scope.setSpan(transaction);
3939
});
40-
res
41-
.once('response', () => transaction.setSuccess())
42-
.once('error', () => transaction.setFailure())
43-
.once('finish', () => transaction.finish());
40+
res.once('finish', () => {
41+
if (res.statusCode >= 500) {
42+
transaction.setFailure();
43+
} else {
44+
transaction.setSuccess();
45+
}
46+
transaction.finish();
47+
});
4448
next();
4549
};
4650
}

packages/node/src/integrations/http.ts

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ function createHandlerWrapper(
9292
if (breadcrumbsEnabled) {
9393
addRequestBreadcrumb('response', requestUrl, this, res);
9494
}
95+
// TODO: Mark >= 500 as failed as well?
9596
if (tracingEnabled) {
9697
span.setSuccess();
9798
span.finish();

0 commit comments

Comments
 (0)