Skip to content

Commit ec7496f

Browse files
authored
Add thread info helper (#5331)
* Add thread info helper * PR comments
1 parent 7baef41 commit ec7496f

File tree

5 files changed

+51
-13
lines changed

5 files changed

+51
-13
lines changed

Sentry.xcodeproj/project.pbxproj

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@
190190
639FCF981EBC7B9700778193 /* SentryEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 639FCF961EBC7B9700778193 /* SentryEvent.h */; settings = {ATTRIBUTES = (Public, ); }; };
191191
639FCF991EBC7B9700778193 /* SentryEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 639FCF971EBC7B9700778193 /* SentryEvent.m */; };
192192
639FCF9C1EBC7F9500778193 /* SentryThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 639FCF9A1EBC7F9500778193 /* SentryThread.h */; settings = {ATTRIBUTES = (Public, ); }; };
193-
639FCF9D1EBC7F9500778193 /* SentryThread.m in Sources */ = {isa = PBXBuildFile; fileRef = 639FCF9B1EBC7F9500778193 /* SentryThread.m */; };
193+
639FCF9D1EBC7F9500778193 /* SentryThread.mm in Sources */ = {isa = PBXBuildFile; fileRef = 639FCF9B1EBC7F9500778193 /* SentryThread.mm */; };
194194
639FCFA01EBC804600778193 /* SentryException.h in Headers */ = {isa = PBXBuildFile; fileRef = 639FCF9E1EBC804600778193 /* SentryException.h */; settings = {ATTRIBUTES = (Public, ); }; };
195195
639FCFA11EBC804600778193 /* SentryException.m in Sources */ = {isa = PBXBuildFile; fileRef = 639FCF9F1EBC804600778193 /* SentryException.m */; };
196196
639FCFA41EBC809A00778193 /* SentryStacktrace.h in Headers */ = {isa = PBXBuildFile; fileRef = 639FCFA21EBC809A00778193 /* SentryStacktrace.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -784,7 +784,7 @@
784784
8ECC674725C23A20000E2BF6 /* SentrySpanContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ECC674325C23A1F000E2BF6 /* SentrySpanContext.m */; };
785785
8ECC674825C23A20000E2BF6 /* SentryTransaction.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ECC674425C23A1F000E2BF6 /* SentryTransaction.m */; };
786786
8ECC674925C23A20000E2BF6 /* SentrySpanId.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ECC674525C23A20000E2BF6 /* SentrySpanId.m */; };
787-
8ECC674A25C23A20000E2BF6 /* SentryTransactionContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8ECC674625C23A20000E2BF6 /* SentryTransactionContext.mm */; };
787+
8ECC674A25C23A20000E2BF6 /* SentryTransactionContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ECC674625C23A20000E2BF6 /* SentryTransactionContext.m */; };
788788
8ED3D306264DFE700049393B /* SwiftDescriptorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8ED3D305264DFE700049393B /* SwiftDescriptorTests.swift */; };
789789
8EE017A126704CD500470616 /* SentryUIViewControllerPerformanceTrackerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EA1ED0E2669152F00E62B98 /* SentryUIViewControllerPerformanceTrackerTests.swift */; };
790790
8F0D6AA22B04115A00D048B1 /* SentryInstallation+Test.h in Sources */ = {isa = PBXBuildFile; fileRef = 8F0D6AA12B040A0100D048B1 /* SentryInstallation+Test.h */; };
@@ -1048,6 +1048,7 @@
10481048
FA67DD172DDBD4EA00896B02 /* SentryLogOutput.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA67DCEC2DDBD4EA00896B02 /* SentryLogOutput.swift */; };
10491049
FA67DD182DDBD4EA00896B02 /* UIImageHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA67DCED2DDBD4EA00896B02 /* UIImageHelper.swift */; };
10501050
FA67DD192DDBD4EA00896B02 /* SwizzleClassNameExclude.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA67DCD52DDBD4EA00896B02 /* SwizzleClassNameExclude.swift */; };
1051+
FA8A36182DEAA1EB0058D883 /* SentryThread+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = FA8A36172DEAA1EB0058D883 /* SentryThread+Private.h */; };
10511052
/* End PBXBuildFile section */
10521053

