ref(node): Streamline Firebase instrumentation#21748
Merged
Merged
Conversation
Create Firebase spans via the `@sentry/core` `startSpan` API instead of the OTel tracer, and fold the integration's firestore/functions hooks (origin, op, captureException) directly into the instrumentation. Ref JS-2848 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
size-limit report 📦
|
JPeer264
reviewed
Jun 24, 2026
JPeer264
left a comment
Member
There was a problem hiding this comment.
Everything looks good, except the clankers objection. Once this is resolved I'll review again
Use `startInactiveSpan` + `withActiveSpan` so the span is ended (enqueuing the finished transaction) before `flush` drains the queue on handler failure. Previously the error path ran `captureException` + `flush` inside the `startSpan` callback, before the span auto-ended, so the transaction could be dropped in short-lived Firebase Functions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d52644a. Configure here.
Set kind on the Sentry span options (SERVER for functions, CLIENT for firestore) so `otel.kind` is emitted as before instead of defaulting to INTERNAL. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the magic kind numbers with the `SPAN_KIND` const from `@sentry/core`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
andreiborza
reviewed
Jun 25, 2026
Comment on lines
+87
to
+108
| const span = startInactiveSpan({ | ||
| name: `firebase.function.${triggerType}`, | ||
| op: 'http.request', | ||
| kind: SPAN_KIND.SERVER, | ||
| attributes, | ||
| }); | ||
|
|
||
| return withActiveSpan(span, async () => { | ||
| try { | ||
| result = await handler.apply(this, handlerArgs); | ||
| } catch (e) { | ||
| error = e as Error; | ||
| } | ||
|
|
||
| functionsConfig?.responseHook?.(span, error); | ||
|
|
||
| if (error) { | ||
| span.recordException(error); | ||
| } | ||
|
|
||
| span.end(); | ||
|
|
||
| if (error) { | ||
| await functionsConfig?.errorHook?.(span, error); | ||
| const result = await handler.apply(this, handlerArgs); | ||
| span.end(); | ||
| return result; | ||
| } catch (error) { | ||
| span.setStatus({ code: SPAN_STATUS_ERROR }); | ||
| captureException(error, { | ||
| mechanism: { | ||
| type: 'auto.firebase.otel.functions', | ||
| handled: false, | ||
| }, | ||
| }); | ||
| span.end(); | ||
| await flush(2000); |
Member
There was a problem hiding this comment.
l: We could rewrite that to use startSpanManual instead of startInactiveSpan + withActiveSpan
Replace startInactiveSpan + withActiveSpan with a single startSpanManual call. Behavior is unchanged: the span stays active during the handler and is ended manually before flushing on error. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
andreiborza
approved these changes
Jun 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Streamlines the firebase instrumentation:
@sentry/core.Closes #21745