Skip to content
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

refactor: Convert constants SentryTraceOrigins to Swift #4717

Merged
merged 11 commits into from
Jan 21, 2025

Conversation

philprime
Copy link
Contributor

@philprime philprime commented Jan 15, 2025

📜 Description

Moves the global constants defined in SentryTraceOrigins.h to static constants in a Swift class

💡 Motivation and Context

  • We want to migrate the code base to Swift over time
  • We want the constants to be available in Swift without complicated setup
  • It uses a @objcMembers class to make the static properties accessible from Objective-C.
  • The current pattern uses the same syntax as Swift's enum which is not available in Objective-C. Eventually it will only be used from Swift files, and can be replaced with an enum without further code changes.

💚 How did you test it?

Unit tests

📝 Checklist

You have to check all boxes before merging:

  • I added tests to verify the 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.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

Copy link

🚨 Detected changes in high risk code 🚨

High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:

  • Sources/Sentry/SentryNetworkTracker.m

@philprime philprime self-assigned this Jan 15, 2025
Copy link

🚨 Detected changes in high risk code 🚨

High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:

  • Sources/Sentry/SentryNetworkTracker.m

Copy link

🚨 Detected changes in high risk code 🚨

High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:

  • Sources/Sentry/SentryNetworkTracker.m

Copy link

github-actions bot commented Jan 15, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1224.90 ms 1245.39 ms 20.49 ms
Size 22.31 KiB 775.10 KiB 752.79 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
b048ba3 1215.32 ms 1234.61 ms 19.29 ms
ebeb68c 1216.27 ms 1243.80 ms 27.53 ms
2affdbd 1224.29 ms 1248.06 ms 23.77 ms
9e6665f 1237.58 ms 1253.84 ms 16.26 ms
39b1c35 1212.90 ms 1214.30 ms 1.41 ms
19b93f9 1212.46 ms 1226.86 ms 14.40 ms
af1f4dd 1232.39 ms 1255.88 ms 23.49 ms
31ac438 1244.29 ms 1264.06 ms 19.78 ms
feba2be 1246.67 ms 1254.64 ms 7.97 ms
a8f7a1b 1219.64 ms 1238.88 ms 19.23 ms

App size

Revision Plain With Sentry Diff
b048ba3 21.90 KiB 707.64 KiB 685.74 KiB
ebeb68c 21.58 KiB 698.37 KiB 676.79 KiB
2affdbd 22.85 KiB 411.37 KiB 388.52 KiB
9e6665f 22.84 KiB 403.52 KiB 380.67 KiB
39b1c35 22.85 KiB 408.88 KiB 386.03 KiB
19b93f9 21.58 KiB 694.46 KiB 672.88 KiB
af1f4dd 22.85 KiB 414.71 KiB 391.86 KiB
31ac438 20.76 KiB 393.36 KiB 372.60 KiB
feba2be 20.76 KiB 414.45 KiB 393.69 KiB
a8f7a1b 21.58 KiB 670.40 KiB 648.82 KiB

Previous results on branch: philprime/refactor-trace-origins

Startup times

Revision Plain With Sentry Diff
77cd5e2 1232.10 ms 1240.49 ms 8.39 ms
cabada0 1234.60 ms 1251.53 ms 16.93 ms
edfaee8 1233.41 ms 1244.63 ms 11.22 ms

App size

Revision Plain With Sentry Diff
77cd5e2 22.31 KiB 770.44 KiB 748.12 KiB
cabada0 22.31 KiB 775.04 KiB 752.72 KiB
edfaee8 22.31 KiB 773.65 KiB 751.33 KiB

Copy link
Member

@armcknight armcknight left a comment

Choose a reason for hiding this comment

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

Also nice 👍🏻 Looks like this one will need a few fixes for tests, tho

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.

I would like to keep the constants internal, please.

Copy link

🚨 Detected changes in high risk code 🚨

High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:

  • Sources/Sentry/SentryNetworkTracker.m

Copy link

🚨 Detected changes in high risk code 🚨

High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:

  • Sources/Sentry/SentryNetworkTracker.m

Copy link

🚨 Detected changes in high risk code 🚨

High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:

  • Sources/Sentry/SentryNetworkTracker.m

Copy link

🚨 Detected changes in high risk code 🚨

High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:

  • Sources/Sentry/SentryNetworkTracker.m

@philprime
Copy link
Contributor Author

philprime commented Jan 20, 2025

@brustolin can you please take a look at the failing SentryTimeToDisplayTrackerTest. testTracerFinishesBeforeReportInitialDisplay_FinishesInitialDisplaySpan.

I can't really tell why my changes break this test, and the test setup is quite complicated.

EDIT: Nevermind, found the issue.

Copy link

🚨 Detected changes in high risk code 🚨

High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:

  • Sources/Sentry/SentryNetworkTracker.m

Copy link

🚨 Detected changes in high risk code 🚨

High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:

  • Sources/Sentry/SentryNetworkTracker.m

Copy link

🚨 Detected changes in high risk code 🚨

High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:

  • Sources/Sentry/SentryNetworkTracker.m

Copy link

codecov bot commented Jan 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.233%. Comparing base (9f57953) to head (709c090).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #4717       +/-   ##
=============================================
+ Coverage   91.128%   91.233%   +0.105%     
=============================================
  Files          622       623        +1     
  Lines        72421     72459       +38     
  Branches     25746     26411      +665     
=============================================
+ Hits         65996     66107      +111     
+ Misses        6331      6255       -76     
- Partials        94        97        +3     
Files with missing lines Coverage Δ
Sources/Sentry/Profiling/SentryLaunchProfiling.m 90.983% <100.000%> (ø)
Sources/Sentry/SentryBuildAppStartSpans.m 100.000% <100.000%> (ø)
Sources/Sentry/SentryCoreDataTracker.m 97.887% <100.000%> (ø)
Sources/Sentry/SentryFileIOTracker.m 95.483% <100.000%> (ø)
Sources/Sentry/SentryHub.m 97.966% <100.000%> (ø)
Sources/Sentry/SentryNetworkTracker.m 96.560% <100.000%> (+0.016%) ⬆️
Sources/Sentry/SentrySpanContext.m 100.000% <100.000%> (ø)
Sources/Sentry/SentryTimeToDisplayTracker.m 100.000% <100.000%> (ø)
Sources/Sentry/SentryTracer.m 97.868% <ø> (ø)
Sources/Sentry/SentryTransactionContext.mm 100.000% <100.000%> (ø)
... and 4 more

... and 25 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 9f57953...709c090. Read the comment docs.

Copy link
Contributor

@brustolin brustolin left a comment

Choose a reason for hiding this comment

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

LGTM

@philprime philprime merged commit a0bb101 into main Jan 21, 2025
71 checks passed
@philprime philprime deleted the philprime/refactor-trace-origins branch January 21, 2025 11:56
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.

4 participants