Skip to content

fix(db): Align db instrumentations to require a parent span - #25879

Draft
nicohrubec wants to merge 7 commits into
developfrom
feat/db-only-if-parent
Draft

nicohrubec wants to merge 7 commits into
developfrom
feat/db-only-if-parent

Conversation

@nicohrubec

@nicohrubec nicohrubec commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Why: Unparented DB queries and cache commands lack application context. Use core's onlyIfParent to align all db instrumentations to only start spans if there is an active parent.

How to review: This adds onlyIfParent: true to all db instrumentations, replacing requiresParentSpan where necessary. Spans that are emitted at server startup (e.g. redis connect spans) where we can assume that in most cases no parent will be active are exempt from this rule.

Closes #25793
Closes #25796
Closes #25798
Closes #25799
Closes #25801
Closes #25802
Closes #25803
Closes #25804
Closes #25805

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 368dc83. Configure here.

Comment thread packages/server-utils/src/integrations/postgres.ts Outdated
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: 3981477 (PR test merge using develop at 53daa00)

Against: 53daa00 (develop) · base run #64191

✅ Baseline matches: this diff contains only this PR's changes.

Path Size % Change Change
@sentry/browser 30.45 kB - -
@sentry/browser - with treeshaking flags 28.56 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.46 kB - -
@sentry/browser (incl. Tracing) 52.8 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 52.8 kB - -
@sentry/browser (incl. Tracing, Profiling) 55.75 kB - -
@sentry/browser (incl. Tracing, Replay) 93.08 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 81.65 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 97.83 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 110.83 kB - -
@sentry/browser (incl. Feedback) 48.02 kB - -
@sentry/browser (incl. sendFeedback) 35.53 kB - -
@sentry/browser (incl. FeedbackAsync) 40.63 kB - -
@sentry/browser (incl. Metrics) 31.46 kB - -
@sentry/browser (incl. Logs) 31.73 kB - -
@sentry/browser (incl. Metrics & Logs) 32.44 kB - -
@sentry/react 32.25 kB - -
@sentry/react (incl. Tracing) 55.1 kB - -
@sentry/vue 38.74 kB - -
@sentry/vue (incl. Tracing) 55.67 kB - -
@sentry/svelte 30.47 kB - -
@sentry/remix (Remix 3 client bundle) 57.83 kB - -
CDN Bundle 32.18 kB - -
CDN Bundle (incl. Tracing) 53.24 kB - -
CDN Bundle (incl. Logs, Metrics) 34.43 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 55.18 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 75.87 kB - -
CDN Bundle (incl. Tracing, Replay) 91.45 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 93.4 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 97.57 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 99.58 kB - -
CDN Bundle - uncompressed 94.62 kB - -
CDN Bundle (incl. Tracing) - uncompressed 157.71 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 101.17 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 163.68 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 232.73 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 279.4 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 285.35 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 293.1 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 299.05 kB - -
@sentry/nextjs (client) 57.94 kB - -
@sentry/sveltekit (client) 53.27 kB - -
@sentry/core/server 44.34 kB - -
@sentry/core/browser 13.95 kB - -
@sentry/node 155.19 kB +0.06% +92 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.67 kB - -
@sentry/node - without tracing 95.92 kB +0.03% +27 B 🔺
@sentry/node - without channel injection 135.86 kB +0.06% +81 B 🔺
@sentry/aws-serverless 104.13 kB +0.05% +46 B 🔺
@sentry/cloudflare (withSentry) - minified 198.06 kB +0.06% +112 B 🔺
@sentry/cloudflare (withSentry) 492.12 kB +0.04% +194 B 🔺
@sentry/nextjs/cloudflare (withSentry) - minified 218.52 kB +0.06% +112 B 🔺

View base workflow run

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Optional E2E tests

Some optional checks were not successful. They do not block the merge. 1 not successful, 56 successful. See the run.

Check Status
❌ CI: Optional E2E Tests / E2E node-anthropic-send-to-sentry (latest) Test (optional) Failing after 3m Details
Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E cloudflare-mastra Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E debug-id-sourcemaps Test (optional) Successful in 24s Details
✅ CI: Optional E2E Tests / E2E cloudflare-think Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable Test (optional) Successful in 42s Details
✅ CI: Optional E2E Tests / E2E node-eve (orchestrion) Test (optional) Successful in 51s Details
✅ CI: Optional E2E Tests / E2E astro-7 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v1 Test (optional) Successful in 23s Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry-static Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 Test (optional) Successful in 23s Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (cloudflare) Test (optional) Successful in 35s Details
✅ CI: Optional E2E Tests / E2E cloudflare-think (ai v6) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-agent Test (optional) Successful in 24s Details
✅ CI: Optional E2E Tests / E2E node-anthropic-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (deno) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 Test (optional) Successful in 32s Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (latest) Test (optional) Successful in 30s Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-pi-durable (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-flue (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-flue-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-flue Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions Test (optional) Successful in 24s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Successful in 35s Details
✅ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-14 (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-eve Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E astro-7-static Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries Test (optional) Successful in 51s Details
✅ CI: Optional E2E Tests / E2E nextjs-orpc Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-openai-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-mastra (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 (tracer provider) Test (optional) Successful in 30s Details
✅ CI: Optional E2E Tests / E2E deno (latest) Test (optional) Successful in 48s Details
✅ CI: Optional E2E Tests / E2E react-router-7-framework-instrumentation Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps Test (optional) Successful in 41s Details
✅ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-mastra Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E node-eve (latest) Test (optional) Successful in 40s Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable (latest) Test (optional) Successful in 24s Details
✅ CI: Optional E2E Tests / E2E solidstart-2 Test (optional) Successful in 47s Details
✅ CI: Optional E2E Tests / E2E vue-3 (no Options API) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions (latest) Test (optional) Successful in 21s Details
✅ CI: Optional E2E Tests / E2E react-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Successful in 38s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (cloudflare, latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-cloudflare Test (optional) Successful in 17s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-openai-send-to-sentry (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E supabase-nextjs Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-pi-durable Test (optional) Successful in 30s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Successful in 57s Details

Comment thread packages/server-utils/src/integrations/mongodb/index.ts
Comment thread packages/server-utils/src/integrations/mongodb/index.ts
nicohrubec and others added 4 commits October 29, 2026 14:33
Co-Authored-By: GPT-6 <codex@openai.com>
Co-Authored-By: GPT-6 <codex@openai.com>
Co-Authored-By: GPT-6 <codex@openai.com>
Co-Authored-By: GPT-6 <codex@openai.com>
Co-Authored-By: GPT-6 <codex@openai.com>
@nicohrubec
nicohrubec marked this pull request as ready for review October 29, 2026 14:48
@nicohrubec
nicohrubec requested review from a team as code owners October 29, 2026 14:48
@nicohrubec
nicohrubec requested review from chargome, isaacs and mydea and removed request for a team October 29, 2026 14:48
const { default: Redis } = await import('ioredis-5');
const redisClient = new Redis({ host: '127.0.0.1', port: 6382, lazyConnect: true });

await redisClient.connect();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This moved into startSpan so that the connect span gets recorded right?

This seems like an annoying downside... I'd assume most users don't have the connect call inside a span. 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes that's the reason. why do you worry about the connect call specifically?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is a special case we can exempt the connect span

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd assume most users call connect on app startup and it will probably not have a parent span. I think we need to exempt here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah sounds reasonable I'll exempt all the connect spans then similar for mysql2 and postgresql

Co-Authored-By: GPT-6 <codex@openai.com>
@nicohrubec
nicohrubec marked this pull request as draft October 29, 2026 17:33

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants