Skip to content

Commit 6a99d24

Browse files
committed
Add thread info helper
1 parent f96ab19 commit 6a99d24

File tree

5 files changed

+52
-9
lines changed

5 files changed

+52
-9
lines changed

Sentry.xcodeproj/project.pbxproj

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@
783783
8ECC674725C23A20000E2BF6 /* SentrySpanContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ECC674325C23A1F000E2BF6 /* SentrySpanContext.m */; };
784784
8ECC674825C23A20000E2BF6 /* SentryTransaction.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ECC674425C23A1F000E2BF6 /* SentryTransaction.m */; };
785785
8ECC674925C23A20000E2BF6 /* SentrySpanId.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ECC674525C23A20000E2BF6 /* SentrySpanId.m */; };
786-
8ECC674A25C23A20000E2BF6 /* SentryTransactionContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8ECC674625C23A20000E2BF6 /* SentryTransactionContext.mm */; };
786+
8ECC674A25C23A20000E2BF6 /* SentryTransactionContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ECC674625C23A20000E2BF6 /* SentryTransactionContext.m */; };
787787
8ED3D306264DFE700049393B /* SwiftDescriptorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8ED3D305264DFE700049393B /* SwiftDescriptorTests.swift */; };
788788
8EE017A126704CD500470616 /* SentryUIViewControllerPerformanceTrackerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EA1ED0E2669152F00E62B98 /* SentryUIViewControllerPerformanceTrackerTests.swift */; };
789789
8F0D6AA22B04115A00D048B1 /* SentryInstallation+Test.h in Sources */ = {isa = PBXBuildFile; fileRef = 8F0D6AA12B040A0100D048B1 /* SentryInstallation+Test.h */; };
@@ -1035,6 +1035,8 @@
10351035
FA67DD172DDBD4EA00896B02 /* SentryLogOutput.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA67DCEC2DDBD4EA00896B02 /* SentryLogOutput.swift */; };
10361036
FA67DD182DDBD4EA00896B02 /* UIImageHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA67DCED2DDBD4EA00896B02 /* UIImageHelper.swift */; };
10371037
FA67DD192DDBD4EA00896B02 /* SwizzleClassNameExclude.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA67DCD52DDBD4EA00896B02 /* SwizzleClassNameExclude.swift */; };
1038+
FA8A36162DEAA1D50058D883 /* ThreadInfoHelper.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA8A36152DEAA1D50058D883 /* ThreadInfoHelper.mm */; };
1039+
FA8A36182DEAA1EB0058D883 /* ThreadInfoHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = FA8A36172DEAA1EB0058D883 /* ThreadInfoHelper.h */; };
10381040
/* End PBXBuildFile section */
10391041

10401042
/* Begin PBXContainerItemProxy section */
@@ -1974,7 +1976,7 @@
19741976
8ECC674325C23A1F000E2BF6 /* SentrySpanContext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentrySpanContext.m; sourceTree = "<group>"; };
19751977
8ECC674425C23A1F000E2BF6 /* SentryTransaction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentryTransaction.m; sourceTree = "<group>"; };
19761978
8ECC674525C23A20000E2BF6 /* SentrySpanId.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentrySpanId.m; sourceTree = "<group>"; };
1977-
8ECC674625C23A20000E2BF6 /* SentryTransactionContext.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SentryTransactionContext.mm; sourceTree = "<group>"; };
1979+
8ECC674625C23A20000E2BF6 /* SentryTransactionContext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentryTransactionContext.m; sourceTree = "<group>"; };
19781980
8ED3D305264DFE700049393B /* SwiftDescriptorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftDescriptorTests.swift; sourceTree = "<group>"; };
19791981
8F0D6AA12B040A0100D048B1 /* SentryInstallation+Test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SentryInstallation+Test.h"; sourceTree = "<group>"; };
19801982
8F73BC302B02B87E00C3CEF4 /* SentryInstallationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryInstallationTests.swift; sourceTree = "<group>"; };
@@ -2248,6 +2250,8 @@
22482250
FA67DCEF2DDBD4EA00896B02 /* URLSessionTaskHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLSessionTaskHelper.swift; sourceTree = "<group>"; };
22492251
FA67DCF12DDBD4EA00896B02 /* SentryExperimentalOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryExperimentalOptions.swift; sourceTree = "<group>"; };
22502252
FA67DCF22DDBD4EA00896B02 /* SwiftDescriptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftDescriptor.swift; sourceTree = "<group>"; };
2253+
FA8A36152DEAA1D50058D883 /* ThreadInfoHelper.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ThreadInfoHelper.mm; sourceTree = "<group>"; };
2254+
FA8A36172DEAA1EB0058D883 /* ThreadInfoHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ThreadInfoHelper.h; path = include/ThreadInfoHelper.h; sourceTree = "<group>"; };
22512255
/* End PBXFileReference section */
22522256