10531054
/* Begin PBXContainerItemProxy section */
@@ -1321,7 +1322,7 @@
13211322
639FCF961EBC7B9700778193 /* SentryEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryEvent.h; path = Public/SentryEvent.h; sourceTree = "<group>"; };
13221323
639FCF971EBC7B9700778193 /* SentryEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentryEvent.m; sourceTree = "<group>"; };
13231324
639FCF9A1EBC7F9500778193 /* SentryThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryThread.h; path = Public/SentryThread.h; sourceTree = "<group>"; };
1324-
639FCF9B1EBC7F9500778193 /* SentryThread.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentryThread.m; sourceTree = "<group>"; };
1325+
639FCF9B1EBC7F9500778193 /* SentryThread.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SentryThread.mm; sourceTree = "<group>"; };
13251326
639FCF9E1EBC804600778193 /* SentryException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryException.h; path = Public/SentryException.h; sourceTree = "<group>"; };
13261327
639FCF9F1EBC804600778193 /* SentryException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentryException.m; sourceTree = "<group>"; };
13271328
639FCFA21EBC809A00778193 /* SentryStacktrace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryStacktrace.h; path = Public/SentryStacktrace.h; sourceTree = "<group>"; };
@@ -1988,7 +1989,7 @@
19881989
8ECC674325C23A1F000E2BF6 /* SentrySpanContext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentrySpanContext.m; sourceTree = "<group>"; };
19891990
8ECC674425C23A1F000E2BF6 /* SentryTransaction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentryTransaction.m; sourceTree = "<group>"; };
19901991
8ECC674525C23A20000E2BF6 /* SentrySpanId.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentrySpanId.m; sourceTree = "<group>"; };
1991-
8ECC674625C23A20000E2BF6 /* SentryTransactionContext.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SentryTransactionContext.mm; sourceTree = "<group>"; };
1992+
8ECC674625C23A20000E2BF6 /* SentryTransactionContext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentryTransactionContext.m; sourceTree = "<group>"; };
19921993
8ED3D305264DFE700049393B /* SwiftDescriptorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftDescriptorTests.swift; sourceTree = "<group>"; };
19931994
8F0D6AA12B040A0100D048B1 /* SentryInstallation+Test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SentryInstallation+Test.h"; sourceTree = "<group>"; };
19941995
8F73BC302B02B87E00C3CEF4 /* SentryInstallationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryInstallationTests.swift; sourceTree = "<group>"; };
@@ -2274,6 +2275,7 @@
22742275
FA67DCEF2DDBD4EA00896B02 /* URLSessionTaskHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLSessionTaskHelper.swift; sourceTree = "<group>"; };
22752276
FA67DCF12DDBD4EA00896B02 /* SentryExperimentalOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryExperimentalOptions.swift; sourceTree = "<group>"; };
22762277
FA67DCF22DDBD4EA00896B02 /* SwiftDescriptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftDescriptor.swift; sourceTree = "<group>"; };
2278+
FA8A36172DEAA1EB0058D883 /* SentryThread+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "SentryThread+Private.h"; path = "include/SentryThread+Private.h"; sourceTree = "<group>"; };
22772279
/* End PBXFileReference section */
22782280

