Skip to content

[@sentry/tracing] Express custom middleware detection #2968

Description

@xr0master

Package + Version

@sentry/tracing 5.25.0

Description

The Performance is great at catching request, but does not detect custom middleware at all. I saw in the documentation how to manually add spans, but how to automate the process? How was express.json tagged as middleware/jsonParser?

Here is init

app.use(Sentry.Handlers.requestHandler());
app.use(Sentry.Handlers.tracingHandler());
app.use(express.json({limit: '25mb'}));
app.use(Sentry.Handlers.errorHandler());

This is an example with several custom middleware.

app.post('/api/send,
  UserController.isAuthenticated,
  SendEmailController.send,
  UserController.saveUserInCache,
);

Unfortunately, these middleware are not included in the report.
image

Thank you.

Activity

  1. kamilogorek commented on Oct 12, 2020

    @kamilogorek
    Contributor
  2. xr0master commented on Oct 12, 2020

    @xr0master
    ContributorAuthor

    @kamilogorek thank you, I see. Why is the wrapper for use only?
    By analogy, I added a wrapper for POST and everything worked just fine.

    var originalAppPost = app.post;
    app.post = function () {
          // eslint-disable-next-line prefer-rest-params
          return originalAppPost.apply(this, wrapUseArgs(arguments));
    };

    The graph looks great.
    image

  3. xr0master commented on Oct 12, 2020

    @xr0master
    ContributorAuthor

    Before that, the graph looked very sad, it was impossible to identify the problem.
    image

  4. kamilogorek commented on Oct 19, 2020

    @kamilogorek
    Contributor

    Closed by #2972

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