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 extension for FileManager to track file I/O operations with Sentry #4863

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Features

- Add extension for `FileManager` to track file I/O operations with Sentry (#4863)

## 8.45.0

### Features
Expand Down
24 changes: 22 additions & 2 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@
D42E48572D48DF1600D251BC /* SentryBuildAppStartSpansTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D42E48562D48DF1600D251BC /* SentryBuildAppStartSpansTests.swift */; };
D43647EF2D5CF9E3001468E0 /* SentrySpanDataKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = D43647EE2D5CF9DC001468E0 /* SentrySpanDataKey.swift */; };
D43647F12D5CFB71001468E0 /* SentrySpanKeyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D43647F02D5CFB71001468E0 /* SentrySpanKeyTests.swift */; };
D43647F32D5CFBC7001468E0 /* FileManagerTracingIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D43647F22D5CFBC2001468E0 /* FileManagerTracingIntegrationTests.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 @@ -822,6 +823,8 @@
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 */; };
D4DB995B2D6778EB000AD63F /* SentryFileIOTracker+SwiftHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4DB99592D6778EB000AD63F /* SentryFileIOTracker+SwiftHelpers.swift */; };
D4DB995C2D6778EB000AD63F /* FileManager+SentryTracing.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4DB99582D6778EB000AD63F /* FileManager+SentryTracing.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 */; };
D4F2B5352D0C69D500649E42 /* SentryCrashCTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4F2B5342D0C69D100649E42 /* SentryCrashCTests.swift */; };
Expand Down Expand Up @@ -1951,6 +1954,9 @@
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>"; };
D43647EE2D5CF9DC001468E0 /* SentrySpanDataKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySpanDataKey.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>"; };
D46D45E12D5F3FD600A1CB35 /* Sentry_Base.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = Sentry_Base.xctestplan; sourceTree = "<group>"; };
D46D45E32D5F402100A1CB35 /* iOS-Swift_Base.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = "iOS-Swift_Base.xctestplan"; sourceTree = "<group>"; };
D46D45E42D5F403E00A1CB35 /* iOS-Swift-Benchmarking_Base.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = "iOS-Swift-Benchmarking_Base.xctestplan"; path = "Plans/iOS-Swift-Benchmarking_Base.xctestplan"; sourceTree = SOURCE_ROOT; };
Expand All @@ -1960,8 +1966,6 @@
D46D45E82D5F40FA00A1CB35 /* SentryProfilerTests_Base.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = SentryProfilerTests_Base.xctestplan; path = Plans/SentryProfilerTests_Base.xctestplan; sourceTree = SOURCE_ROOT; };
D46D45E92D5F411700A1CB35 /* SentrySwiftUI_Base.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = SentrySwiftUI_Base.xctestplan; path = Plans/SentrySwiftUI_Base.xctestplan; sourceTree = SOURCE_ROOT; };
D46D45EA2D5F412100A1CB35 /* SentryTests_Base.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = SentryTests_Base.xctestplan; path = Plans/SentryTests_Base.xctestplan; sourceTree = SOURCE_ROOT; };
D43647EE2D5CF9DC001468E0 /* SentrySpanDataKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySpanDataKey.swift; sourceTree = "<group>"; };
D43647F02D5CFB71001468E0 /* SentrySpanKeyTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SentrySpanKeyTests.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 @@ -1979,6 +1983,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>"; };
D4DB99582D6778EB000AD63F /* FileManager+SentryTracing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileManager+SentryTracing.swift"; sourceTree = "<group>"; };
D4DB99592D6778EB000AD63F /* SentryFileIOTracker+SwiftHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SentryFileIOTracker+SwiftHelpers.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 @@ -3846,6 +3852,15 @@
path = Transactions;
sourceTree = "<group>";
};
D4DB995A2D6778EB000AD63F /* IO */ = {
isa = PBXGroup;
children = (
D4DB99582D6778EB000AD63F /* FileManager+SentryTracing.swift */,
D4DB99592D6778EB000AD63F /* SentryFileIOTracker+SwiftHelpers.swift */,
);
path = IO;
sourceTree = "<group>";
};
D4F2B5332D0C69CC00649E42 /* Recording */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -4048,6 +4063,7 @@
D8739CF72BECFF92007D2F66 /* Performance */ = {
isa = PBXGroup;
children = (
D4DB995A2D6778EB000AD63F /* IO */,
6294287F2CB3BF4E002C454C /* SwizzleClassNameExclude.swift */,
D8739CF82BECFFB5007D2F66 /* SentryTransactionNameSource.swift */,
);
Expand All @@ -4057,6 +4073,7 @@
D875ED09276CC83200422FAC /* IO */ = {
isa = PBXGroup;
children = (
D43647F22D5CFBC2001468E0 /* FileManagerTracingIntegrationTests.swift */,
D875ED0A276CC84700422FAC /* SentryFileIOTrackerTests.swift */,
D8CE69BB277E39C700C6EC5C /* SentryFileIOTrackingIntegrationObjCTests.m */,
D885266327739D01001269FC /* SentryFileIOTrackingIntegrationTests.swift */,
Expand Down Expand Up @@ -4938,6 +4955,8 @@
7BBC827125DFD039005F1ED8 /* SentryInAppLogic.m in Sources */,
63FE708D20DA4C1000CDBAE8 /* SentryCrashReportFilterBasic.m in Sources */,
63FE718120DA4C1100CDBAE8 /* SentryCrashDoctor.m in Sources */,
D4DB995B2D6778EB000AD63F /* SentryFileIOTracker+SwiftHelpers.swift in Sources */,
D4DB995C2D6778EB000AD63F /* FileManager+SentryTracing.swift in Sources */,
63FE713720DA4C1100CDBAE8 /* SentryCrashCPU_x86_64.c in Sources */,
8ECC674725C23A20000E2BF6 /* SentrySpanContext.m in Sources */,
D4AF00212D2E92FD00F5F3D7 /* SentryNSFileManagerSwizzling.m in Sources */,
Expand Down Expand Up @@ -5390,6 +5409,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
7 changes: 7 additions & 0 deletions Sources/Sentry/SentryFileIOTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@
return result;
}

- (nullable id<SentrySpan>)spanForPath:(NSString *)path
origin:(NSString *)origin
operation:(NSString *)operation
{
return [self spanForPath:path origin:origin operation:operation size:0];

Check warning on line 185 in Sources/Sentry/SentryFileIOTracker.m

View check run for this annotation

Codecov / codecov/patch

Sources/Sentry/SentryFileIOTracker.m#L184-L185

Added lines #L184 - L185 were not covered by tests
}

- (nullable id<SentrySpan>)spanForPath:(NSString *)path
origin:(NSString *)origin
operation:(NSString *)operation
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/SentryFileIOTrackingIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

- (SentryIntegrationOption)integrationOptions
{
return kIntegrationOptionEnableSwizzling | kIntegrationOptionIsTracingEnabled
| kIntegrationOptionEnableAutoPerformanceTracing | kIntegrationOptionEnableFileIOTracing;
return kIntegrationOptionIsTracingEnabled | kIntegrationOptionEnableAutoPerformanceTracing
| kIntegrationOptionEnableFileIOTracing;

Check warning on line 34 in Sources/Sentry/SentryFileIOTrackingIntegration.m

View check run for this annotation

Codecov / codecov/patch

Sources/Sentry/SentryFileIOTrackingIntegration.m#L33-L34

Added lines #L33 - L34 were not covered by tests
}

- (void)uninstall
Expand Down
10 changes: 10 additions & 0 deletions Sources/Sentry/include/SentryFileIOTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ SENTRY_NO_INIT
method:(BOOL (^)(NSString *, NSData *,
NSDictionary<NSFileAttributeKey, id> *))method;

// MARK: - Internal Methods available for Swift Extension

- (nullable id<SentrySpan>)spanForPath:(NSString *)path
origin:(NSString *)origin
operation:(NSString *)operation;
- (nullable id<SentrySpan>)spanForPath:(NSString *)path
origin:(NSString *)origin
operation:(NSString *)operation
size:(NSUInteger)size;

@end

NS_ASSUME_NONNULL_END
Loading
Loading