Skip to content

[@sentry/tracing] Nested express custom middlewares detection #3155

Description

@Pierre-Demessence

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:

newTracing.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.tsconstapp=express();Sentry.init({dsn: "...",integrations: [newTracing.Integrations.Express({ app,methods: ["get"]}),],tracesSampleRate: 1.0,});app.get("/test",someHandler);// first endpointapp.use("/api",require("./api"));// nested router// api.tsconstrouter=express.Router();router.get("/users",someHandler);// second endpointexportdefaultrouter;
  • 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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