22792281
/* Begin PBXFrameworksBuildPhase section */
@@ -2511,7 +2513,7 @@
25112513
639FCFA21EBC809A00778193 /* SentryStacktrace.h */,
25122514
639FCFA31EBC809A00778193 /* SentryStacktrace.m */,
25132515
639FCF9A1EBC7F9500778193 /* SentryThread.h */,
2514-
639FCF9B1EBC7F9500778193 /* SentryThread.m */,
2516+
639FCF9B1EBC7F9500778193 /* SentryThread.mm */,
25152517
639FCFAA1EBC811400778193 /* SentryUser.h */,
25162518
639FCFAB1EBC811400778193 /* SentryUser.m */,
25172519
843FB3212D0CD04D00558F18 /* SentryUserAccess.h */,
@@ -3880,6 +3882,7 @@
38803882
8ECC673625C23936000E2BF6 /* Transaction */ = {
38813883
isa = PBXGroup;
38823884
children = (
3885+
FA8A36172DEAA1EB0058D883 /* SentryThread+Private.h */,
38833886
D8603DD7284F894C000E1227 /* SentryBaggage.h */,
38843887
D8603DD4284F8497000E1227 /* SentryBaggage.m */,
38853888
620379DA2AFE1415005AC0C1 /* SentryBuildAppStartSpans.h */,
@@ -3926,7 +3929,7 @@
39263929
8E4E7C6B25DAAAFE006AB9E2 /* SentryTransaction.h */,
39273930
8ECC674425C23A1F000E2BF6 /* SentryTransaction.m */,
39283931
8ECC673B25C23996000E2BF6 /* SentryTransactionContext.h */,
3929-
8ECC674625C23A20000E2BF6 /* SentryTransactionContext.mm */,
3932+
8ECC674625C23A20000E2BF6 /* SentryTransactionContext.m */,
39303933
0A56DA5E28ABA01B00C400D5 /* SentryTransactionContext+Private.h */,
39313934
);
39323935
name = Transaction;
@@ -4834,6 +4837,7 @@
48344837
7BA61CB9247BC57B00C130A8 /* SentryCrashDefaultBinaryImageProvider.h in Headers */,
48354838
8E4E7C7D25DAB287006AB9E2 /* SentryTracer.h in Headers */,
48364839
7BC8523724588115005A70F0 /* SentryDataCategory.h in Headers */,
4840+
FA8A36182DEAA1EB0058D883 /* SentryThread+Private.h in Headers */,
48374841
62A456E32B0370AA003F19A1 /* SentryUIEventTrackerTransactionMode.h in Headers */,
48384842
63FE714B20DA4C1100CDBAE8 /* SentryCrashString.h in Headers */,
48394843
7BCFBD6D2681D0A900BC27D8 /* SentryCrashScopeObserver.h in Headers */,
@@ -5215,7 +5219,7 @@
52155219
D8ACE3C82762187200F5A213 /* SentryFileIOTracker.m in Sources */,
52165220
7BE3C77D2446112C00A38442 /* SentryRateLimitParser.m in Sources */,
52175221
D8B088B729C9E3FF00213258 /* SentryTracerConfiguration.m in Sources */,
5218-
8ECC674A25C23A20000E2BF6 /* SentryTransactionContext.mm in Sources */,
5222+
8ECC674A25C23A20000E2BF6 /* SentryTransactionContext.m in Sources */,
52195223
03BCC38C27E1C01A003232C7 /* SentryTime.mm in Sources */,
52205224
A8F17B342902870300990B25 /* SentryHttpStatusCodeRange.m in Sources */,
52215225
62C97D3A2CC64E6B00DDA204 /* SentryUncaughtNSExceptions.m in Sources */,
@@ -5449,7 +5453,7 @@
54495453
63FE712D20DA4C1100CDBAE8 /* SentryCrashJSONCodecObjC.m in Sources */,
54505454
7BBD18932449BEDD00427C76 /* SentryDefaultRateLimits.m in Sources */,
54515455
7BD729982463E93500EA3610 /* SentryDateUtil.m in Sources */,
5452-
639FCF9D1EBC7F9500778193 /* SentryThread.m in Sources */,
5456+
639FCF9D1EBC7F9500778193 /* SentryThread.mm in Sources */,
54535457
D88B30A92D48D8C3008DE513 /* SentryMaskingPreviewView.swift in Sources */,
54545458
849B8F992C6E906900148E1F /* SentryUserFeedbackFormConfiguration.swift in Sources */,
54555459
8E8C57A225EEFC07001CEEFA /* SentrySampling.m in Sources */,

Sources/Sentry/PrivateSentrySDKOnly.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#import "SentrySDK+Private.h"
1414
#import "SentrySerialization.h"
1515
#import "SentrySessionReplayIntegration+Private.h"
16-
#import "SentrySwift.h"
1716
#import "SentryThreadHandle.hpp"
1817
#import "SentryUser+Private.h"
1918
#import "SentryViewHierarchy.h"
@@ -31,6 +30,10 @@
3130
# import "SentryTraceProfiler.h"
3231
#endif // SENTRY_TARGET_PROFILING_SUPPORTED
3332

33+
#if SENTRY_TARGET_PROFILING_SUPPORTED || SENTRY_TARGET_REPLAY_SUPPORTED
34+
# import "SentrySwift.h"
35+
#endif // SENTRY_TARGET_PROFILING_SUPPORTED || SENTRY_TARGET_REPLAY_SUPPORTED
36+
3437
@implementation PrivateSentrySDKOnly
3538

3639
static SentryOnAppStartMeasurementAvailable _onAppStartMeasurementAvailable;

Sources/Sentry/SentryThread.m renamed to Sources/Sentry/SentryThread.mm

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
#import "SentryThread.h"
22
#import "NSMutableDictionary+Sentry.h"
3+
#include "SentryProfilingConditionals.h"
34
#import "SentryStacktrace.h"
45

6+
#if SENTRY_TARGET_PROFILING_SUPPORTED
7+
# include "SentryThreadHandle.hpp"
8+
#endif // SENTRY_TARGET_PROFILING_SUPPORTED
9+
510
NS_ASSUME_NONNULL_BEGIN
611

712
@implementation SentryThread
@@ -28,6 +33,16 @@ - (instancetype)initWithThreadId:(NSNumber *)threadId
2833
return serializedData;
2934
}
3035

