You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fastify integration starts a span per hook on unsampled requests #26710
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, 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.
Solution Brainstorm
In 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.
Additional Context
I have a change with unit tests ready and would be happy to open a PR if this sounds good.
Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
Activity
linear-code commentedon Nov 20, 2026
JS-4138