Skip to content

Generated transaction name is wrong with express nested routers #2708

@plaffitt

Description

@plaffitt

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other:

Version:

5.18.1

Description

Using express routers a middlewares, sentry create a transaction name including only the path in the last router.

Here is an example:

const express = require('express');
const Sentry = require('@sentry/node');

const app = express();
Sentry.init({ dsn: 'secret' });

const subRouter = express.Router();

subRouter.get('throw-new-error', (req, res) => {
  throw new Error('An error');
});

app.use(Sentry.Handlers.requestHandler());
app.use('/sub', subRouter);
app.use(Sentry.Handlers.errorHandler());

app.listen(3000, function () {
  console.log('Example app listening on port 3000!');
});

So here, when I GET /sub/throw-new-error, the transaction name will be GET|/throw-new-error instead of GET|/sub/throw-new-error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions