-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[7.108.0] Sentry.Handlers.tracingHandler uses incorret route name in Express server #11337
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
Comments
Hello, in the upcoming v8 version we use a new instrumentation base, where this may (or may not, hard to say) be fixed already. Could you give it a try with |
I'm using |
Hey @mydea we've got the same problem on basically the same setup (express, node, version 7 of Sentry, etc.). I tried to move over to version 8 alpha so I could tell you if its working or not, but I can't even figure out how to set v8 up for node. Can you help me with the v8 equivalent of this setup block? Almost all of the integration paths are no longer importable, and I was able to figure most of that part out by moving the paths around, but the middlewares for app.use seem completely gone in v8? Also does the express integration no longer require the app (the express router) parameter in the new version?
Also the link here for how to set this up is completely dead 😢 |
Circling back a few hours later, the doc I needed was here . This is indeed fixed in the v8 alpha. Is there any chance that whatever fixed the transaction name grouping can get ported back into v7? Unless v8 is close to a full release, this is a pretty big breakage in the most recent v7. |
Hey, sadly the code for this is completely different in v8 than it was in v7. So it is hard to backport this, I fear. However, a full release of v8 shouldn't be too far off - we are planning to release a beta in the next week or so! |
This was noticed here: #11337 (comment), when viewed on e.g. npmjs.org the relative links to do not work, so we should have full URLs only in the readme files. It would be _nicer_ if we could replace this with a proper full URL at release time to point to the correct version of the file, but that's more work and probably not worth it...
FYI: Issue is not fixed with |
We have just released v8.0.0-beta.1 - could you give that a try and let us now if it works for you as expected on that version? |
This was noticed here: getsentry#11337 (comment), when viewed on e.g. npmjs.org the relative links to do not work, so we should have full URLs only in the readme files. It would be _nicer_ if we could replace this with a proper full URL at release time to point to the correct version of the file, but that's more work and probably not worth it...
@mydea I can confirm that route names are correctly identified in I'm using instrument.jsimport * as Sentry from '@sentry/node'
Sentry.init({
dsn: process.env.SENTRY_DSN,
enabled: Boolean(process.env.SENTRY_DSN),
release: process.env.npm_package_version,
environment: process.env.SENTRY_ENV,
serverName: process.env.SERVER_ID,
sampleRate: 1,
tracesSampler: (samplingContext) => {
console.log('[Sentry] transactionContext', samplingContext.transactionContext)
return 1
},
}) The log messages, while showing much more activity than v7, seems to identify the route name correctly: Example app listening on port 3000
[Sentry] transactionContext { name: 'GET', parentSampled: undefined }
[Sentry] transactionContext { name: 'middleware - query', parentSampled: true }
[Sentry] transactionContext { name: 'middleware - expressInit', parentSampled: true }
[Sentry] transactionContext { name: 'router - /', parentSampled: true }
[Sentry] transactionContext { name: 'request handler - /test/:first/:second', parentSampled: true }
[Test Route] { 'req.route.path': '/test/:first/:second' }
[Test Route] { 'req.originalUrl': '/test/foo/bar/' } However, on my production app I run into the "SDK fails in ESM mode in combination with date-fns" error and had to disable the instrumentation 😢: #12154 |
Thank you for the feedback! It's good to hear that this is generally resolved. |
We've fixed the |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
7.108.0
Framework Version
Node 18, Express 4.19.2
Link to Sentry event
SDK Setup
Steps to Reproduce
node -r dotenv/config index.js
.GET http://127.0.0.1:3000/test/hello/world
.Expected Result
I expect the Sentry Trace to use the route name
/test/:first/:second
.Actual Result
The Sentry Trace uses the originalUrl
/test/hello/world
instead of the router path name.As an effect, the performance dashboard is nearly useless, because all requests are filed under different names.
Observations:
extractPathForTransaction
is called twice (https://github.com/getsentry/sentry-javascript/blob/7.108.0/packages/tracing-internal/src/node/integrations/express.ts), first for thesentryTracingMiddleware
without thereq.route
being undefined, second for theinstrumentRouter
function with thereq.route
being correct.extractPathForTransaction
-> https://github.com/getsentry/sentry-javascript/blob/7.108.0/packages/utils/src/requestdata.ts#L107sentryTracingMiddleware
-> https://github.com/getsentry/sentry-javascript/blob/7.108.0/packages/node/src/handlers.ts#L45instrumentRouter
-> https://github.com/getsentry/sentry-javascript/blob/7.108.0/packages/tracing-internal/src/node/integrations/express.ts#L278The text was updated successfully, but these errors were encountered: