Closed
Description
Important Details
How are you running Sentry? @sentry/node@5.15.4
Environment: N/A, can reproduce both locally, in docker and anywhere else
Description
When doing:
const router = new Router();
router.get('/bar', (req, res, next) => { next(new Errror('Foo')); });
app.use('/foo', someOtherRouter);
sentry would set the event.transaction
to /bar
as this is what req.url
will point to.
See this doc.
https://expressjs.com/en/api.html#req.originalUrl
Steps to Reproduce
- Setup routing using express router https://expressjs.com/en/api.html#router
- Handle an exception thrown from the router.
- event.transaction (and issue title in Sentry) will include only the router's part of the URL
What you expected to happen
Given my example in the description, I would expect to see full URL:
GET|/foo/bar
Possible Solution
Sentry should try to get the URL from req.originalUrl
. I am currently using this workaround:
const sentryRequestHandler = Sentry.Handlers.requestHandler();
app.use((req, res, next) => {
sentryRequestHandler(req, res, () => {
Sentry.getCurrentHub().configureScope(scope => {
scope.addEventProcessor((event) => {
event.transaction = `${req.method}|${req.originalUrl}`;
return event;
});
});
next();
});
});
This is patching the transaction to use .originalUrl
Metadata
Metadata
Assignees
Labels
No labels