Closed
Description
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.
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 getmiddleware.get
corresponding to our first endpoint in the list of spans. - If we call
/api/users
we'll only getmiddleware.use router
corresponding to the nested router, but the second endpoint will not appear at all in the list of spans.