Title: Fastify integration starts a span per hook on unsampled requests · Issue #26710 · getsentry/sentry-javascript · GitHub
Open Graph Title: Fastify integration starts a span per hook on unsampled requests · Issue #26710 · getsentry/sentry-javascript
X Title: Fastify integration starts a span per hook on unsampled requests · Issue #26710 · getsentry/sentry-javascript
Description: Problem Statement With fastifyIntegration, every instance hook, route hook and route handler is wrapped in startSpan, even when the request is not sampled. Those spans are non-recording and never sent, but each still forks the scope, set...
Open Graph Description: Problem Statement With fastifyIntegration, every instance hook, route hook and route handler is wrapped in startSpan, even when the request is not sampled. Those spans are non-recording and never s...
X Description: Problem Statement With fastifyIntegration, every instance hook, route hook and route handler is wrapped in startSpan, even when the request is not sampled. Those spans are non-recording and never s...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/26710
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Fastify integration starts a span per hook on unsampled requests","articleBody":"### Problem Statement\n\nWith `fastifyIntegration`, every instance hook, route hook and route handler is wrapped in `startSpan`, even when the request is not sampled. Those spans are non-recording and never sent, but each still forks the scope, sets an active span and builds its attributes. With 20 no-op hooks and `tracesSampleRate: 0`, a Fastify 5 request takes about 94 µs instead of about 16 µs in a local `app.inject()` benchmark.\n\n### Solution Brainstorm\n\nIn the hook wrapper, run the hook directly when the parent span (the request span, or the active span once it has ended) is not sampled. Sampled requests keep the same spans. The only visible difference is that the skipped spans no longer record a `sample_rate` client outcome.\n\n### Additional Context\n\nI have a change with unit tests ready and would be happy to open a PR if this sounds good.\n\n### Priority\n\n\u003csub>React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it.\u003c/sub>\n","author":{"url":"https://github.com/JonasBa","@type":"Person","name":"JonasBa"},"datePublished":"2026-11-20T17:56:58Z","url":"https://github.com/getsentry/sentry-javascript/issues/26710"}
| 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:3098832f-200b-3454-ed56-ce013351bf7e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CA0E:2F12FE:79DBE0:A144B1:6B04E8D2 |
| html-safe-nonce | 2d1dbaef7696a1468e379ff7e423723b4a9eee0141b3bd6979c7aeae6b7e22dd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTBFOjJGMTJGRTo3OURCRTA6QTE0NEIxOjZCMDRFOEQyIiwidmlzaXRvcl9pZCI6IjQxNDAyMTI0MTA1NzU1NDY1NzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5b4cbcadbcef47885b3808ccf8283c6b2ca7d28172889b8caf3fab35b648f8f3 |
| hovercard-subject-tag | issue:6516879543 |
| 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/26710/issue_layout |
| twitter:image | https://opengraph.githubassets.com/afed6b419e1080f45fb2091c2f8bb15c6178f830aa13420bfba6dded4ef621c6/getsentry/sentry-javascript/issues/26710 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/afed6b419e1080f45fb2091c2f8bb15c6178f830aa13420bfba6dded4ef621c6/getsentry/sentry-javascript/issues/26710 |
| og:image:alt | Problem Statement With fastifyIntegration, every instance hook, route hook and route handler is wrapped in startSpan, even when the request is not sampled. Those spans are non-recording and never s... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JonasBa |
| hostname | github.com |
| expected-hostname | github.com |
| None | f3851aad500d8e8dce736722ddc6fa9596e17d9fce3c53581eba968664c0bc32 |
| 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 | e29c922455fd8137f27e1cfcdf6a1e8b920b1926 |
| 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