Skip to content

Conversation

@noahsmartin
Copy link
Contributor

@noahsmartin noahsmartin commented Nov 25, 2025

Fixes #4040

The problem was that for some events such as app hangs and CPUDiagnostics the metric kit payload contains an entire flamegraph. This change parses the flame graph into samples, and then picks the longest duration sample as the one we use for a stack trace. It also fixes over-counting the CPUDiagnostics which was emitting more than one event per exception. This is also fixed by identifying the longest duration sample.

Eventually we should support showing the full flame graph on the frontend, but with this PR the bug is fixed and we can consider that a future improvement.

I tested this on test flight by triggering crashes and verifying they are still correct, as well as manually replaying hang reports received in production

@noahsmartin noahsmartin added the ready-to-merge Use this label to trigger all PR workflows label Nov 25, 2025
@codecov
Copy link

codecov bot commented Nov 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.895%. Comparing base (6c20265) to head (ac40ad2).
⚠️ Report is 7 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #6908       +/-   ##
=============================================
- Coverage   84.968%   84.895%   -0.073%     
=============================================
  Files          457       459        +2     
  Lines        27608     27575       -33     
  Branches     12142     12145        +3     
=============================================
- Hits         23458     23410       -48     
- Misses        4109      4126       +17     
+ Partials        41        39        -2     
Files with missing lines Coverage Δ
Sources/Sentry/SentryFormatterSwift.m 100.000% <100.000%> (ø)
Sources/Sentry/SentryMetricKitIntegration.m 100.000% <100.000%> (ø)
...Core/MetricKit/SentryMXCallStackTree+Parsing.swift 100.000% <100.000%> (ø)
...s/Swift/Core/MetricKit/SentryMXCallStackTree.swift 100.000% <ø> (+25.000%) ⬆️
Sources/Swift/Core/MetricKit/SentryMXManager.swift 100.000% <100.000%> (ø)

... and 18 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6c20265...ac40ad2. Read the comment docs.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 25, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1192.81 ms 1220.30 ms 27.49 ms
Size 24.14 KiB 1.03 MiB 1.01 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
af848c4 1224.02 ms 1251.00 ms 26.98 ms
2ec2700 1238.28 ms 1258.82 ms 20.53 ms
b358363 1228.33 ms 1262.34 ms 34.01 ms
dcaec4e 1209.06 ms 1246.02 ms 36.96 ms
5ff1b04 1226.00 ms 1259.98 ms 33.98 ms
1b9991e 1233.45 ms 1256.61 ms 23.17 ms
f8cad3c 1217.94 ms 1257.96 ms 40.02 ms
5cfc768 1220.74 ms 1245.06 ms 24.32 ms
650d802 1231.86 ms 1255.64 ms 23.78 ms
5ec90e0 1235.57 ms 1258.45 ms 22.88 ms

App size

Revision Plain With Sentry Diff
af848c4 24.14 KiB 1.01 MiB 1012.94 KiB
2ec2700 23.75 KiB 980.80 KiB 957.05 KiB
b358363 23.75 KiB 987.92 KiB 964.18 KiB
dcaec4e 24.15 KiB 1.01 MiB 1014.80 KiB
5ff1b04 23.75 KiB 1.01 MiB 1016.24 KiB
1b9991e 23.75 KiB 908.01 KiB 884.26 KiB
f8cad3c 23.75 KiB 1.01 MiB 1016.13 KiB
5cfc768 23.75 KiB 850.73 KiB 826.98 KiB
650d802 23.74 KiB 913.13 KiB 889.39 KiB
5ec90e0 23.74 KiB 872.67 KiB 848.92 KiB

Previous results on branch: mxRewriting

Startup times

Revision Plain With Sentry Diff
c20c3c1 1209.08 ms 1237.69 ms 28.61 ms
d0cf095 1225.92 ms 1255.11 ms 29.20 ms
44da6c5 1234.22 ms 1266.02 ms 31.80 ms
bf3e245 1222.17 ms 1257.09 ms 34.92 ms
793ffea 1229.79 ms 1264.65 ms 34.86 ms
c5b3f7a 1220.18 ms 1259.44 ms 39.25 ms
f3b889c 1221.57 ms 1252.77 ms 31.20 ms
8824c94 1226.98 ms 1262.65 ms 35.67 ms

App size

Revision Plain With Sentry Diff
c20c3c1 24.14 KiB 1.03 MiB 1.01 MiB
d0cf095 24.14 KiB 1.03 MiB 1.01 MiB
44da6c5 24.14 KiB 1.03 MiB 1.00 MiB
bf3e245 24.14 KiB 1.03 MiB 1.00 MiB
793ffea 24.14 KiB 1.03 MiB 1.00 MiB
c5b3f7a 24.14 KiB 1.01 MiB 1013.45 KiB
f3b889c 24.14 KiB 1.03 MiB 1.01 MiB
8824c94 24.14 KiB 1.01 MiB 1014.88 KiB

@noahsmartin noahsmartin force-pushed the mxRewriting branch 2 times, most recently from d978079 to 169cf94 Compare December 1, 2025 20:59
@noahsmartin noahsmartin force-pushed the mxRewriting branch 3 times, most recently from a7949ab to 0c4f788 Compare December 11, 2025 00:30
@noahsmartin noahsmartin marked this pull request as ready for review December 11, 2025 00:31
Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

Thank you @noahsmartin, I added a few comments.

@noahsmartin noahsmartin force-pushed the mxRewriting branch 2 times, most recently from 62cf281 to 47f8d7c Compare December 17, 2025 16:11
@noahsmartin
Copy link
Contributor Author

Thanks @philipphofmann this is ready for another look!

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM.

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

Again, LGTM

@noahsmartin noahsmartin merged commit d069d70 into main Dec 19, 2025
207 of 209 checks passed
@noahsmartin noahsmartin deleted the mxRewriting branch December 19, 2025 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Use this label to trigger all PR workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SDK wrongly parses MetricKit MXHangDiagnostic stack trace

3 participants