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

feat: Add manual file IO tracking for Swift.Data and Swift.FileManager #4605

Open
wants to merge 53 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
f1f5a44
fix(tests): add swizzling for NSFileManager
philprime Dec 6, 2024
b196c30
Update CHANGELOG.MD
philprime Dec 6, 2024
c0bb33d
Add iOS 18 and macOS 15 to GH workflow tests
philprime Dec 6, 2024
bc22ac9
Revert removal of import statement
philprime Dec 6, 2024
effcf8e
fix: add OS availability check to file manager swizzling
philprime Dec 6, 2024
7bf668c
add tvOS 18 and mac catalyst to test workflows
philprime Dec 6, 2024
74dd90c
rename SentryNSDataTracker to SentryFileIOTracker; add SentryDataWrapper
philprime Dec 12, 2024
750052a
Merge remote-tracking branch 'origin/main' into philprime/file-io-tra…
philprime Dec 13, 2024
123871d
revert changes after splitting PR
philprime Dec 13, 2024
e002163
revert changes after splitting PR
philprime Dec 13, 2024
ef74f63
removed deprecated method
philprime Dec 16, 2024
dc8c924
Merge remote-tracking branch 'origin/main' into philprime/file-io-tra…
philprime Dec 16, 2024
11c4806
Remove header
philprime Dec 16, 2024
5dc2ead
add WIP for tracking file.read/file.write spans
philprime Dec 17, 2024
be33890
Merge remote-tracking branch 'origin/main' into philprime/file-io-tra…
philprime Dec 18, 2024
07abf5d
Merge remote-tracking branch 'origin/main' into philprime/file-io-tra…
philprime Dec 18, 2024
7047a61
wip
philprime Dec 18, 2024
036da29
add wip changes to reuse data tracker in Swift
philprime Dec 20, 2024
e6cf6f0
Merge remote-tracking branch 'origin/main' into philprime/file-io-tra…
philprime Jan 9, 2025
c856d5a
Merge remote-tracking branch 'origin/main' into philprime/file-io-tra…
philprime Jan 13, 2025
8a3a012
refactor to type extension
philprime Jan 13, 2025
b03c19a
add trace origin to swift file
philprime Jan 13, 2025
1e4c13e
add file io tracker to dependency container
philprime Jan 13, 2025
335207c
refactor changes
philprime Jan 13, 2025
b790458
wip
philprime Jan 13, 2025
4ff6f4e
revert changes in SentrySpanOperations.h
philprime Jan 13, 2025
4ef283e
add more tests, refactored tests
philprime Jan 13, 2025
f29de60
remove unused imported headers
philprime Jan 13, 2025
7f22a1d
Merge branch 'main' into philprime/file-io-tracking-fix
philprime Jan 13, 2025
89e13c0
add more verbose xcframework build logs
philprime Jan 14, 2025
3828edd
refactor measure methods to Swift
philprime Jan 14, 2025
7143715
Merge remote-tracking branch 'origin/main' into philprime/file-io-tra…
philprime Jan 14, 2025
0c917bb
Merge remote-tracking branch 'origin/main' into philprime/file-io-tra…
philprime Jan 14, 2025
f6954d2
Merge remote-tracking branch 'origin/main' into philprime/file-io-tra…
philprime Jan 16, 2025
444a139
applied feedback
philprime Jan 16, 2025
f1e4816
add defer to finish tracking nsdata
philprime Jan 16, 2025
7595a6a
Merge remote-tracking branch 'origin/main' into philprime/file-io-tra…
philprime Jan 22, 2025
530ca0e
Merge remote-tracking branch 'origin/main' into philprime/file-io-tra…
philprime Jan 23, 2025
185097a
fix changelog
philprime Jan 23, 2025
2ffd120
fix duplicate spans
philprime Jan 23, 2025
0ca0bcb
revert change in sample
philprime Jan 23, 2025
15393b0
Update Sources/Swift/Integrations/Performance/IO/Data+SentryTracing.s…
philprime Feb 6, 2025
f12b0c3
Merge remote-tracking branch 'origin/main' into philprime/file-io-tra…
philprime Feb 6, 2025
5d688e6
wip
philprime Feb 12, 2025
c1a15fe
wip
philprime Feb 13, 2025
244d1f0
Merge remote-tracking branch 'origin/main' into philprime/file-io-tra…
philprime Feb 13, 2025
732f394
wip
philprime Feb 13, 2025
2105097
disable swizzling in file io tests
philprime Feb 13, 2025
c08b598
fix test configuration
philprime Feb 13, 2025
8b609d9
add more tests
philprime Feb 13, 2025
b54b4f3
Add more tests
philprime Feb 13, 2025
eb8ed5d
add tests
philprime Feb 13, 2025
e4be2f7
Merge remote-tracking branch 'origin/main' into philprime/file-io-tra…
philprime Feb 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Add `showMaskPreview` to `SentrySDK.replay` api to debug replay masking (#4761)
- Session replay masking preview for SwiftUI (#4737)
- HTTP Breadcrumb level based on response status code (#4779) 4xx is warning, 5xx is error.
- Add manual file IO tracking methods for Swift.Data and Swift.FileManager (#4605)

Choose a reason for hiding this comment

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

  • 🚫 The changelog entry seems to be part of an already released section ## 8.45.0.
    Consider moving the entry to the ## Unreleased section, please.

- Measure app hang duration for AppHangTrackingV2 (#4836)

### Improvements
Expand Down
36 changes: 36 additions & 0 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,11 @@
A8F17B2E2901765900990B25 /* SentryRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = A8F17B2D2901765900990B25 /* SentryRequest.m */; };
A8F17B342902870300990B25 /* SentryHttpStatusCodeRange.m in Sources */ = {isa = PBXBuildFile; fileRef = A8F17B332902870300990B25 /* SentryHttpStatusCodeRange.m */; };
D42E48572D48DF1600D251BC /* SentryBuildAppStartSpansTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D42E48562D48DF1600D251BC /* SentryBuildAppStartSpansTests.swift */; };
D43647AB2D5CAA32001468E0 /* FileManager+SentryTracing.swift in Sources */ = {isa = PBXBuildFile; fileRef = D43647AA2D5CAA32001468E0 /* FileManager+SentryTracing.swift */; };
D43647EF2D5CF9E3001468E0 /* SentrySpanKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = D43647EE2D5CF9DC001468E0 /* SentrySpanKey.swift */; };
D43647F12D5CFB71001468E0 /* SentrySpanKeyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D43647F02D5CFB71001468E0 /* SentrySpanKeyTests.swift */; };
D43647F32D5CFBC7001468E0 /* FileManagerTracingIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D43647F22D5CFBC2001468E0 /* FileManagerTracingIntegrationTests.swift */; };
D468C0622D3669A200964230 /* SentryFileIOTracker+SwiftHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = D468C0612D3669A200964230 /* SentryFileIOTracker+SwiftHelpers.swift */; };
D48724DB2D352597005DE483 /* SentryTraceOrigin.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48724DA2D352591005DE483 /* SentryTraceOrigin.swift */; };
D48724DD2D354939005DE483 /* SentrySpanOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48724DC2D354934005DE483 /* SentrySpanOperation.swift */; };
D48724E02D3549CA005DE483 /* SentrySpanOperationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48724DF2D3549C6005DE483 /* SentrySpanOperationTests.swift */; };
Expand All @@ -820,8 +825,10 @@
D4AF00212D2E92FD00F5F3D7 /* SentryNSFileManagerSwizzling.m in Sources */ = {isa = PBXBuildFile; fileRef = D4AF00202D2E92FD00F5F3D7 /* SentryNSFileManagerSwizzling.m */; };
D4AF00232D2E931000F5F3D7 /* SentryNSFileManagerSwizzling.h in Headers */ = {isa = PBXBuildFile; fileRef = D4AF00222D2E931000F5F3D7 /* SentryNSFileManagerSwizzling.h */; };
D4AF00252D2E93C400F5F3D7 /* SentryNSFileManagerSwizzlingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D4AF00242D2E93C400F5F3D7 /* SentryNSFileManagerSwizzlingTests.m */; };
D4C5F59A2D4249E6002A9BF6 /* DataSentryTracingIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C5F5992D4249E0002A9BF6 /* DataSentryTracingIntegrationTests.swift */; };
D4E3F35D2D4A864600F79E2B /* SentryNSDictionarySanitizeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D42E48582D48FC8F00D251BC /* SentryNSDictionarySanitizeTests.swift */; };
D4E3F35E2D4A877300F79E2B /* SentryNSDictionarySanitize+Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = D41909942D490006002B83D0 /* SentryNSDictionarySanitize+Tests.m */; };
D4EDF9842D0B2A210071E7B3 /* Data+SentryTracing.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4EDF9832D0B2A1D0071E7B3 /* Data+SentryTracing.swift */; };
D4F2B5352D0C69D500649E42 /* SentryCrashCTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4F2B5342D0C69D100649E42 /* SentryCrashCTests.swift */; };
D8019910286B089000C277F0 /* SentryCrashReportSinkTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D801990F286B089000C277F0 /* SentryCrashReportSinkTests.swift */; };
D802994E2BA836EF000F0081 /* SentryOnDemandReplay.swift in Sources */ = {isa = PBXBuildFile; fileRef = D802994D2BA836EF000F0081 /* SentryOnDemandReplay.swift */; };
Expand Down Expand Up @@ -1949,6 +1956,11 @@
D41909942D490006002B83D0 /* SentryNSDictionarySanitize+Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "SentryNSDictionarySanitize+Tests.m"; sourceTree = "<group>"; };
D42E48562D48DF1600D251BC /* SentryBuildAppStartSpansTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryBuildAppStartSpansTests.swift; sourceTree = "<group>"; };
D42E48582D48FC8F00D251BC /* SentryNSDictionarySanitizeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryNSDictionarySanitizeTests.swift; sourceTree = "<group>"; };
D43647AA2D5CAA32001468E0 /* FileManager+SentryTracing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileManager+SentryTracing.swift"; sourceTree = "<group>"; };
D43647EE2D5CF9DC001468E0 /* SentrySpanKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySpanKey.swift; sourceTree = "<group>"; };
D43647F02D5CFB71001468E0 /* SentrySpanKeyTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SentrySpanKeyTests.swift; sourceTree = "<group>"; };
D43647F22D5CFBC2001468E0 /* FileManagerTracingIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileManagerTracingIntegrationTests.swift; sourceTree = "<group>"; };
D468C0612D3669A200964230 /* SentryFileIOTracker+SwiftHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SentryFileIOTracker+SwiftHelpers.swift"; sourceTree = "<group>"; };
D48724DA2D352591005DE483 /* SentryTraceOrigin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryTraceOrigin.swift; sourceTree = "<group>"; };
D48724DC2D354934005DE483 /* SentrySpanOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySpanOperation.swift; sourceTree = "<group>"; };
D48724DF2D3549C6005DE483 /* SentrySpanOperationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySpanOperationTests.swift; sourceTree = "<group>"; };
Expand All @@ -1958,6 +1970,8 @@
D4AF00202D2E92FD00F5F3D7 /* SentryNSFileManagerSwizzling.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryNSFileManagerSwizzling.m; sourceTree = "<group>"; };
D4AF00222D2E931000F5F3D7 /* SentryNSFileManagerSwizzling.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryNSFileManagerSwizzling.h; path = include/SentryNSFileManagerSwizzling.h; sourceTree = "<group>"; };
D4AF00242D2E93C400F5F3D7 /* SentryNSFileManagerSwizzlingTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryNSFileManagerSwizzlingTests.m; sourceTree = "<group>"; };
D4C5F5992D4249E0002A9BF6 /* DataSentryTracingIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataSentryTracingIntegrationTests.swift; sourceTree = "<group>"; };
D4EDF9832D0B2A1D0071E7B3 /* Data+SentryTracing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Data+SentryTracing.swift"; sourceTree = "<group>"; };
D4F2B5342D0C69D100649E42 /* SentryCrashCTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryCrashCTests.swift; sourceTree = "<group>"; };
D800942628F82F3A005D3943 /* SwiftDescriptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftDescriptor.swift; sourceTree = "<group>"; };
D801990F286B089000C277F0 /* SentryCrashReportSinkTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryCrashReportSinkTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3780,11 +3794,22 @@
name = Transaction;
sourceTree = "<group>";
};
D468C0602D36699700964230 /* IO */ = {
isa = PBXGroup;
children = (
D4EDF9832D0B2A1D0071E7B3 /* Data+SentryTracing.swift */,
D43647AA2D5CAA32001468E0 /* FileManager+SentryTracing.swift */,
D468C0612D3669A200964230 /* SentryFileIOTracker+SwiftHelpers.swift */,
);
path = IO;
sourceTree = "<group>";
};
D48724D92D35258A005DE483 /* Transactions */ = {
isa = PBXGroup;
children = (
D48724DA2D352591005DE483 /* SentryTraceOrigin.swift */,
D48724DC2D354934005DE483 /* SentrySpanOperation.swift */,
D43647EE2D5CF9DC001468E0 /* SentrySpanKey.swift */,
);
path = Transactions;
sourceTree = "<group>";
Expand All @@ -3794,6 +3819,7 @@
children = (
D48724E12D354D16005DE483 /* SentryTraceOriginTests.swift */,
D48724DF2D3549C6005DE483 /* SentrySpanOperationTests.swift */,
D43647F02D5CFB71001468E0 /* SentrySpanKeyTests.swift */,
);
path = Transactions;
sourceTree = "<group>";
Expand Down Expand Up @@ -4000,6 +4026,7 @@
D8739CF72BECFF92007D2F66 /* Performance */ = {
isa = PBXGroup;
children = (
D468C0602D36699700964230 /* IO */,
6294287F2CB3BF4E002C454C /* SwizzleClassNameExclude.swift */,
D8739CF82BECFFB5007D2F66 /* SentryTransactionNameSource.swift */,
);
Expand All @@ -4009,6 +4036,8 @@
D875ED09276CC83200422FAC /* IO */ = {
isa = PBXGroup;
children = (
D43647F22D5CFBC2001468E0 /* FileManagerTracingIntegrationTests.swift */,
D4C5F5992D4249E0002A9BF6 /* DataSentryTracingIntegrationTests.swift */,
D875ED0A276CC84700422FAC /* SentryFileIOTrackerTests.swift */,
D8CE69BB277E39C700C6EC5C /* SentryFileIOTrackingIntegrationObjCTests.m */,
D885266327739D01001269FC /* SentryFileIOTrackingIntegrationTests.swift */,
Expand Down Expand Up @@ -4937,6 +4966,7 @@
843FB3232D0CD04D00558F18 /* SentryUserAccess.m in Sources */,
63FE716720DA4C1100CDBAE8 /* SentryCrashCPU.c in Sources */,
63FE717320DA4C1100CDBAE8 /* SentryCrashC.c in Sources */,
D43647AB2D5CAA32001468E0 /* FileManager+SentryTracing.swift in Sources */,
6293F5752D422A95002BC3BD /* SentryStacktraceCodable.swift in Sources */,
63FE712120DA4C1000CDBAE8 /* SentryCrashSymbolicator.c in Sources */,
627C77892D50B6840055E966 /* SentryBreadcrumbCodable.swift in Sources */,
Expand All @@ -4957,6 +4987,7 @@
D82859432C3E753C009A28AA /* SentrySessionReplaySyncC.c in Sources */,
D833D57C2D10784800961E7A /* SentryRRWebOptionsEvent.swift in Sources */,
84A8891D28DBD28900C51DFD /* SentryDevice.mm in Sources */,
D43647EF2D5CF9E3001468E0 /* SentrySpanKey.swift in Sources */,
7B56D73324616D9500B842DA /* SentryConcurrentRateLimitsDictionary.m in Sources */,
8ECC674825C23A20000E2BF6 /* SentryTransaction.m in Sources */,
0A80E433291017C300095219 /* SentryWatchdogTerminationScopeObserver.m in Sources */,
Expand Down Expand Up @@ -5014,6 +5045,7 @@
D84D2CC32C29AD120011AF8A /* SentrySessionReplay.swift in Sources */,
849B8F9B2C6E906900148E1F /* SentryUserFeedbackIntegrationDriver.swift in Sources */,
63FE70DF20DA4C1000CDBAE8 /* SentryCrashMonitorType.c in Sources */,
D468C0622D3669A200964230 /* SentryFileIOTracker+SwiftHelpers.swift in Sources */,
7BF9EF7E2722B91F00B5BBEF /* SentryDefaultObjCRuntimeWrapper.m in Sources */,
7BC3936E25B1AB72004F03D3 /* SentryLevelMapper.m in Sources */,
6304360B1EC0595B00C4D3FA /* SentryNSDataUtils.m in Sources */,
Expand All @@ -5033,6 +5065,7 @@
7BB65501253DC1B500887E87 /* SentryUserFeedback.m in Sources */,
7D5C441A237C2E1F00DAB0A3 /* SentrySDK.m in Sources */,
7D65260E237F649E00113EA2 /* SentryScope.m in Sources */,
D4EDF9842D0B2A210071E7B3 /* Data+SentryTracing.swift in Sources */,
84281C472A57905700EE88F2 /* SentrySample.m in Sources */,
84AC61D329F7541E009EEF61 /* SentryDispatchSourceWrapper.m in Sources */,
62A456E52B0370E0003F19A1 /* SentryUIEventTrackerTransactionMode.m in Sources */,
Expand Down Expand Up @@ -5332,6 +5365,7 @@
8E70B0FD25CB72BE002B3155 /* SentrySpanTests.swift in Sources */,
7BBD188F2448469A00427C76 /* HttpDateFormatter.swift in Sources */,
63FE720C20DA66EC00CDBAE8 /* SentryCrashMonitor_Tests.m in Sources */,
D4C5F59A2D4249E6002A9BF6 /* DataSentryTracingIntegrationTests.swift in Sources */,
D855B3EA27D652C700BCED76 /* TestCoreDataStack.swift in Sources */,
D8AE48C12C57B1550092A2A6 /* SentryLevelTests.swift in Sources */,
63FE721820DA66EC00CDBAE8 /* TestThread.m in Sources */,
Expand All @@ -5341,6 +5375,7 @@
8F73BC312B02B87E00C3CEF4 /* SentryInstallationTests.swift in Sources */,
7B569E002590EEF600B653FC /* SentryScope+Equality.m in Sources */,
D8BFE37929A76666002E73F3 /* SentryTimeToDisplayTrackerTest.swift in Sources */,
D43647F32D5CFBC7001468E0 /* FileManagerTracingIntegrationTests.swift in Sources */,
D84541182A2DC2CD00E2B11C /* SentryBinaryImageCacheTests.swift in Sources */,
7BF536D424BEF255004FA6A2 /* SentryAssertions.swift in Sources */,
7BC6EC14255C415E0059822A /* SentryExceptionTests.swift in Sources */,
Expand Down Expand Up @@ -5392,6 +5427,7 @@
7BF9EF7A2722B58900B5BBEF /* SentrySubClassFinderTests.swift in Sources */,
D48724E02D3549CA005DE483 /* SentrySpanOperationTests.swift in Sources */,
7B59398224AB47650003AAD2 /* SentrySessionTrackerTests.swift in Sources */,
D43647F12D5CFB71001468E0 /* SentrySpanKeyTests.swift in Sources */,
7B05A61824A4D14A00EF211D /* SentrySessionGeneratorTests.swift in Sources */,
D8CB742B294B1DD000A5F964 /* SentryUIApplicationTests.swift in Sources */,
63FE720920DA66EC00CDBAE8 /* XCTestCase+SentryCrash.m in Sources */,
Expand Down
16 changes: 16 additions & 0 deletions Sources/Sentry/SentryDependencyContainer.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#import "SentryDispatchQueueWrapper.h"
#import "SentryDisplayLinkWrapper.h"
#import "SentryExtraContextProvider.h"
#import "SentryFileIOTracker.h"
#import "SentryFileManager.h"
#import "SentryInternalCDefines.h"
#import "SentryLog.h"
Expand Down Expand Up @@ -186,6 +187,21 @@ - (SentryThreadInspector *)threadInspector SENTRY_DISABLE_THREAD_SANITIZER(
return _threadInspector;
}

- (SentryFileIOTracker *)fileIOTracker SENTRY_DISABLE_THREAD_SANITIZER(
"double-checked lock produce false alarms")
{
if (_fileIOTracker == nil) {
@synchronized(sentryDependencyContainerLock) {
if (_fileIOTracker == nil) {
_fileIOTracker =
[[SentryFileIOTracker alloc] initWithThreadInspector:[self threadInspector]
processInfoWrapper:[self processInfoWrapper]];
}
}
}
return _fileIOTracker;
}

- (SentryDebugImageProvider *)debugImageProvider
{
@synchronized(sentryDependencyContainerLock) {
Expand Down
Loading
Loading