22532257
/* Begin PBXFrameworksBuildPhase section */
@@ -3839,6 +3843,8 @@
38393843
8ECC673625C23936000E2BF6 /* Transaction */ = {
38403844
isa = PBXGroup;
38413845
children = (
3846+
FA8A36172DEAA1EB0058D883 /* ThreadInfoHelper.h */,
3847+
FA8A36152DEAA1D50058D883 /* ThreadInfoHelper.mm */,
38423848
D8603DD7284F894C000E1227 /* SentryBaggage.h */,
38433849
D8603DD4284F8497000E1227 /* SentryBaggage.m */,
38443850
620379DA2AFE1415005AC0C1 /* SentryBuildAppStartSpans.h */,
@@ -3885,7 +3891,7 @@
38853891
8E4E7C6B25DAAAFE006AB9E2 /* SentryTransaction.h */,
38863892
8ECC674425C23A1F000E2BF6 /* SentryTransaction.m */,
38873893
8ECC673B25C23996000E2BF6 /* SentryTransactionContext.h */,
3888-
8ECC674625C23A20000E2BF6 /* SentryTransactionContext.mm */,
3894+
8ECC674625C23A20000E2BF6 /* SentryTransactionContext.m */,
38893895
0A56DA5E28ABA01B00C400D5 /* SentryTransactionContext+Private.h */,
38903896
);
38913897
name = Transaction;
@@ -4738,6 +4744,7 @@
47384744
7BA61CB9247BC57B00C130A8 /* SentryCrashDefaultBinaryImageProvider.h in Headers */,
47394745
8E4E7C7D25DAB287006AB9E2 /* SentryTracer.h in Headers */,
47404746
7BC8523724588115005A70F0 /* SentryDataCategory.h in Headers */,
4747+
FA8A36182DEAA1EB0058D883 /* ThreadInfoHelper.h in Headers */,
47414748
62A456E32B0370AA003F19A1 /* SentryUIEventTrackerTransactionMode.h in Headers */,
47424749
63FE714B20DA4C1100CDBAE8 /* SentryCrashString.h in Headers */,
47434750
7BCFBD6D2681D0A900BC27D8 /* SentryCrashScopeObserver.h in Headers */,
@@ -5119,7 +5126,7 @@
51195126
D8ACE3C82762187200F5A213 /* SentryFileIOTracker.m in Sources */,
51205127
7BE3C77D2446112C00A38442 /* SentryRateLimitParser.m in Sources */,
51215128
D8B088B729C9E3FF00213258 /* SentryTracerConfiguration.m in Sources */,
5122-
8ECC674A25C23A20000E2BF6 /* SentryTransactionContext.mm in Sources */,
5129+
8ECC674A25C23A20000E2BF6 /* SentryTransactionContext.m in Sources */,
51235130
03BCC38C27E1C01A003232C7 /* SentryTime.mm in Sources */,
51245131
A8F17B342902870300990B25 /* SentryHttpStatusCodeRange.m in Sources */,
51255132
62C97D3A2CC64E6B00DDA204 /* SentryUncaughtNSExceptions.m in Sources */,
@@ -5168,6 +5175,7 @@
51685175
63FE708D20DA4C1000CDBAE8 /* SentryCrashReportFilterBasic.m in Sources */,
51695176
63FE718120DA4C1100CDBAE8 /* SentryCrashDoctor.m in Sources */,
51705177
63FE713720DA4C1100CDBAE8 /* SentryCrashCPU_x86_64.c in Sources */,
5178+
FA8A36162DEAA1D50058D883 /* ThreadInfoHelper.mm in Sources */,
51715179
8ECC674725C23A20000E2BF6 /* SentrySpanContext.m in Sources */,
51725180
D473ACD72D8090FC000F1CC6 /* FileManager+SentryTracing.swift in Sources */,
51735181
D4AF00212D2E92FD00F5F3D7 /* SentryNSFileManagerSwizzling.m in Sources */,

Sources/Sentry/PrivateSentrySDKOnly.mm

Lines changed: 1 addition & 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"
@@ -28,6 +27,7 @@
2827
#if SENTRY_TARGET_PROFILING_SUPPORTED
2928
# import "SentryProfiledTracerConcurrency.h"
3029
# import "SentryProfilerSerialization.h"
30+
# import "SentrySwift.h"
3131
# import "SentryTraceProfiler.h"
3232
#endif // SENTRY_TARGET_PROFILING_SUPPORTED
3333

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
#import "SentrySpanContext+Private.h"
55
#import "SentrySwift.h"
66
#import "SentryThread.h"
7-
#include "SentryThreadHandle.hpp"
87
#import "SentryTraceOrigin.h"
98
#import "SentryTransactionContext+Private.h"
9+
#import "ThreadInfoHelper.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 = [ThreadInfoHelper threadInfo];
202201
#endif
203202
}
204203

Sources/Sentry/ThreadInfoHelper.mm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#import "ThreadInfoHelper.h"
2+
#import "SentryThread.h"
3+
#include "SentryThreadHandle.hpp"
4+
5+
#if SENTRY_TARGET_PROFILING_SUPPORTED
6+
7+
@implementation ThreadInfoHelper
8+
9+
+ (SentryThread *)threadInfo
10+
{
11+
const auto threadID = sentry::profiling::ThreadHandle::current()->tid();
12+
return [[SentryThread alloc] initWithThreadId:@(threadID)];
13+
}
14+
15+
@end
16+
17+
#endif
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include "SentryProfilingConditionals.h"
2+
#import <Foundation/Foundation.h>
3+
4+
#if SENTRY_TARGET_PROFILING_SUPPORTED
5+
6+
@class SentryThread;
7+
8+
NS_ASSUME_NONNULL_BEGIN
9+
10+
// Helper function to access C++ in a file that does not import Swift
11+
@interface ThreadInfoHelper : NSObject
12+
13+
+ (SentryThread *)threadInfo;
14+
15+
@end
16+
17+
NS_ASSUME_NONNULL_END
18+
19+
#endif

0 commit comments

Comments
 (0)