-
-
Notifications
You must be signed in to change notification settings - Fork 337
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
fix: Add manual file IO tracking for Swift.Data #4605
base: main
Are you sure you want to change the base?
Conversation
🚨 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:
|
We could consider to refactor the class |
Performance metrics 🚀
|
Revision | Plain | With Sentry | Diff |
---|---|---|---|
b695b61 | 1221.71 ms | 1249.18 ms | 27.47 ms |
0589699 | 1243.25 ms | 1252.60 ms | 9.35 ms |
3ea21f5 | 1250.80 ms | 1258.88 ms | 8.08 ms |
407ff99 | 1190.89 ms | 1237.18 ms | 46.29 ms |
904d7fa | 1225.73 ms | 1249.22 ms | 23.49 ms |
c471221 | 1224.16 ms | 1241.59 ms | 17.43 ms |
1928267 | 1200.94 ms | 1227.17 ms | 26.23 ms |
09311b6 | 1238.67 ms | 1255.04 ms | 16.37 ms |
ed49f0c | 1215.94 ms | 1245.63 ms | 29.69 ms |
973d574 | 1240.86 ms | 1255.83 ms | 14.98 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
b695b61 | 21.90 KiB | 707.65 KiB | 685.75 KiB |
0589699 | 21.58 KiB | 656.60 KiB | 635.02 KiB |
3ea21f5 | 22.84 KiB | 402.63 KiB | 379.78 KiB |
407ff99 | 20.76 KiB | 427.86 KiB | 407.10 KiB |
904d7fa | 20.76 KiB | 432.87 KiB | 412.11 KiB |
c471221 | 22.85 KiB | 413.89 KiB | 391.04 KiB |
1928267 | 22.30 KiB | 730.78 KiB | 708.47 KiB |
09311b6 | 21.58 KiB | 654.67 KiB | 633.09 KiB |
ed49f0c | 21.58 KiB | 632.13 KiB | 610.55 KiB |
973d574 | 21.58 KiB | 542.38 KiB | 520.80 KiB |
Previous results on branch: philprime/file-io-tracking-fix
Startup times
Revision | Plain | With Sentry | Diff |
---|---|---|---|
e7b3309 | 1233.23 ms | 1251.71 ms | 18.47 ms |
e9ec0cb | 1221.08 ms | 1242.90 ms | 21.81 ms |
ec1acc1 | 1237.65 ms | 1250.54 ms | 12.90 ms |
1f201e0 | 1231.24 ms | 1254.83 ms | 23.59 ms |
8b628ff | 1213.15 ms | 1239.17 ms | 26.01 ms |
80a6dda | 1239.90 ms | 1252.33 ms | 12.43 ms |
6a01c37 | 1229.94 ms | 1243.82 ms | 13.88 ms |
ae13629 | 1228.47 ms | 1246.39 ms | 17.92 ms |
3588c99 | 1242.96 ms | 1264.22 ms | 21.27 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
e7b3309 | 22.31 KiB | 779.13 KiB | 756.82 KiB |
e9ec0cb | 22.31 KiB | 770.73 KiB | 748.42 KiB |
ec1acc1 | 22.31 KiB | 770.06 KiB | 747.75 KiB |
1f201e0 | 22.30 KiB | 751.69 KiB | 729.39 KiB |
8b628ff | 22.30 KiB | 751.72 KiB | 729.42 KiB |
80a6dda | 22.30 KiB | 751.72 KiB | 729.42 KiB |
6a01c37 | 22.31 KiB | 778.67 KiB | 756.36 KiB |
ae13629 | 22.31 KiB | 770.92 KiB | 748.60 KiB |
3588c99 | 22.31 KiB | 778.24 KiB | 755.93 KiB |
🚨 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:
|
Thanks for this investigation. Since you enable testing for iOS 18.2, we have other I/O tests failing. We could solve them in a different PR that will merge to this one, or disable those tests before merging this to Main. |
🚨 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:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4605 +/- ##
=============================================
+ Coverage 91.189% 91.225% +0.036%
=============================================
Files 624 628 +4
Lines 72082 72404 +322
Branches 26219 26321 +102
=============================================
+ Hits 65731 66051 +320
- Misses 6254 6255 +1
- Partials 97 98 +1
... and 6 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
🚨 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:
|
🚨 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:
|
🚨 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:
|
After an internal brainstorming/discussion, we decided to change the user-facing API to be an extension of I'll update the PR accordingly. |
🚨 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:
|
🚨 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:
|
🚨 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:
|
🚨 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:
|
🚨 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:
|
🚨 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:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't give this a full pass yet cause I found one potential major issue that could require some significant changes to the PR, which could make plenty of comments obsolete.
@@ -188,7 +224,7 @@ - (BOOL)measureNSFileManagerCreateFileAtPath:(NSString *)path | |||
} | |||
|
|||
SENTRY_LOG_DEBUG( | |||
@"SentryNSDataTracker automatically started a new span with description: %@, operation: %@", | |||
@"SentryFileIOTracker automatically started a new span with description: %@, operation: %@", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l
: The log messages include the class name when using the macro.
@"SentryFileIOTracker automatically started a new span with description: %@, operation: %@", | |
@"Automatically started a new span with description: %@, operation: %@", |
@@ -269,7 +310,7 @@ - (void)finishTrackingNSData:(NSData *)data span:(id<SentrySpan>)span | |||
[span setDataValue:[NSNumber numberWithUnsignedInteger:data.length] forKey:@"file.size"]; | |||
[span finish]; | |||
|
|||
SENTRY_LOG_DEBUG(@"SentryNSDataTracker automatically finished span %@", span.description); | |||
SENTRY_LOG_DEBUG(@"SentryFileIOTracker automatically finished span %@", span.description); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l
:
SENTRY_LOG_DEBUG(@"SentryFileIOTracker automatically finished span %@", span.description); | |
SENTRY_LOG_DEBUG(@"Automatically finished span %@", span.description); |
// We dont track reads from a url that is not a file url | ||
// because these reads are handled by NSURLSession and | ||
// SentryNetworkTracker will create spans in these cases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comment 👍
// Note: Consider adding new operations to the `SentrySpanOperation` enum in | ||
// `SentrySpanOperations.swift` instead of adding them here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l
: I think it would be great to migrate all of these to the enum in a follow up PR or even doing this small refactoring before merging this PR and base this PR on this refactoring
|
||
class SentrySpanOperationTests: XCTestCase { | ||
|
||
/// This test asserts that the constant matches the SDK specification. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l
: To me these comments are verbose. IMO, we can remove them.
/// This test asserts that the constant matches the SDK specification. |
/// | ||
/// - Note: Methods provided by this extension reflect the same functionality as the original `Data` methods, | ||
/// but they automatically track the operation with Sentry. | ||
@available(iOS 18, macOS 15, tvOS 18, *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
h
: This will make using the API a bit complicated, because our users need to do this
let data = "SOME DATA".data(using: .utf8) ?? Data()
if #available(iOS 18, macOS 15, tvOS 18, *) {
try data.writeWithSentryTracing(to: fileURL)
} else {
try data.write(to: fileURL)
}
Instead, I think when they decide using writeWithSentryTracing
, we need to ensure that we're not creating duplicated spans for the file IO operations on older OS versions. It should be this:
let data = "SOME DATA".data(using: .utf8) ?? Data()
try data.write(to: fixture.fileURL)
try data.writeWithSentryTracing(to: fixture.fileURL)
Otherwise, all users have to deal with this complexity.
Open Sub Tasks:
SentryNSDataTracker
toSentryFileIOTracker
SentryFileIOTrackingIntegrationTests.swift
Out-of-scope for this PR:
Closes #4546