Skip to content

Commit db5ab22

Browse files
committed
Add thread info helper
1 parent f96ab19 commit db5ab22

File tree

4 files changed

+40
-5
lines changed

4 files changed

+40
-5
lines changed

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)