Repository navigation
Conversation
The react_native.long_task.duration metric had only sentry.origin, so long tasks could not be broken down by where they happened. Each metric now has the route (route), the foreground state (app.in_foreground), the app start phase (app.start_phase: app_start or steady_state) and the name and op of the root span (sentry.segment.name, sentry.op). React Native delivers long task entries to the observer callback with idle priority, which can run up to 5 minutes after the task when the JS thread is busy. The context at callback time can then belong to a later screen. So the integration keeps a short history of route changes, app state changes and root spans, and reads the values at the start time of each task. The long tasks that a transaction reads with takeRecords() before the observer delivers them go through the same path, so they get the same context. The tracing integration and the app start code emit the new currentRouteChange and appStartEnd client hooks for this. The app start end comes from Sentry.wrap, ReactNativeProfiler or appLoaded(). Tasks wait for it, so the long tasks of the app start get the phase too. If the app records no app start end within 30 seconds, the waiting tasks are reported without the phase. The oldest task is reported without the phase when more than 50 tasks wait, and the client close reports the waiting tasks. The root span op is used instead of the op of the active leaf span, because the leaf span at the task start is not known and its op has more values.
Adds the captureThresholdMs option to longTaskIntegration. For each long task that reaches the threshold, the SDK captures a warning event with the breadcrumbs up to the end of the task, so users can see the Redux actions, requests and navigation that led to the block without their own ring buffer. The events are off by default and an app launch captures at most 10 of them. Sentry groups them by the route at the start of the task, because they have no stack. The route history moves out of the metric reporter, so events work also with metrics disabled. The task end is converted on the Date.now() clock that breadcrumbs use, relative to now, so the window does not depend on performance.timeOrigin. processEvent drops the breadcrumbs after the task, because React Native can deliver the entry long after the task ends.
Replaces the placeholder in the CHANGELOG entry for captureThresholdMs with the number of the opened PR (#7147).
Contributor
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog.
🤖 This preview updates automatically when you update the PR. |
Contributor
|
alwx
force-pushed
the
alwx/feature/7074
branch
from
December 1, 2026 09:52
2c747f8 to
c6d842e
Compare
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.
📢 Type of change
📜 Description
Adds the
captureThresholdMsoption tolongTaskIntegration. For each long task of at least this duration, the SDK captures a warning eventJS thread blockedwith the breadcrumbs up to the end of the task, for example Redux actions, HTTP requests and navigation. The option is off by default, and an app launch captures at most 10 of these events.The events have no stack, so Sentry groups them by the route at the start of the task (
fingerprint: ['long-task', route],contexts.app.view_names). The duration is incontexts.long_task.duration_ms. React Native can deliver the entry long after the task ends, so the event timestamp is the task end, andprocessEventdrops the breadcrumbs after it. The task end is converted relative to now on theDate.now()clock that breadcrumbs use, so it does not depend onperformance.timeOrigin.💡 Motivation and Context
A long task tells you that the JS thread was blocked, but not what led to it. Customers keep their own ring buffer next to the SDK to get this timeline, and the SDK already records most of it as breadcrumbs. Closes #7076.
This PR is based on #7119, which adds the route history.
💚 How did you test it?
Unit tests cover the threshold, the breadcrumb window, the route fingerprint, the limit of 10 events, and events with metrics disabled or below
minDurationMs. The breadcrumb test fails without the filter.yarn build,yarn test,yarn lintandyarn circularDepCheckpass. The sample app turns the option on. I have not tested it on a device yet.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
Test on a device. Agree on the option name, the limit of 10 events and the fingerprint. Check if the default
maxBreadcrumbs(100) keeps enough history in apps that dispatch many Redux actions. Change the base tomainafter #7119 merges.