Skip to content

Commit 0fd27d6

Browse files
committed
ref: Create thread inspector Swift protocol
1 parent d8ceea3 commit 0fd27d6

File tree

6 files changed

+27
-9
lines changed

6 files changed

+27
-9
lines changed

Sentry.xcodeproj/project.pbxproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,7 @@
10891089
FA7206DF2E0B37850072FDD4 /* SentryProfileCollector.h in Headers */ = {isa = PBXBuildFile; fileRef = FA7206DE2E0B37780072FDD4 /* SentryProfileCollector.h */; };
10901090
FA7206E12E0B37C80072FDD4 /* SentryProfileCollector.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA7206E02E0B37C60072FDD4 /* SentryProfileCollector.mm */; };
10911091
FA8A36182DEAA1EB0058D883 /* SentryThread+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = FA8A36172DEAA1EB0058D883 /* SentryThread+Private.h */; };
1092+
FA8AFCED2E8434A8007A0E18 /* SentryThreadInspecting.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA8AFCE72E8434A0007A0E18 /* SentryThreadInspecting.swift */; };
10921093
FA8E58F12E0AD4270049F69D /* SentryDispatchQueueWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA8E58F02E0AD4220049F69D /* SentryDispatchQueueWrapper.swift */; };
10931094
FA90FAA82E06614E008CAAE8 /* SentryExtraPackages.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA90FAA72E06614B008CAAE8 /* SentryExtraPackages.swift */; };
10941095
FA90FAFD2E070A3B008CAAE8 /* SentryURLRequestFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA90FAFC2E070A3B008CAAE8 /* SentryURLRequestFactory.swift */; };
@@ -1110,16 +1111,16 @@
11101111
FACEED132E3179A10007B4AC /* SentyOptionsInternal.m in Sources */ = {isa = PBXBuildFile; fileRef = FACEED122E3179A10007B4AC /* SentyOptionsInternal.m */; };
11111112
FAE2DAB82E1F317900262307 /* SentryProfilingSwiftHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = FAE2DAB72E1F317900262307 /* SentryProfilingSwiftHelpers.m */; };
11121113
FAE2DABA2E1F318900262307 /* SentryProfilingSwiftHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE2DAB92E1F318900262307 /* SentryProfilingSwiftHelpers.h */; };
1114+
FAE579842E7CF21800B710F9 /* SentryMigrateSessionInit.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE5797E2E7CF21300B710F9 /* SentryMigrateSessionInit.swift */; };
11131115
FAE5798D2E7D9D4C00B710F9 /* SentrySysctl.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE579872E7D9D4900B710F9 /* SentrySysctl.swift */; };
11141116
FAE579BA2E7DBE9900B710F9 /* SentryGlobalEventProcessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE579B42E7DBE9400B710F9 /* SentryGlobalEventProcessor.swift */; };
11151117
FAE579C22E7DDDE700B710F9 /* SentryThreadWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE579BC2E7DDDE400B710F9 /* SentryThreadWrapper.swift */; };
1116-
FAE579842E7CF21800B710F9 /* SentryMigrateSessionInit.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE5797E2E7CF21300B710F9 /* SentryMigrateSessionInit.swift */; };
11171118
FAE579CC2E7DE14900B710F9 /* SentryFrameRemover.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE579C62E7DE14400B710F9 /* SentryFrameRemover.swift */; };
11181119
FAE80C242E4695B40010A595 /* SentryEvent+Serialize.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE80C232E4695AE0010A595 /* SentryEvent+Serialize.h */; };
11191120
FAEC270E2DF3526000878871 /* SentryUserFeedback.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAEC270D2DF3526000878871 /* SentryUserFeedback.swift */; };
11201121
FAEC273D2DF3933A00878871 /* NSData+Unzip.m in Sources */ = {isa = PBXBuildFile; fileRef = FAEC273C2DF3933200878871 /* NSData+Unzip.m */; };
1121-
FAEEC0522E75E55F00E79CA9 /* SentrySerializationSwift.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAEEC04C2E75E55A00E79CA9 /* SentrySerializationSwift.swift */; };
11221122
FAEEBFE22E736D4B00E79CA9 /* SentryViewHierarchyProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAEEBFDC2E736D4100E79CA9 /* SentryViewHierarchyProvider.swift */; };
1123+
FAEEC0522E75E55F00E79CA9 /* SentrySerializationSwift.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAEEC04C2E75E55A00E79CA9 /* SentrySerializationSwift.swift */; };
11231124
FAEFA12F2E4FAE1900C431D9 /* SentrySDKSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAEFA1292E4FAE1700C431D9 /* SentrySDKSettings.swift */; };
11241125
FAF120182E70C08F006E1DA3 /* SentryEnvelopeHeaderHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = FAF120122E70C088006E1DA3 /* SentryEnvelopeHeaderHelper.h */; };
11251126
FAF1201A2E70C0EE006E1DA3 /* SentryEnvelopeHeaderHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = FAF120192E70C0EA006E1DA3 /* SentryEnvelopeHeaderHelper.m */; };
@@ -2433,6 +2434,7 @@
24332434
FA7206DE2E0B37780072FDD4 /* SentryProfileCollector.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SentryProfileCollector.h; sourceTree = "<group>"; };
24342435
FA7206E02E0B37C60072FDD4 /* SentryProfileCollector.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SentryProfileCollector.mm; sourceTree = "<group>"; };
24352436
FA8A36172DEAA1EB0058D883 /* SentryThread+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "SentryThread+Private.h"; path = "include/SentryThread+Private.h"; sourceTree = "<group>"; };
2437+
FA8AFCE72E8434A0007A0E18 /* SentryThreadInspecting.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryThreadInspecting.swift; sourceTree = "<group>"; };
24362438
FA8E58F02E0AD4220049F69D /* SentryDispatchQueueWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryDispatchQueueWrapper.swift; sourceTree = "<group>"; };
24372439
FA90FAA72E06614B008CAAE8 /* SentryExtraPackages.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryExtraPackages.swift; sourceTree = "<group>"; };
24382440
FA90FAFC2E070A3B008CAAE8 /* SentryURLRequestFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryURLRequestFactory.swift; sourceTree = "<group>"; };
@@ -2463,8 +2465,8 @@
24632465
FAEC270D2DF3526000878871 /* SentryUserFeedback.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUserFeedback.swift; sourceTree = "<group>"; };
24642466
FAEC273C2DF3933200878871 /* NSData+Unzip.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSData+Unzip.m"; sourceTree = "<group>"; };
24652467
FAEC273E2DF393E000878871 /* NSData+Unzip.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSData+Unzip.h"; sourceTree = "<group>"; };
2466-
FAEEC04C2E75E55A00E79CA9 /* SentrySerializationSwift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySerializationSwift.swift; sourceTree = "<group>"; };
24672468
FAEEBFDC2E736D4100E79CA9 /* SentryViewHierarchyProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryViewHierarchyProvider.swift; sourceTree = "<group>"; };
2469+
FAEEC04C2E75E55A00E79CA9 /* SentrySerializationSwift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySerializationSwift.swift; sourceTree = "<group>"; };
24682470
FAEFA1292E4FAE1700C431D9 /* SentrySDKSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySDKSettings.swift; sourceTree = "<group>"; };
24692471
FAF120122E70C088006E1DA3 /* SentryEnvelopeHeaderHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryEnvelopeHeaderHelper.h; path = include/SentryEnvelopeHeaderHelper.h; sourceTree = "<group>"; };
24702472
FAF120192E70C0EA006E1DA3 /* SentryEnvelopeHeaderHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryEnvelopeHeaderHelper.m; sourceTree = "<group>"; };
@@ -4743,6 +4745,7 @@
47434745
F4FE9E062E6248BB0014FED5 /* SentryCrash */ = {
47444746
isa = PBXGroup;
47454747
children = (
4748+
FA8AFCE72E8434A0007A0E18 /* SentryThreadInspecting.swift */,
47464749
FAE579C62E7DE14400B710F9 /* SentryFrameRemover.swift */,
47474750
F4FE9E072E6248E40014FED5 /* SentryCrashWrapper.swift */,
47484751
);
@@ -5564,6 +5567,7 @@
55645567
isa = PBXSourcesBuildPhase;
55655568
buildActionMask = 2147483647;
55665569
files = (
5570+
FA8AFCED2E8434A8007A0E18 /* SentryThreadInspecting.swift in Sources */,
55675571
7BFC16A125249A9D00FF6266 /* SentryMessage.m in Sources */,
55685572
FA90FAFD2E070A3B008CAAE8 /* SentryURLRequestFactory.swift in Sources */,
55695573
7BCFBD6F2681D0EE00BC27D8 /* SentryCrashScopeObserver.m in Sources */,

Sources/Sentry/SentryANRTrackingIntegration.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ @interface SentryANRTrackingIntegration () <SentryANRTrackerDelegate>
3232
@property (nonatomic, strong) SentryDispatchQueueWrapper *dispatchQueueWrapper;
3333
@property (nonatomic, strong) SentryCrashWrapper *crashWrapper;
3434
@property (nonatomic, strong) SentryDebugImageProvider *debugImageProvider;
35-
@property (nonatomic, strong) SentryThreadInspector *threadInspector;
35+
@property (nonatomic, strong) id<SentryThreadInspecting> threadInspector;
3636
@property (atomic, assign) BOOL reportAppHangs;
3737
@property (atomic, assign) BOOL enableReportNonFullyBlockingAppHangs;
3838

@@ -64,7 +64,7 @@ - (BOOL)installWithOptions:(SentryOptions *)options
6464
self.dispatchQueueWrapper = SentryDependencyContainer.sharedInstance.dispatchQueueWrapper;
6565
self.crashWrapper = SentryDependencyContainer.sharedInstance.crashWrapper;
6666
self.debugImageProvider = SentryDependencyContainer.sharedInstance.debugImageProvider;
67-
self.threadInspector = SentryDependencyContainer.sharedInstance.threadInspector;
67+
self.threadInspector = SentryDependencyContainer.sharedInstance.threadInspecting;
6868
[self.tracker addListener:self];
6969
self.options = options;
7070
self.reportAppHangs = YES;

Sources/Sentry/SentryDependencyContainer.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,13 @@
6161
@interface SentryFileManager () <SentryFileManagerProtocol>
6262
@end
6363

64+
@interface SentryThreadInspector () <SentryThreadInspecting>
65+
@end
66+
6467
@interface SentryDependencyContainer ()
6568

6669
@property (nonatomic, strong) id<SentryANRTracker> anrTracker;
70+
@property (nonatomic, strong) SentryThreadInspector *threadInspector;
6771

6872
@end
6973

@@ -215,6 +219,11 @@ - (SentryAppStateManager *)appStateManager SENTRY_THREAD_SANITIZER_DOUBLE_CHECKE
215219
notificationCenterWrapper:self.notificationCenterWrapper]);
216220
}
217221

