getsentry / getsentry/sentry-react-native

Add standalone long task detection integration

Aperta
#6,185 1 commento 2 reazioni 0 assegnatari Vedi su GitHub
Feature React-Native
Lingua principale
TypeScript
Stelle
1.8k
Fork
366
Merge medio
1g 5h
PR unite (30g)
93

Descrizione

## Summary

React Native exposes a [`PerformanceObserver` API](https://reactnative.dev/docs/global-PerformanceObserver) that supports `longtask` entry types. We should add a new integration that uses this to detect and report JS thread long tasks independently of tracing.

## Motivation

Customer request. They want visibility into JS thread blocking at scale across their fleet — frequency, duration, and the ability to filter by custom attributes (userId, orgId, etc). Current stall tracking only attaches measurements to active transactions, so it misses long tasks that happen outside traced operations.

## Requirements

- **Always-on reporting** — must work independently of active traces/transactions, with a configurable sample rate
- **Configurable threshold** — default 50ms from RN is too low for mobile; allow users to set their own (e.g. 200ms)
- **Emit as metrics** — report long task occurrences and durations via `Sentry.metrics` so they're queryable/aggregatable in Dashboards, with user-set tags for filtering
- **Code origin (stretch)** — `PerformanceObserver` does not provide stack traces. Correlating with continuous profiling would be the path here, but depends on continuous profiling support landing first. Out of scope for v1.

## Technical Notes

- RN's `PerformanceObserver.supportedEntryTypes` includes `longtask` — need to verify minimum RN version
- Existing `stallTrackingIntegration` uses a `setTimeout`-based watchdog for similar detection but is transaction-scoped. Consider whether to extend it or build a separate integration
- The JS SDK's browser long task instrumentation creates spans; our use case is different (metrics, not spans) since it needs to work outside transactions

## Open Questions

- Should we also emit long tasks as standalone spans (not tied to a root transaction) or strictly as metrics?
- Should this replace or complement the existing stall tracking integration?

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia leggendo la stallTrackingIntegration esistente e verificando la versione minima di React Native che supporta le entry longtask di PerformanceObserver. Determina se l’integrazione integra o sostituisce il tracciamento degli stall e se emette solo metriche, quindi definisci test per la segnalazione sempre attiva, il sampling e le soglie configurabili, le durate e gli attributi di filtro impostati dall’utente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
react-native, typescript
Ambito
mobile-dev, observability
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.