Skip to content

fix(profiling): Fix app start transaction profile timestamp offset#5962

Open
antonis wants to merge 7 commits intomainfrom
fix/profile-app-start-timestamp-offset
Open

fix(profiling): Fix app start transaction profile timestamp offset#5962
antonis wants to merge 7 commits intomainfrom
fix/profile-app-start-timestamp-offset

Conversation

@antonis
Copy link
Copy Markdown
Contributor

@antonis antonis commented Apr 7, 2026

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Uses the actual profiling start timestamp for the profile's timestamp field instead of the adjusted event.start_timestamp.

For app start transactions, the SDK adjusts the transaction's start_timestamp backward to the app start time. However, profile samples use elapsed_since_start_ns relative to when profiling actually started (JS VM start), not the app start time. This mismatch caused the profile to appear misaligned in the Sentry UI.

Changes:

  • Added profilingStartTimestampNs field to HermesProfileEvent and AndroidCombinedProfileEvent types
  • stopProfiling now stores the profiling start timestamp on the returned profile event
  • enrichCombinedProfileWithEventContext and enrichAndroidProfileWithEventContext prefer the stored profiling start timestamp over event.start_timestamp
  • The internal field is stripped before serialization via destructuring

💡 Motivation and Context

Fixes #4511

When an app start transaction has its start time adjusted, the profile timestamp was incorrectly set to the app start time, while profile samples were relative to the JS VM start. This caused a visual offset in the Sentry profiling UI.

Relay does not validate the profile timestamp against the transaction start_timestamp, so this change is safe from the ingestion side.

💚 How did you test it?

  • All existing tests pass (196 tests)
  • Build succeeds
  • For non-app-start transactions: no behavior change (profiling start ≈ transaction start)
  • For app start transactions: profile timestamp now correctly reflects when profiling started

📝 Checklist

  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing
  • No breaking changes

🔮 Next steps

Use the actual profiling start timestamp for the profile's timestamp
field instead of the adjusted transaction start_timestamp. For app start
transactions, the transaction start is adjusted backward to the app
start time, but the profile samples are relative to when profiling
actually started (JS VM start). This caused a misalignment in the
Sentry UI.

Fixes #4511

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • fix(profiling): Fix app start transaction profile timestamp offset by antonis in #5962
  • fix(android): Use componentStack as fallback for missing error stack traces by antonis in #5965
  • chore(deps): bump addressable from 2.8.7 to 2.9.0 in /samples/react-native-macos by dependabot in #5967
  • chore(deps): bump addressable from 2.8.7 to 2.9.0 in /samples/react-native by dependabot in #5966
  • fix(ios): Add SENTRY_PROJECT_ROOT env var for monorepo support by antonis in #5961
  • feat(ios): Add attachAllThreads option by antonis in #5960
  • fix(core): Lazy-load Metro internal modules to prevent Expo 55 import errors by lucas-zimerman in #5958
  • chore(deps): update Cocoa SDK to v9.9.0 by github-actions in #5956
  • chore(deps): update Maestro to v2.4.0 by github-actions in #5955
  • Feat: Fallback to stacktrace parsing by lucas-zimerman in #5946
  • fix(ci): Bump Node to 22 in size-analysis and testflight workflows by antonis in #5954
  • feat(playground): Open Sentry in desktop browser from Expo apps by antonis in #5947
  • chore(core): Bump sample app to React Native 0.84.1 by antonis in #5941
  • Size analysis for React Native SDK by alwx in #5949
  • chore(deps): bump lodash from 4.17.23 to 4.18.1 by dependabot in #5953
  • chore(deps): bump yauzl to ^3.2.1 by antonis in #5950
  • chore(deps): bump brace-expansion to ^2.0.3 by antonis in #5951
  • chore(deps): bump @xmldom/xmldom to fix XML injection by antonis in #5952

🤖 This preview updates automatically when you update the PR.

antonis and others added 2 commits April 7, 2026 12:00
Add unit tests for enrichCombinedProfileWithEventContext and
enrichAndroidProfileWithEventContext verifying that:
- profilingStartTimestampNs is used for the profile timestamp when set
- Falls back to event.start_timestamp when not set
- profilingStartTimestampNs is stripped from serialized output

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sentry
Copy link
Copy Markdown

sentry bot commented Apr 7, 2026

Sentry Build Distribution

App Name App ID Version Configuration Install Page
Sentry RN io.sentry.reactnative.sample 8.7.0 (82) Release Install Build

Configure sentry-react-native build distribution settings

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@antonis antonis marked this pull request as ready for review April 7, 2026 10:51
Copy link
Copy Markdown
Collaborator

@lucas-zimerman lucas-zimerman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@lucas-zimerman lucas-zimerman added the ready-to-merge Triggers the full CI test suite label Apr 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 406.88 ms 430.90 ms 24.02 ms
Size 43.75 MiB 48.08 MiB 4.33 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
df5d108+dirty 527.06 ms 603.58 ms 76.52 ms
2c735cc+dirty 414.09 ms 438.47 ms 24.38 ms
a50b33d+dirty 500.81 ms 532.11 ms 31.30 ms
3817909+dirty 406.67 ms 416.58 ms 9.91 ms
5c1e987+dirty 423.52 ms 471.64 ms 48.12 ms
4953e94+dirty 442.02 ms 456.52 ms 14.50 ms

App size

