Skip to content

fix(tracing): Generate new trace on navigation #2861

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Apr 17, 2025

Conversation

buenaflor
Copy link
Contributor

@buenaflor buenaflor commented Apr 14, 2025

One step closer towards #2753

💚 How did you test it?

image

image

Manual test, 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

🔮 Next steps

Follow up PR: implement it for app lifecycle

Copy link

codecov bot commented Apr 14, 2025

Codecov Report

Attention: Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.

Project coverage is 87.68%. Comparing base (886a258) to head (3e89a70).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
dart/lib/src/hub_adapter.dart 0.00% 2 Missing ⚠️
dart/lib/src/noop_hub.dart 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2861      +/-   ##
==========================================
- Coverage   87.68%   87.68%   -0.01%     
==========================================
  Files         272      272              
  Lines        9031     9037       +6     
==========================================
+ Hits         7919     7924       +5     
- Misses       1112     1113       +1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

github-actions bot commented Apr 14, 2025

Android Performance metrics 🚀

  Plain With Sentry Diff
Startup time 452.71 ms 514.49 ms 61.78 ms
Size 6.44 MiB 7.43 MiB 1010.07 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
d189e01 328.67 ms 397.12 ms 68.45 ms
dfcfde9 464.98 ms 526.06 ms 61.08 ms
4f6634c 418.68 ms 524.88 ms 106.20 ms
abcdba3 354.68 ms 399.04 ms 44.36 ms
25fdf12 451.85 ms 526.20 ms 74.35 ms
ef6466d 373.96 ms 443.17 ms 69.21 ms
6e9c5a2 392.32 ms 498.51 ms 106.19 ms
a758ebd 556.55 ms 588.14 ms 31.59 ms
c1bb00f 303.77 ms 371.88 ms 68.11 ms
9f9f94f 331.04 ms 368.92 ms 37.88 ms

App size

Revision Plain With Sentry Diff
d189e01 6.16 MiB 7.14 MiB 1009.90 KiB
dfcfde9 6.46 MiB 7.48 MiB 1.03 MiB
4f6634c 6.46 MiB 7.48 MiB 1.02 MiB
abcdba3 5.94 MiB 6.95 MiB 1.01 MiB
25fdf12 6.46 MiB 7.48 MiB 1.02 MiB
ef6466d 6.34 MiB 7.28 MiB 967.79 KiB
6e9c5a2 6.35 MiB 7.42 MiB 1.07 MiB
a758ebd 6.49 MiB 7.57 MiB 1.08 MiB
c1bb00f 6.06 MiB 7.09 MiB 1.03 MiB
9f9f94f 5.94 MiB 6.95 MiB 1.01 MiB

Previous results on branch: start-new-trace-on-navigation

Startup times

Revision Plain With Sentry Diff
d34ee4a 460.10 ms 518.85 ms 58.75 ms
5a0c06d 479.50 ms 537.54 ms 58.04 ms

App size

Revision Plain With Sentry Diff
d34ee4a 6.44 MiB 7.45 MiB 1.01 MiB
5a0c06d 6.44 MiB 7.45 MiB 1.01 MiB

Copy link
Contributor

github-actions bot commented Apr 15, 2025

iOS Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1258.49 ms 1267.61 ms 9.12 ms
Size 8.43 MiB 10.01 MiB 1.58 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
3e4b523 1260.53 ms 1270.06 ms 9.53 ms
d5696bf 1232.96 ms 1254.50 ms 21.54 ms
c978477 1228.43 ms 1249.17 ms 20.74 ms
ef31c7f 1272.43 ms 1295.71 ms 23.29 ms
1596141 1230.77 ms 1241.90 ms 11.13 ms
b49bf00 1248.00 ms 1260.35 ms 12.35 ms
934f10e 1245.18 ms 1263.77 ms 18.59 ms
0ac1eed 1278.51 ms 1285.29 ms 6.78 ms
b9da046 1256.43 ms 1275.82 ms 19.39 ms
9ed26e6 1263.84 ms 1281.04 ms 17.20 ms

App size

Revision Plain With Sentry Diff
3e4b523 8.28 MiB 9.33 MiB 1.05 MiB
d5696bf 8.38 MiB 9.73 MiB 1.35 MiB
c978477 8.32 MiB 9.50 MiB 1.18 MiB
ef31c7f 8.09 MiB 9.07 MiB 1000.79 KiB
1596141 8.29 MiB 9.37 MiB 1.08 MiB
b49bf00 8.10 MiB 9.08 MiB 1004.36 KiB
934f10e 8.38 MiB 9.77 MiB 1.39 MiB
0ac1eed 8.10 MiB 9.16 MiB 1.07 MiB
b9da046 8.10 MiB 9.16 MiB 1.07 MiB
9ed26e6 8.42 MiB 9.89 MiB 1.46 MiB

Previous results on branch: start-new-trace-on-navigation

Startup times

Revision Plain With Sentry Diff
d34ee4a 1255.47 ms 1273.55 ms 18.08 ms
5a0c06d 1254.45 ms 1264.45 ms 10.00 ms
c782130 1274.96 ms 1285.33 ms 10.38 ms

App size

Revision Plain With Sentry Diff
d34ee4a 8.43 MiB 10.04 MiB 1.61 MiB
5a0c06d 8.43 MiB 10.04 MiB 1.61 MiB
c782130 8.43 MiB 10.01 MiB 1.58 MiB

Comment on lines -457 to -459
} else if (!_options.isTracingEnabled()) {
final item = _peek();
item.scope.propagationContext = PropagationContext();
Copy link
Contributor Author

@buenaflor buenaflor Apr 15, 2025

Choose a reason for hiding this comment

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

this code doesn't make sense, we can remove it. a new start transaction with performance disabled should not be able to create a new trace, it should just no-op

@@ -470,6 +466,7 @@ class Hub {
}

transactionContext.origin ??= SentryTraceOrigins.manual;
transactionContext.traceId = scope.propagationContext.traceId;
Copy link
Contributor Author

@buenaflor buenaflor Apr 15, 2025

Choose a reason for hiding this comment

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

navigator observer will take care of updating the propagation context so new transactions just need to use it and child spans will inherit the trace id from parent

@buenaflor buenaflor changed the title fix(tracing): [draft] Generate new trace on navigation fix(tracing): Generate new trace on navigation Apr 15, 2025
@buenaflor buenaflor marked this pull request as ready for review April 15, 2025 15:28
Copy link
Collaborator

@denrase denrase 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, we should only add some tests.

@@ -43,6 +43,17 @@ class Scope {
/// Returns active transaction or null if there is no active transaction.
ISentrySpan? span;

/// The propagation context for connecting errors and spans to traces.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Love the additional descriptions/documetnations you have added. ❤️

@buenaflor buenaflor merged commit 10118fa into main Apr 17, 2025
142 of 153 checks passed
@buenaflor buenaflor deleted the start-new-trace-on-navigation branch April 17, 2025 12:30
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.

2 participants