Skip to content

Commit

Permalink
Remove check for isWrapped
Browse files Browse the repository at this point in the history
  • Loading branch information
chtushar committed Nov 15, 2023
1 parent 16466d1 commit 0de1b60
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/clients/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@ export const instrumentExpress = (

const routerProto = express.Router as unknown as Express.Router['prototype'];

if (isWrapped(routerProto, 'use')) {
wrap(routerProto, 'use', (original) => {
return function wrappedUse(
this: typeof original,
...args: Parameters<typeof original>
) {
if (!redMiddlewareAdded) {
original.apply(this, [redMiddleware]);
redMiddlewareAdded = true;
}
return original.apply(this, args);
};
});
}
wrap(routerProto, 'use', (original) => {
return function wrappedUse(
this: typeof original,
...args: Parameters<typeof original>
) {
if (!redMiddlewareAdded) {
original.apply(this, [redMiddleware]);
redMiddlewareAdded = true;
}
return original.apply(this, args);
};
});

if (!isWrapped(express.application, 'listen')) {
wrap(
Expand Down

0 comments on commit 0de1b60

Please sign in to comment.