36+
#if SENTRY_TARGET_PROFILING_SUPPORTED
37+
38+
+ (SentryThread *)threadInfo
39+
{
40+
const auto threadID = sentry::profiling::ThreadHandle::current()->tid();
41+
return [[SentryThread alloc] initWithThreadId:@(threadID)];
42+
}
43+
44+
#endif // SENTRY_TARGET_PROFILING_SUPPORTED
45+
3146
@end
3247

3348
NS_ASSUME_NONNULL_END

Sources/Sentry/SentryTransactionContext.mm renamed to Sources/Sentry/SentryTransactionContext.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
#include "SentryProfilingConditionals.h"
44
#import "SentrySpanContext+Private.h"
55
#import "SentrySwift.h"
6+
#import "SentryThread+Private.h"
67
#import "SentryThread.h"
7-
#include "SentryThreadHandle.hpp"
88
#import "SentryTraceOrigin.h"
99
#import "SentryTransactionContext+Private.h"
1010

1111
NS_ASSUME_NONNULL_BEGIN
1212

13-
static const auto kSentryDefaultSamplingDecision = kSentrySampleDecisionUndecided;
13+
static const NSUInteger kSentryDefaultSamplingDecision = kSentrySampleDecisionUndecided;
1414

1515
@implementation SentryTransactionContext
1616

@@ -197,8 +197,7 @@ - (instancetype)initWithName:(NSString *)name
197197
- (void)getThreadInfo
198198
{
199199
#if SENTRY_TARGET_PROFILING_SUPPORTED
200-
const auto threadID = sentry::profiling::ThreadHandle::current()->tid();
201-
self.threadInfo = [[SentryThread alloc] initWithThreadId:@(threadID)];
200+
self.threadInfo = [SentryThread threadInfo];
202201
#endif
203202
}
204203

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "SentryProfilingConditionals.h"
2+
#include "SentryThread.h"
3+
#import <Foundation/Foundation.h>
4+
5+
#if SENTRY_TARGET_PROFILING_SUPPORTED
6+
7+
NS_ASSUME_NONNULL_BEGIN
8+
9+
@interface SentryThread ()
10+
11+
+ (SentryThread *)threadInfo;
12+
13+
@end
14+
15+
NS_ASSUME_NONNULL_END
16+
17+
#endif

0 commit comments

Comments
 (0)