Title: Surface missing or late diagnostics-channel injection instead of silently dropping spans · Issue #25677 · getsentry/sentry-javascript · GitHub
Open Graph Title: Surface missing or late diagnostics-channel injection instead of silently dropping spans · Issue #25677 · getsentry/sentry-javascript
X Title: Surface missing or late diagnostics-channel injection instead of silently dropping spans · Issue #25677 · getsentry/sentry-javascript
Description: Library instrumentation (DB, framework, queue, AI) depends on diagnostics channels being injected, either at runtime (--import / hooks registered in init(), Deno --preload) or at build time (bundler plugins, @sentry/bun/plugin, @sentry/c...
Open Graph Description: Library instrumentation (DB, framework, queue, AI) depends on diagnostics channels being injected, either at runtime (--import / hooks registered in init(), Deno --preload) or at build time (bundle...
X Description: Library instrumentation (DB, framework, queue, AI) depends on diagnostics channels being injected, either at runtime (--import / hooks registered in init(), Deno --preload) or at build time (bundle...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/25677
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Surface missing or late diagnostics-channel injection instead of silently dropping spans","articleBody":"Library instrumentation (DB, framework, queue, AI) depends on diagnostics channels being injected, either at runtime (`--import` / hooks registered in `init()`, Deno `--preload`) or at build time (bundler plugins, `@sentry/bun/plugin`, `@sentry/cloudflare/vite`). When injection does not happen, or happens too late, these libraries produce no spans. HTTP spans still work, so a setup that is only partly instrumented looks healthy to users, and in several cases nothing tells them otherwise unless `debug: true` is set.\n\n### Cases that are currently silent\n\n- **Node: a library is imported before `Sentry.init()`.** `NodeClient` registers the hooks in `init()` (`packages/node/src/sdk/client.ts`), so any instrumented library loaded earlier stays uninstrumented. This happens when users skip `--import`, import a driver in the same file as `init`, or use a framework that loads drivers early (e.g. #23876). Nothing checks for it today.\n- **Bun without `@sentry/bun/plugin`.** Runtime hook registration is skipped with only a `debug.warn` (`packages/server-runtime-injection/src/register.ts`), and `detectOrchestrionSetup()` also only uses `debug.warn`.\n- **Deno without `--preload=npm:@sentry/deno/import`.** Injection only happens in the preload. Deno's `init` does not call `detectOrchestrionSetup()` at all.\n- **Cloudflare without the Vite plugin.** The channel integrations are never registered, and no warning is printed.\n\nOn Node, registration failures and a bundled `@sentry/server-runtime-injection` already warn without `debug`, so these are not covered here.\n\n### Proposal\n\n1. **Warn by default when nothing is injected, on every runtime.** If spans are enabled and neither runtime nor bundler injection ran, `detectOrchestrionSetup()` should warn once through `console.warn` (with `consoleSandbox`) instead of `debug.warn`. Call it from the Bun, Deno and Cloudflare SDKs too, each with its own fix hint (Bun plugin, Deno `--preload`, Cloudflare Vite plugin, Node `--import`). This condition cannot be a false positive: tracing is on and nothing can produce library spans.\n\n2. **Node: warn about instrumented libraries that loaded before `init()`.** When the hooks are registered, scan `require.cache` for paths under `node_modules/\u003cname>/` for every instrumented package name (from the orchestrion configs, see `getModuleNames`). Any match was loaded too early and will not be traced. Warn once and name the libraries, e.g. \"`pg`, `ioredis` were imported before `Sentry.init()` and will not be traced; use `--import …`\". CJS packages imported from ESM also end up in `require.cache`, so this works for ESM apps as well, and most affected packages (pg, mysql2, ioredis, mongodb, express, …) are CJS. ESM-only packages are not detectable this way, and that gap is accepted. The cost is one pass over the cache keys at init.\n\n3. **Report the injection state in SDK metadata.** Attach a general indicator of how the process was instrumented (e.g. `runtime` / `bundler` / `both` / `none`) to the SDK metadata on outgoing envelopes. That lets us measure how common broken or partial setups are, and lets the product surface a hint later. Reporting which individual libraries were instrumented is out of scope here and will be handled separately.\n","author":{"url":"https://github.com/mydea","@type":"Person","name":"mydea"},"datePublished":"2026-10-23T07:11:53Z","url":"https://github.com/getsentry/sentry-javascript/issues/25677"}
| 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:90ad8f72-3072-5aa0-d3fb-6d0fb3df8d8c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AD58:125D11:6EA18:95026:6B042B25 |
| html-safe-nonce | efae8ae1c87f456fc5238d1ba3e2cb8e0bee985cb4d83cc3082bffe51e1cbb1c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRDU4OjEyNUQxMTo2RUExODo5NTAyNjo2QjA0MkIyNSIsInZpc2l0b3JfaWQiOiI3MzU0ODc4Mzc2NTkyODEyODM3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 8c7f774618ab85008f0e03eca1e6ffceb3f9568b4bd8b5e320244784cd5b55b6 |
| hovercard-subject-tag | issue:5993575223 |
| 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/25677/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bb5fb7c82eba2df831490166058dc61b7c15f871fad439b643122eabc373daf4/getsentry/sentry-javascript/issues/25677 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bb5fb7c82eba2df831490166058dc61b7c15f871fad439b643122eabc373daf4/getsentry/sentry-javascript/issues/25677 |
| og:image:alt | Library instrumentation (DB, framework, queue, AI) depends on diagnostics channels being injected, either at runtime (--import / hooks registered in init(), Deno --preload) or at build time (bundle... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mydea |
| hostname | github.com |
| expected-hostname | github.com |
| None | b7a1d2b9101496921b08579fbee988d014345aef2f5bd660d1f8c7332d81560e |
| 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 | c3dd496c3da6ea6b77e69c09279d2b81604654f1 |
| 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