222+
- (id<SentryThreadInspecting>)threadInspecting
223+
{
224+
return [self threadInspector];
225+
}
226+
218227
- (SentryThreadInspector *)threadInspector SENTRY_THREAD_SANITIZER_DOUBLE_CHECKED_LOCK
219228
{
220229
SENTRY_LAZY_INIT(_threadInspector,

Sources/Sentry/SentrySpan.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ - (instancetype)initWithContext:(SentrySpanContext *)context
6969
if ([NSThread isMainThread]) {
7070
_data[SPAN_DATA_THREAD_NAME] = @"main";
7171
} else {
72-
_data[SPAN_DATA_THREAD_NAME] = [SentryDependencyContainer.sharedInstance.threadInspector
73-
getThreadName:currentThread];
72+
_data[SPAN_DATA_THREAD_NAME] =
73+
[SentryDependencyContainer.sharedInstance.threadInspecting
74+
getThreadName:currentThread];
7475
}
7576

7677
#if SENTRY_HAS_UIKIT

Sources/Sentry/include/HybridPublic/SentryDependencyContainer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
@class SentryThreadsafeApplication;
2020
@class SentrySystemWrapper;
2121
@class SentryThreadWrapper;
22-
@class SentryThreadInspector;
2322
@class SentryFileIOTracker;
2423
@class SentryScopePersistentStore;
2524
@class SentryOptions;
@@ -34,6 +33,7 @@
3433
@protocol SentryProcessInfoSource;
3534
@protocol SentryDispatchQueueProviderProtocol;
3635
@protocol SentryNSNotificationCenterWrapper;
36+
@protocol SentryThreadInspecting;
3737
@protocol SentryObjCRuntimeWrapper;
3838

3939
#if SENTRY_HAS_METRIC_KIT
@@ -108,7 +108,7 @@ SENTRY_NO_INIT
108108

109109
@property (nonatomic, strong, nullable) SentryFileManager *fileManager;
110110
@property (nonatomic, strong) SentryAppStateManager *appStateManager;
111-
@property (nonatomic, strong) SentryThreadInspector *threadInspector;
111+
- (id<SentryThreadInspecting>)threadInspecting;
112112
@property (nonatomic, strong) SentryFileIOTracker *fileIOTracker;
113113
@property (nonatomic, strong) SentryCrash *crashReporter;
114114
@property (nonatomic, strong) SentryScopePersistentStore *scopePersistentStore;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@_spi(Private) @objc public protocol SentryThreadInspecting {
2+
func getCurrentThreadsWithStackTrace() -> [SentryThread]
3+
func getThreadName(_ thread: uintptr_t) -> String?
4+
}

0 commit comments

Comments
 (0)