Skip to content

Commit

Permalink
chore: review comments resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
aryamohanan committed Aug 8, 2024
1 parent 0f90dd5 commit 68e05d1
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions packages/core/src/tracing/instrumentation/frameworks/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ exports.init = function init() {
};

function instrument(express) {
// capture the uncaught error
if (express.Router && express.Router.handle && express.Router.use) {
// express 4
// capture the uncaught error
shimmer.wrap(express.Router, 'handle', shimExpress4Handle);
shimmer.wrap(express.Router, 'handle', shimExpressHandle);
shimmer.wrap(express.Router, 'use', shimExpress4Use);
} else if (express.Router && express.Router.prototype) {
// express v5 beta
shimmer.wrap(express.Router.prototype, 'handle', shimExpressHandle);
shimmer.wrap(express.Router.prototype, 'use', shimExpress4Use);
}

if (express.Route && express.Route.prototype) {
Expand All @@ -44,15 +48,9 @@ function instrument(express) {
}
});
}
if (express.Router && express.Router.prototype) {
// express v5 beta
// capture the uncaught error
shimmer.wrap(express.Router.prototype, 'handle', shimExpress4Handle);
shimmer.wrap(express.Router.prototype, 'use', shimExpress4Use);
}
}

function shimExpress4Handle(realHandle) {
function shimExpressHandle(realHandle) {
return function shimmedHandle() {
const args = [];
for (let i = 0; i < arguments.length; i++) {
Expand Down

0 comments on commit 68e05d1

Please sign in to comment.