Package + Version
@sentry/tracing 5.29.2
Description
At first I had the problem described in #2968 but I saw #2972 and added the methods I wanted to log:
new Tracing.Integrations.Express({ app, methods: ['get', 'post'] }),
This works great, except that it doesn't seem to handle nested middlewares.
I checked the code source and indeed it seems the wrapping only applies to the app or router parameter.
|
router[method] = function(...args: unknown[]): void { |
That means considering a code like this:
// index.ts
const app = express();
Sentry.init({
dsn: "...",
integrations: [
new Tracing.Integrations.Express({ app, methods: ["get"] }),
],
tracesSampleRate: 1.0,
});
app.get("/test", someHandler); // first endpoint
app.use("/api", require("./api")); // nested router
// api.ts
const router = express.Router();
router.get("/users", someHandler); // second endpoint
export default router;
- If we call
/test we'll indeed get middleware.get corresponding to our first endpoint in the list of spans.
- If we call
/api/users we'll only get middleware.use router corresponding to the nested router, but the second endpoint will not appear at all in the list of spans.
Package + Version
@sentry/tracing5.29.2Description
At first I had the problem described in #2968 but I saw #2972 and added the methods I wanted to log:
This works great, except that it doesn't seem to handle nested middlewares.
I checked the code source and indeed it seems the wrapping only applies to the
apporrouterparameter.sentry-javascript/packages/tracing/src/integrations/express.ts
Line 201 in 0ddd74f
That means considering a code like this:
/testwe'll indeed getmiddleware.getcorresponding to our first endpoint in the list of spans./api/userswe'll only getmiddleware.use routercorresponding to the nested router, but the second endpoint will not appear at all in the list of spans.