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 SentrySpanOperations to Swift #4718

Merged
merged 9 commits into from
Jan 20, 2025

Conversation

philprime
Copy link
Contributor

📜 Description

Collects all global constants defined in SentrySpanOperations.h and other various variables into 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
  • Span operation names are defined in the Sentry specification and should be managed in one spot to match the spec
  • 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?

CI 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

@philprime philprime changed the title refactor: convert constants SentrySpanOrigins to Swift refactor: Convert constants SentrySpanOrigins to Swift 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

github-actions bot commented Jan 15, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1220.78 ms 1251.63 ms 30.86 ms
Size 22.31 KiB 773.84 KiB 751.53 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
3478fc5 1237.94 ms 1251.13 ms 13.19 ms
16d73bf 1200.12 ms 1221.10 ms 20.98 ms
39b1c35 1236.35 ms 1239.90 ms 3.55 ms
6bc31df 1202.52 ms 1215.86 ms 13.34 ms
f587451 1271.63 ms 1275.90 ms 4.27 ms
af1f4dd 1225.39 ms 1245.48 ms 20.09 ms
fdb003d 1214.51 ms 1230.49 ms 15.98 ms
98752f3 1240.61 ms 1259.80 ms 19.18 ms
e072ad1 1241.17 ms 1256.65 ms 15.48 ms
aad68bb 1221.12 ms 1237.41 ms 16.29 ms

App size

Revision Plain With Sentry Diff
3478fc5 21.58 KiB 654.59 KiB 633.01 KiB
16d73bf 21.58 KiB 669.90 KiB 648.32 KiB
39b1c35 22.85 KiB 408.88 KiB 386.03 KiB
6bc31df 21.58 KiB 544.86 KiB 523.28 KiB
f587451 20.76 KiB 435.25 KiB 414.49 KiB
af1f4dd 22.85 KiB 414.71 KiB 391.86 KiB
fdb003d 22.85 KiB 414.11 KiB 391.26 KiB
98752f3 20.76 KiB 435.09 KiB 414.33 KiB
e072ad1 21.58 KiB 625.83 KiB 604.24 KiB
aad68bb 21.58 KiB 542.38 KiB 520.80 KiB

Previous results on branch: philprime/refactor-span-operations

Startup times

Revision Plain With Sentry Diff
5b4c600 1226.88 ms 1244.53 ms 17.66 ms
b3783b2 1226.64 ms 1243.39 ms 16.74 ms

App size

Revision Plain With Sentry Diff
5b4c600 22.31 KiB 773.84 KiB 751.53 KiB
b3783b2 22.31 KiB 770.49 KiB 748.17 KiB

Copy link

codecov bot commented Jan 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.205%. Comparing base (f59d0bf) to head (5526f37).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main     #4718   +/-   ##
=========================================
  Coverage   91.204%   91.205%           
=========================================
  Files          621       622    +1     
  Lines        72392     72428   +36     
  Branches     26369     26390   +21     
=========================================
+ Hits         66025     66058   +33     
- Misses        6267      6272    +5     
+ Partials       100        98    -2     
Files with missing lines Coverage Δ
Sources/Sentry/Profiling/SentryLaunchProfiling.m 90.983% <100.000%> (ø)
Sources/Sentry/SentryCoreDataTracker.m 97.887% <100.000%> (ø)
Sources/Sentry/SentryFileIOTracker.m 95.483% <100.000%> (ø)
Sources/Sentry/SentryNetworkTracker.m 96.551% <100.000%> (-0.009%) ⬇️
Sources/Sentry/SentryTimeToDisplayTracker.m 100.000% <100.000%> (ø)
Sources/Sentry/SentryTracer.m 97.377% <100.000%> (+0.327%) ⬆️
Sources/Sentry/SentryUIEventTracker.m 100.000% <100.000%> (ø)
...urces/Sentry/SentryUIEventTrackerTransactionMode.m 100.000% <100.000%> (ø)
.../Sentry/SentryUIViewControllerPerformanceTracker.m 99.317% <100.000%> (ø)
...SentryProfilerTests/SentryProfileTestFixture.swift 99.703% <100.000%> (ø)
... and 8 more

... and 10 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 f59d0bf...5526f37. Read the comment docs.

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.

Nice 👍🏻

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 if possible.

@philprime philprime changed the title refactor: Convert constants SentrySpanOrigins to Swift refactor: Convert constants SentrySpanOperations to Swift Jan 20, 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

🚨 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
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.

LGTM

@philprime philprime merged commit 9f57953 into main Jan 20, 2025
71 checks passed
@philprime philprime deleted the philprime/refactor-span-operations branch January 20, 2025 15:54
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