Skip to content

JS-side integration: attach TurboModule stats to active spans #6165

@alwx

Description

@alwx

Native gives us the data; the JS layer is where it has to land on the right span. Today, idle navigation spans (reactnavigation.ts, expoRouter.ts) and the user's own Sentry.startSpan(...) calls have no visibility into native module work that happened during them.

Goal

  • New integration: turboModulesIntegration() exported from packages/core/src/js/integrations/exports.ts.

  • On install, the integration:

    • Calls into the native sink (Issue 1) to start a logical "JS observation window" tied to the active span (using getActiveSpan()).
    • On span end, pulls a delta of aggregate stats since the window started and attaches them as attributes (turbo_module.<name>.<method>.call_count, ..._duration_ms, ..._error_count) — capped to top-N modules by duration to keep payload size sane.
    • Adds a breadcrumb (category: 'native.turbo_module', level: 'info') for any async call that exceeded a configurable threshold (slowCallThresholdMs, default 500ms) including module + method + duration.
  • Surface a tiny JS API for users who want explicit attribution:

    Sentry.startSpan({ name: 'load profile' }, async () => {
      // any TurboModule activity inside this callback is automatically attached
    });
  • Auto-enabled when enableTurboModuleTracking (Issue 1) is on; no-op otherwise.

Metadata

Metadata

Assignees

No one assigned
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions