Skip to content

Conversation

denrase
Copy link
Collaborator

@denrase denrase commented Sep 23, 2025

📜 Description

Mark file sync spans run in the main isolate with blocked_main_thread

  • Add spans for file sync oeration accros plugins: hive, isar, file
  • Add new event 'OnSpanFinish'
  • enrich in thread info integration if sync file access on main

💡 Motivation and Context

Closes #1727

💚 How did you test it?

Unit tests

📝 Checklist

  • I reviewed submitted code
  • 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
  • All tests passing
  • No breaking changes

Copy link

codecov bot commented Sep 23, 2025

Codecov Report

❌ Patch coverage is 89.85507% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.96%. Comparing base (a10aff4) to head (8979940).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
packages/isar/lib/src/sentry_isar.dart 69.56% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3270      +/-   ##
==========================================
+ Coverage   87.82%   88.96%   +1.14%     
==========================================
  Files         294      281      -13     
  Lines       10143     9805     -338     
==========================================
- Hits         8908     8723     -185     
+ Misses       1235     1082     -153     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

github-actions bot commented Sep 23, 2025

Android Performance metrics 🚀

  Plain With Sentry Diff
Startup time 462.37 ms 461.92 ms -0.45 ms
Size 13.93 MiB 15.06 MiB 1.13 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
0fb3800 465.64 ms 536.77 ms 71.13 ms
81f83eb 471.40 ms 522.14 ms 50.74 ms
93b7728 475.28 ms 489.13 ms 13.86 ms
e04b24b 504.72 ms 516.43 ms 11.71 ms
2d34233 470.54 ms 558.90 ms 88.36 ms
640ad0c 466.00 ms 552.67 ms 86.67 ms
4298701 524.40 ms 633.30 ms 108.90 ms
7cfee3b 498.78 ms 516.98 ms 18.20 ms
4481076 484.08 ms 505.70 ms 21.61 ms
54acf91 487.24 ms 529.60 ms 42.36 ms

App size

Revision Plain With Sentry Diff
0fb3800 6.54 MiB 7.69 MiB 1.15 MiB
81f83eb 6.54 MiB 7.69 MiB 1.15 MiB
93b7728 6.54 MiB 7.69 MiB 1.15 MiB
e04b24b 13.93 MiB 15.00 MiB 1.06 MiB
2d34233 6.54 MiB 7.55 MiB 1.01 MiB
640ad0c 6.54 MiB 7.69 MiB 1.15 MiB
4298701 6.54 MiB 7.71 MiB 1.17 MiB
7cfee3b 6.54 MiB 7.70 MiB 1.17 MiB
4481076 6.54 MiB 7.69 MiB 1.15 MiB
54acf91 6.54 MiB 7.70 MiB 1.17 MiB

Previous results on branch: enha/mark-scncy-method-spans-on-main-isolate

Startup times

Revision Plain With Sentry Diff
55214b3 447.58 ms 443.88 ms -3.70 ms
f4d9e3a 487.98 ms 478.63 ms -9.35 ms
8305f60 457.54 ms 468.00 ms 10.46 ms
6780d71 420.98 ms 433.34 ms 12.36 ms
15fdf60 437.92 ms 426.57 ms -11.35 ms
fe27ab8 424.98 ms 445.18 ms 20.20 ms
cd6efd2 503.06 ms 493.85 ms -9.21 ms
d005357 437.94 ms 470.70 ms 32.76 ms

App size

Revision Plain With Sentry Diff
55214b3 13.93 MiB 15.00 MiB 1.06 MiB
f4d9e3a 13.93 MiB 15.00 MiB 1.06 MiB
8305f60 13.93 MiB 15.06 MiB 1.13 MiB
6780d71 13.93 MiB 15.00 MiB 1.06 MiB
15fdf60 13.93 MiB 15.00 MiB 1.06 MiB
fe27ab8 13.93 MiB 15.00 MiB 1.06 MiB
cd6efd2 13.93 MiB 15.00 MiB 1.06 MiB
d005357 13.93 MiB 15.00 MiB 1.06 MiB

Copy link
Contributor

github-actions bot commented Sep 23, 2025

iOS Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1269.92 ms 1268.06 ms -1.86 ms
Size 5.53 MiB 6.01 MiB 487.66 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
192b44c 1269.08 ms 1275.52 ms 6.44 ms
c1e775e 1263.08 ms 1275.32 ms 12.24 ms
79f6b41 1269.33 ms 1279.71 ms 10.38 ms
eca355d 1238.39 ms 1266.98 ms 28.59 ms
de377fd 1252.28 ms 1254.76 ms 2.48 ms
c8596a6 1234.11 ms 1241.19 ms 7.08 ms
e2d675d 1238.48 ms 1242.76 ms 4.28 ms
793f4dc 1262.50 ms 1282.35 ms 19.85 ms
81f83eb 1259.53 ms 1273.39 ms 13.86 ms
4481076 1256.48 ms 1266.64 ms 10.17 ms

App size

Revision Plain With Sentry Diff
192b44c 5.53 MiB 5.96 MiB 444.33 KiB
c1e775e 20.70 MiB 22.46 MiB 1.75 MiB
79f6b41 7.86 MiB 9.44 MiB 1.58 MiB
eca355d 7.86 MiB 9.44 MiB 1.58 MiB
de377fd 20.71 MiB 22.43 MiB 1.73 MiB
c8596a6 7.86 MiB 9.44 MiB 1.58 MiB
e2d675d 7.86 MiB 9.44 MiB 1.58 MiB
793f4dc 7.86 MiB 9.44 MiB 1.58 MiB
81f83eb 7.86 MiB 9.44 MiB 1.58 MiB
4481076 7.86 MiB 9.44 MiB 1.58 MiB

Previous results on branch: enha/mark-scncy-method-spans-on-main-isolate

Startup times

Revision Plain With Sentry Diff
fe27ab8 1252.94 ms 1246.31 ms -6.63 ms
8305f60 1259.24 ms 1264.04 ms 4.80 ms
cd6efd2 1253.13 ms 1256.17 ms 3.03 ms
15fdf60 1251.14 ms 1249.26 ms -1.88 ms
6780d71 1259.80 ms 1257.65 ms -2.14 ms
f4d9e3a 1256.13 ms 1249.04 ms -7.08 ms
55214b3 1261.92 ms 1263.49 ms 1.57 ms

App size

Revision Plain With Sentry Diff
fe27ab8 5.53 MiB 6.00 MiB 481.98 KiB
8305f60 5.53 MiB 6.01 MiB 487.66 KiB
cd6efd2 5.53 MiB 6.00 MiB 481.93 KiB
15fdf60 5.53 MiB 6.00 MiB 482.11 KiB
6780d71 5.53 MiB 6.00 MiB 481.99 KiB
f4d9e3a 5.53 MiB 6.00 MiB 481.93 KiB
55214b3 5.53 MiB 6.00 MiB 481.94 KiB

@denrase denrase marked this pull request as ready for review September 24, 2025 08:10
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@denrase denrase requested a review from buenaflor October 8, 2025 11:56
cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@buenaflor buenaflor left a comment

Choose a reason for hiding this comment

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

looks good!

makes me think, I think we should spec out a bit when to use SDK lifecycle hooks vs event processor - currently it's a bit unclear when it's better to use which

We could have achieved the same with event processor for example, wdyt

// Check if we're on the main isolate by looking at thread name
if (data['sync'] == true &&
data[SpanDataConvention.threadName] == 'main') {
span.setData('blocked_main_thread', true);
Copy link
Contributor

Choose a reason for hiding this comment

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

let's add blocked_main_thread to SpanDataConvention as well

# Conflicts:
#	packages/flutter/lib/src/integrations/thread_info_integration.dart
@denrase
Copy link
Collaborator Author

denrase commented Oct 13, 2025

@buenaflor We are mutating span data, which is currently only possible for un-finished spans, as enforced by the SDK. Thats why using the lifecycle hook was the straight forward thing to do here. But generally it could also have been an event (transaction) processor.

@override
void setData(String key, value) {
  if (finished) {
    return;  // Early return - no modification allowed
  }
  _data[key] = value;
}

@denrase
Copy link
Collaborator Author

denrase commented Oct 13, 2025

@buenaflor Created a file span manually (the ones internally would not take so long) with 150ms duration with DSN set to one of my sample apps. Detection works.

Bildschirmfoto 2025-10-13 um 15 42 54

https://denrase.sentry.io/issues/6941568283/?project=4508369865539584&query=is%3Aunresolved&referrer=issue-stream

@denrase denrase requested a review from buenaflor October 13, 2025 13:57
@denrase denrase merged commit 6ad8fc4 into main Oct 13, 2025
134 of 136 checks passed
@denrase denrase deleted the enha/mark-scncy-method-spans-on-main-isolate branch October 13, 2025 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File sync run in the main isolate for a certain amount of time should report as a performance issue

2 participants