Skip to content

feat(server-utils): Migrate FirebaseInstrumentation to orchestrion#22141

Draft
mydea wants to merge 3 commits into
developfrom
feat/firebase-orchestrion
Draft

feat(server-utils): Migrate FirebaseInstrumentation to orchestrion#22141
mydea wants to merge 3 commits into
developfrom
feat/firebase-orchestrion

Conversation

@mydea

@mydea mydea commented Jul 9, 2026

Copy link
Copy Markdown
Member

Rewrites the Firebase integration off InstrumentationBase to an orchestrion diagnostics-channel listener in @sentry/server-utils, following the mysql (#20900) and graphql (#21885) migrations. The channel-based integration reuses the OTel Firebase name, so opting in via experimentalUseDiagnosticsChannelInjection() swaps it in 1:1 for the OTel one (which stays the default).

Firestore — subscribes to orchestrion:@firebase/firestore:{add,get,set,delete}-doc (injected into firestore's lite addDoc/getDocs/setDoc/deleteDoc) and emits the same db.query client spans via bindTracingChannelToSpan, with a distinct auto.firebase.orchestrion.firestore origin.

firebase-functions — the onX(...) provider functions register a handler and return synchronously, so the span can't be bound to the registration call. Instead the channel start subscriber rewraps the handler argument (orchestrion forwards the mutated args array to the real call), so the returned cloud function opens a SERVER span + error boundary on invocation, with auto.firebase.orchestrion.functions origin.

The node-firebase e2e firestore suite additionally runs with E2E_ORCHESTRION=true to assert the orchestrion origin.

Closes #20919

🤖 Generated with Claude Code

mydea and others added 3 commits July 9, 2026 14:44
Adds an orchestrion diagnostics-channel `Firebase` integration in
`@sentry/server-utils`, replacing the `InstrumentationBase` approach when
`experimentalUseDiagnosticsChannelInjection()` is enabled (swapping in 1:1 for
the OTel `Firebase` integration by name).

- Firestore: subscribes to `orchestrion:@firebase/firestore:{add,get,set,delete}-doc`
  and emits the same `db.query` spans via `bindTracingChannelToSpan`, with a
  distinct `auto.firebase.orchestrion.firestore` origin.
- firebase-functions: subscribes to `orchestrion:firebase-functions:*` and
  rewraps the handler argument of each `onX(...)` registration in the channel's
  `start` so the returned cloud function opens a SERVER span + error boundary on
  invocation, with `auto.firebase.orchestrion.functions` origin.

Closes #20919

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mydea

mydea commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

This depends on nodejs/orchestrion-js#90 being released (and subsequently released in tracing-hooks etc), as we need to target hashed files:

- firebase-functions → orchestrion works ✅ (the onRequest channel fires — onRequest is declared in the stable lib/v2/providers/https.js).
- firestore → blocked ❌. This is the cause of the "0 spans" e2e failure.

Root cause of the e2e failure

@firebase/firestore@4.16.0 (what firebase@12 installs) is built with Rollup code-splitting: addDoc/getDocs/setDoc/deleteDoc are declared in a content-hash-named shared chunk —
dist/lite/common-460c749a.node.cjs.js — and index.node.cjs.js only re-exports them (exports.addDoc = common….addDoc).

Orchestrion transforms the declaration site, so it must target the chunk file. But:
- My config targets index.node.cjs.js (which has no function addDoc) → never transformed → channel never fires → 0 spans.
- The chunk name (common-460c749a) is a content hash that changes every firestore version, and @apm-js-collab/code-transformer (v?) matches filePath exactly — no glob/regex (I tested *,
**, etc.). So there's no stable, version-independent path to target.

@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 8aabf34. Configure here.

return startSpanManual(
{
name: `firebase.function.${triggerType}`,
op: 'function.firebase',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Wrong Firebase functions span op

Medium Severity

The orchestrion firebase-functions wrapper sets sentry.op to function.firebase, but the existing OTel integration uses http.request for the same spans and the PR states orchestrion output should match OTel aside from origin. Instrumented Cloud Functions therefore emit a different op than the default path and than the new unit test expects.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8aabf34. Configure here.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.59 kB - -
@sentry/browser - with treeshaking flags 26.03 kB - -
@sentry/browser (incl. Tracing) 46.34 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.13 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.12 kB - -
@sentry/browser (incl. Tracing, Replay) 85.62 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.26 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 90.32 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 102.97 kB - -
@sentry/browser (incl. Feedback) 44.76 kB - -
@sentry/browser (incl. sendFeedback) 32.38 kB - -
@sentry/browser (incl. FeedbackAsync) 37.51 kB - -
@sentry/browser (incl. Metrics) 28.67 kB - -
@sentry/browser (incl. Logs) 28.91 kB - -
@sentry/browser (incl. Metrics & Logs) 29.59 kB - -
@sentry/react 29.38 kB - -
@sentry/react (incl. Tracing) 48.61 kB - -
@sentry/vue 33.03 kB - -
@sentry/vue (incl. Tracing) 48.3 kB - -
@sentry/svelte 27.61 kB - -
CDN Bundle 30 kB - -
CDN Bundle (incl. Tracing) 48.32 kB - -
CDN Bundle (incl. Logs, Metrics) 31.57 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.64 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.81 kB - -
CDN Bundle (incl. Tracing, Replay) 85.84 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.14 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.64 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.92 kB - -
CDN Bundle - uncompressed 89.35 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.1 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.05 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 150.07 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 218.78 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 265.3 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 269.26 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 282.95 kB - -
@sentry/nextjs (client) 51.16 kB - -
@sentry/sveltekit (client) 46.78 kB - -
@sentry/core/server 78.42 kB - -
@sentry/core/browser 64.74 kB - -
@sentry/node-core 62.72 kB - -
@sentry/node 125.38 kB +0.01% +1 B 🔺
@sentry/node (incl. diagnostics channel injection) 140.03 kB +1.08% +1.49 kB 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 69.95 kB - -
@sentry/node/light 50.72 kB - -
@sentry/node - without tracing 74.06 kB - -
@sentry/aws-serverless 85.5 kB - -
@sentry/cloudflare (withSentry) - minified 181.71 kB - -
@sentry/cloudflare (withSentry) 449.16 kB - -

View base workflow run

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rewrite FirebaseInstrumentation to orchestrion

1 participant