Uh oh!
There was an error while loading. Please reload this page.
ref(node): Streamline Firebase instrumentation - #21748
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>
Uh oh!
There was an error while loading. Please reload this page.
size-limit report 📦
|
JPeer264
left a comment
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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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>
| 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); |
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>

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