Revision Plain With Sentry Diff
df5d108+dirty 43.75 MiB 48.08 MiB 4.33 MiB
2c735cc+dirty 43.75 MiB 48.08 MiB 4.33 MiB
a50b33d+dirty 43.75 MiB 48.08 MiB 4.33 MiB
3817909+dirty 43.75 MiB 48.08 MiB 4.33 MiB
5c1e987+dirty 43.75 MiB 48.08 MiB 4.33 MiB
4953e94+dirty 43.75 MiB 48.08 MiB 4.33 MiB

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1210.93 ms 1212.39 ms 1.46 ms
Size 3.38 MiB 4.74 MiB 1.35 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
a50b33d+dirty 1197.74 ms 1197.17 ms -0.57 ms
3817909+dirty 1183.90 ms 1187.50 ms 3.60 ms
5c1e987+dirty 1204.30 ms 1222.15 ms 17.85 ms
2c735cc+dirty 1229.67 ms 1221.50 ms -8.17 ms
4953e94+dirty 1212.06 ms 1214.83 ms 2.77 ms
df5d108+dirty 1225.90 ms 1220.14 ms -5.76 ms

App size

Revision Plain With Sentry Diff
a50b33d+dirty 3.38 MiB 4.73 MiB 1.35 MiB
3817909+dirty 3.38 MiB 4.73 MiB 1.35 MiB
5c1e987+dirty 3.38 MiB 4.73 MiB 1.35 MiB
2c735cc+dirty 3.38 MiB 4.74 MiB 1.35 MiB
4953e94+dirty 3.38 MiB 4.73 MiB 1.35 MiB
df5d108+dirty 3.38 MiB 4.73 MiB 1.35 MiB

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 73ea8a5. Configure here.

- Fix app start transaction profile offset by using the actual profiling start timestamp instead of the adjusted app start time ([#5962](https://github.com/getsentry/sentry-react-native/issues/5962))
=======
- Use React `componentStack` as fallback when error has no stack trace on Android ([#5965](https://github.com/getsentry/sentry-react-native/pull/5965)
>>>>>>> main
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unresolved merge conflict markers in CHANGELOG

High Severity

Unresolved git merge conflict markers (<<<<<<<, =======, >>>>>>>) were accidentally committed in CHANGELOG.md. This breaks the Markdown rendering and drops the existing componentStack changelog entry from its proper location, as both changelog entries need to appear without conflict markers.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 73ea8a5. Configure here.

Comment on lines +13 to +17
<<<<<<< fix/profile-app-start-timestamp-offset
- Fix app start transaction profile offset by using the actual profiling start timestamp instead of the adjusted app start time ([#5962](https://github.com/getsentry/sentry-react-native/issues/5962))
=======
- Use React `componentStack` as fallback when error has no stack trace on Android ([#5965](https://github.com/getsentry/sentry-react-native/pull/5965)
>>>>>>> main
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The CHANGELOG.md file contains unresolved git merge conflict markers, which will break the release process.
Severity: HIGH

Suggested Fix

Resolve the merge conflict in CHANGELOG.md. Remove the git conflict markers (<<<<<<<, =======, >>>>>>>) and combine the changelog entries from both branches correctly.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: CHANGELOG.md#L13-L17

Potential issue: The `CHANGELOG.md` file contains unresolved git merge conflict markers
(`<<<<<<<`, `=======`, `>>>>>>>`) that were committed to the codebase. While this does
not cause a runtime error in the application, it will break the release tooling which
automatically parses the changelog. This failure in the release automation will prevent
new versions of the software from being released.

Did we get this right? 👍 / 👎 to inform future reviews.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1221.28 ms 1223.07 ms 1.79 ms
Size 3.38 MiB 4.74 MiB 1.35 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
a50b33d+dirty 1207.11 ms 1212.10 ms 5.00 ms
3817909+dirty 1210.76 ms 1215.64 ms 4.89 ms
5c1e987+dirty 1208.43 ms 1220.72 ms 12.29 ms
2c735cc+dirty 1223.33 ms 1224.38 ms 1.04 ms
4953e94+dirty 1217.41 ms 1223.53 ms 6.12 ms
df5d108+dirty 1207.34 ms 1210.50 ms 3.16 ms

App size

Revision Plain With Sentry Diff
a50b33d+dirty 3.38 MiB 4.73 MiB 1.35 MiB
3817909+dirty 3.38 MiB 4.73 MiB 1.35 MiB
5c1e987+dirty 3.38 MiB 4.73 MiB 1.35 MiB
2c735cc+dirty 3.38 MiB 4.74 MiB 1.35 MiB
4953e94+dirty 3.38 MiB 4.73 MiB 1.35 MiB
df5d108+dirty 3.38 MiB 4.73 MiB 1.35 MiB

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 405.56 ms 422.78 ms 17.22 ms
Size 43.94 MiB 48.94 MiB 5.00 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
df5d108+dirty 434.82 ms 447.39 ms 12.57 ms
2c735cc+dirty 435.20 ms 459.48 ms 24.28 ms
a50b33d+dirty 353.21 ms 398.48 ms 45.27 ms
3817909+dirty 357.52 ms 391.52 ms 34.00 ms
5c1e987+dirty 444.71 ms 475.13 ms 30.42 ms
4953e94+dirty 398.80 ms 431.81 ms 33.01 ms

App size

Revision Plain With Sentry Diff
df5d108+dirty 43.94 MiB 48.94 MiB 5.00 MiB
2c735cc+dirty 43.94 MiB 48.94 MiB 5.00 MiB
a50b33d+dirty 43.94 MiB 48.94 MiB 5.00 MiB
3817909+dirty 43.94 MiB 48.94 MiB 5.00 MiB
5c1e987+dirty 43.94 MiB 48.94 MiB 5.00 MiB
4953e94+dirty 43.94 MiB 48.94 MiB 5.00 MiB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Triggers the full CI test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix App Start Transaction Profile offset

2 participants