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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1232.10 ms 1240.49 ms 8.39 ms
Size 22.31 KiB 770.44 KiB 748.12 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
716a5b0 1240.21 ms 1265.81 ms 25.60 ms
26d116c 1196.14 ms 1209.51 ms 13.37 ms
9e96fd6 1207.20 ms 1229.40 ms 22.20 ms
75ef4eb 1237.30 ms 1249.53 ms 12.23 ms
2a769ba 1217.92 ms 1239.78 ms 21.86 ms
52e4912 1216.25 ms 1226.69 ms 10.44 ms
8919322 1231.83 ms 1255.24 ms 23.41 ms
99fe600 1226.16 ms 1236.88 ms 10.71 ms
2ccbd03 1225.13 ms 1247.51 ms 22.39 ms
f74904f 1229.02 ms 1244.91 ms 15.89 ms

App size

Revision Plain With Sentry Diff
716a5b0 22.31 KiB 756.95 KiB 734.64 KiB
26d116c 21.58 KiB 417.87 KiB 396.29 KiB
9e96fd6 20.76 KiB 425.80 KiB 405.04 KiB
75ef4eb 22.85 KiB 413.45 KiB 390.60 KiB
2a769ba 21.58 KiB 683.64 KiB 662.05 KiB
52e4912 21.58 KiB 418.14 KiB 396.56 KiB
8919322 22.84 KiB 403.18 KiB 380.34 KiB
99fe600 21.90 KiB 708.13 KiB 686.23 KiB
2ccbd03 21.58 KiB 546.20 KiB 524.62 KiB
f74904f 21.58 KiB 418.71 KiB 397.12 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.

import Foundation

@objcMembers
public class SentryTraceOrigin: NSObject {
Copy link
Member

Choose a reason for hiding this comment

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

h: Again I would like to keep this internal, same as here: #4718 (comment)

Copy link
Contributor Author

@philprime philprime Jan 16, 2025

Choose a reason for hiding this comment

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

We'll discuss in comment

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.

3 participants