Title: [@sentry/tracing] Nested express custom middlewares detection · Issue #3155 · getsentry/sentry-javascript · GitHub
Open Graph Title: [@sentry/tracing] Nested express custom middlewares detection · Issue #3155 · getsentry/sentry-javascript
X Title: [@sentry/tracing] Nested express custom middlewares detection · Issue #3155 · getsentry/sentry-javascript
Description: 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: new Tracing.Integrations.Express({ app, methods: ['get', 'post'] }), This works gre...
Open Graph Description: 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: new Tracing.Integrations.Express({ app, met...
X Description: 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: new Tracing.Integrations.Express({ app, met...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/3155
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[@sentry/tracing] Nested express custom middlewares detection","articleBody":"## Package + Version\r\n`@sentry/tracing` 5.29.2\r\n\r\n## Description\r\n\r\nAt first I had the problem described in #2968 but I saw #2972 and added the methods I wanted to log:\r\n```ts\r\nnew Tracing.Integrations.Express({ app, methods: ['get', 'post'] }),\r\n```\r\nThis works great, except that it doesn't seem to handle nested middlewares.\r\nI checked the code source and indeed it seems the wrapping only applies to the `app` or `router` parameter. https://github.com/getsentry/sentry-javascript/blob/0ddd74f03035c9b4cbbaf8cdd5e7e77fbd7fda46/packages/tracing/src/integrations/express.ts#L201\r\n\r\nThat means considering a code like this:\r\n```ts\r\n// index.ts\r\nconst app = express();\r\n\r\nSentry.init({\r\n dsn: \"...\",\r\n integrations: [\r\n new Tracing.Integrations.Express({ app, methods: [\"get\"] }),\r\n ],\r\n tracesSampleRate: 1.0,\r\n});\r\n\r\napp.get(\"/test\", someHandler); // first endpoint\r\n\r\napp.use(\"/api\", require(\"./api\")); // nested router\r\n\r\n\r\n// api.ts\r\nconst router = express.Router();\r\n\r\nrouter.get(\"/users\", someHandler); // second endpoint\r\n\r\nexport default router;\r\n```\r\n- If we call `/test` we'll indeed get `middleware.get` corresponding to our **first endpoint** in the list of spans.\r\n- 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.","author":{"url":"https://github.com/Pierre-Demessence","@type":"Person","name":"Pierre-Demessence"},"datePublished":"2021-01-07T03:39:41Z","url":"https://github.com/getsentry/sentry-javascript/issues/3155"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c1e886b6-1692-23b4-8965-92ab2008d4dc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D300:3A6B0F:B0F319:FA3D6A:6B04381B |
| html-safe-nonce | 750b451ef9b13c37534f00c447a1fc507292a2bad300286dc37bd06c8d99ca19 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzAwOjNBNkIwRjpCMEYzMTk6RkEzRDZBOjZCMDQzODFCIiwidmlzaXRvcl9pZCI6Ijc1MTA4OTIyODYyMzA5MzU1NzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1313cdb18497397c745e032699f3f4e862aabc4390babef39c3df0efc1790add |
| hovercard-subject-tag | issue:781002252 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/3155/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f42bc9c37a4baa99f140f2cfc2645ca16d11ce6726c5cd1ac3cecf27aebc865c/getsentry/sentry-javascript/issues/3155 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f42bc9c37a4baa99f140f2cfc2645ca16d11ce6726c5cd1ac3cecf27aebc865c/getsentry/sentry-javascript/issues/3155 |
| og:image:alt | 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: new Tracing.Integrations.Express({ app, met... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Pierre-Demessence |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9185ccfefd80c1ff2d9ddcdb0cd2becf46b5a1efbbf30741a895e4bb8de25e64 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 06dc448a76fe4751ac1db26524aefa3aa3e889a8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width