Repository navigation
Closed
Description
Summary
Upgrade @sentry/node and @sentry/nitro from 10.65.0 to v11 (11.9.0 or later). v11 replaces import-in-the-middle with channel-based instrumentation (orchestrion) and changes several init options. Use build-time instrumentation in the Nitro build instead of a runtime --import hook.
Migration guide: https://docs.sentry.io/platforms/javascript/guides/node/migration/v10-to-v11/
Problems to solve
1. Build-time instrumentation
@sentry/nitro'swithSentryConfigadds only source maps and the Nitro request channel. It does not instrument libraries.juniorNitro()must add the orchestrion Rollup plugin. Options:sentryOrchestrionPluginfrom@sentry/server-utils/orchestrion/rollup. This needs@sentry/server-utilsas a direct dependency, pinned to the same version as@sentry/node.sentryRollupPluginfrom@sentry/node/rollup. This also adds the source map plugin, which duplicates the@sentry/nitroupload.
- Remove the
bundleOpenTelemetryLoaderHooksworkaround. v11 does not useimport-in-the-middle. nitro devdoes not bundlenode_modules, so dev gets no library instrumentation. The current--import ./instrument.mjsdoes not give it under v11 either.- Remove
instrument.mjs,cross-env, andNODE_OPTIONS=--importfrom the example app and thejunior initscaffold.server.tsalready callsinitSentry()first.
2. Data collection (sendDefaultPii → dataCollection)
- v11 removes
sendDefaultPii. WhendataCollectionis not set, v11 collects more data than v10. - Collect only incoming request bodies (
httpBodies: ["incomingRequest"]). Outgoing calls carry model prompts and provider responses that the payload filter does not see. - Set
databaseQueryData: falseso that query spans never carry parameter values. - Decide if cookie, header, and user-info defaults are correct.
3. Removed and changed options
- Remove
traceLifecycle,registerEsmLoaderHooks,streamGenAiSpans, andenableLogs. - Keep
SENTRY_ENABLE_LOGS=falsebehavior: drop logs inbeforeSendLog. withStreamedSpanis a no-op.beforeSendTransactionhas no effect in stream mode. Remove the transaction scrubber.beforeSendSpanreceivesStreamedSpanJSON, which usesname,attributes, and statusokorerror. Update the tests that readdescriptionordata.StartSpanOptions.kindis removed.
4. Database spans
- v11 auto-instruments
pg,pg-pool, and Neon. Ifdb/tracing.tsstays, each query gets duplicate spans. - Proposal: remove
db/tracing.tsand use the automatic spans. - The query text is the same in both, and neither records parameter values.
- The automatic spans lose these attributes:
- the PostgreSQL error code (
db.response.status_code) db.operation.name(feat(server-utils): Setdb.operation.nameon SQL spans sentry-javascript#25850 adds it)db.collection.nameapp.db.driver
- the PostgreSQL error code (
- The automatic spans add
pg-pool.connectandpg.connectspans,db.user, anddb.connection_string.
5. Model call (gen_ai) spans
- Junior calls models through
pi-ai.pi-aicallsclient.beta.messages.create(...).asResponse()and parses the SSE stream itself. - Because of this, the automatic Anthropic span has no token usage, output, or finish reason. It never records cost.
- The Sentry SDK has no
pi-aiintegration. Thepi-aiusage helpers are used only by thepi-durableandflueintegrations. - Keep the manual
gen_aispans. They are the only source of tokens and cost. - Disable the automatic AI provider integrations (Anthropic, OpenAI, Google, Mistral). Each model call now produces two
gen_ai.chatspans. - Track the upstream
pi-aiintegration: feat(server-utils): Add pi-ai integration sentry-javascript#25869. When it is released, remove the filter and decide if the manualgen_aispans can go.
6. Other manual instrumentation to remove
- Remove the
http.server.requestwebhook span. The automatichttp.serverspan replaces it. - Remove the
GET files.slack.comspan. The automatic fetch span replaces it. - Keep the Slack Web API retry spans. Slack sends errors in 200 responses, so only these spans carry
app.slack.api_error_code. - Keep the sandbox egress span. It controls trace continuation.
withSpan: Sentry sets the error status when a callback throws, but it does not seterror.type.- Keep the
error.typecatch. - Do not overwrite an
error.typethat the callback already set. The current code replaces values such asrate_limitedwith the error name. - Remove
setSpanStatus("error")calls that come immediately before athrow.
- Keep the
7. Telemetry contract and dashboards
- Update
TELEMETRY.mdand the docs observability page (database and webhook sections). - v11 renames span ops and attributes (for example
http.methodandgen_ai.system) and uses low-cardinality span names. Update the saved queries, alerts, dashboards, and sampling rules. captureMessagenow attaches stack traces by default. This can create new issue groups.
8. Lockfile
pnpm installleaves@sentry/node@10.65.0in the injected workspace package snapshots. Prune the orphaned entries.- Use the pinned pnpm (11.8.0).
Verification
- Build the example app and run
check-vercel-output.mjs. - Run the build with
SENTRY_DEBUG=1. ConfirmBundler plugin ran, injected libraries=[...]. The list must includehono,pg,@neondatabase/serverless, and@anthropic-ai/sdk. - Deploy a Vercel preview. Confirm that spans, logs, and errors reach the project.
Metadata
Metadata
Assignees
Labels
No labels
Activity
feat(sentry): Upgrade Sentry SDKs to v11