Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
xr0master opened this issue Oct 11, 2020 · 4 comments
Closed

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

xr0master opened this issue Oct 11, 2020 · 4 comments

Comments

@xr0master
Copy link
Contributor

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.

@kamilogorek
Copy link
Contributor

@xr0master
Copy link
Contributor Author

@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

@xr0master
Copy link
Contributor Author

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

@kamilogorek
Copy link
Contributor

Closed by #2972

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants