Skip to content

Aggregated per-module / per-method stats #6164

@alwx

Description

@alwx

Per-call spans for every TurboModule invocation would explode span counts and add noise. Instead, aggregate counters + latency histograms per (module, method, kind) and flush them.

Ideas:

  • In the native code, maintain per-(module, method, kind) counters: call_count, error_count, total_duration_ms, plus a small fixed-bucket histogram (e.g. <1ms, <5ms, <20ms, <100ms, <500ms, >=500ms).
  • Flush at two points:
    1. On every transaction finish — emit the aggregate as span attributes / measurements on a synthetic turbo_modules.aggregate child span (or as measurements on the root span), so a slow screen load shows which native modules consumed the time.
    2. On a periodic timer (e.g. every 30s, configurable) for long-running sessions without transactions — emit as a metric / event so we don't lose the signal.
  • Per-module overhead must stay O(1). Keep all aggregation lock-free where possible (per-thread bucket → merge on flush) to avoid contention on hot async paths.
  • Provide an opt-out per module via options.ignoreTurboModules: string[] (e.g. users may want to exclude RNSentry itself to keep the signal clean).

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