Skip to content

Commit 3c66029

Browse files
committed
ref: SentryPerformanceTracker in Swift
1 parent f747c9c commit 3c66029

File tree

19 files changed

+159
-60
lines changed

19 files changed

+159
-60
lines changed

Samples/iOS-SwiftUI/iOS-SwiftUI.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ targets:
2929
- ../Shared/SampleAssets.xcassets
3030
- ../../Sources/Sentry/Public/SentrySerializable.h
3131
- ../../Sources/Sentry/include/SentryTracer.h
32-
- ../../Sources/Sentry/include/SentryPerformanceTracker.h
3332
- ../../Sources/Sentry/Public/SentryProfilingConditionals.h
3433
dependencies:
3534
- target: Sentry/Sentry

Samples/iOS-SwiftUI/iOS-SwiftUI/ContentView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Sentry
1+
@_spi(Private) import Sentry
22
import SentrySwiftUI
33
import SwiftUI
44

Samples/iOS-SwiftUI/iOS-SwiftUI/FormScreen.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Foundation
2+
@_spi(Private) import Sentry
23
import SentrySwiftUI
34
import SwiftUI
45

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
#import "SentryPerformanceTracker.h"
21
#import "SentryTracer.h"

Sentry.xcodeproj/project.pbxproj

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -713,9 +713,9 @@
713713
8EAC7FF8265C8910005B44E5 /* SentryTracerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EAC7FF7265C8910005B44E5 /* SentryTracerTests.swift */; };
714714
8EAE8E5E2681768000D6958B /* URLSessionTaskMock.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EAE8E5D2681768000D6958B /* URLSessionTaskMock.m */; };
715715
8EAE9806261E87120073B6B3 /* SentryUIViewControllerPerformanceTracker.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EAE9804261E87120073B6B3 /* SentryUIViewControllerPerformanceTracker.m */; };
716-
8EAE980B261E9F530073B6B3 /* SentryPerformanceTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 8EAE9809261E9F530073B6B3 /* SentryPerformanceTracker.h */; };
716+
8EAE980B261E9F530073B6B3 /* SentryPerformanceTrackerHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 8EAE9809261E9F530073B6B3 /* SentryPerformanceTrackerHelper.h */; };
717717
8EAE980C261E9F530073B6B3 /* SentryUIViewControllerPerformanceTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 8EAE980A261E9F530073B6B3 /* SentryUIViewControllerPerformanceTracker.h */; };
718-
8EBF870926140D37001A6853 /* SentryPerformanceTracker.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EBF870726140D37001A6853 /* SentryPerformanceTracker.m */; };
718+
8EBF870926140D37001A6853 /* SentryPerformanceTrackerHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EBF870726140D37001A6853 /* SentryPerformanceTrackerHelper.m */; };
719719
8EC3AE7A25CA23B600E7591A /* SentrySpan.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EC3AE7925CA23B600E7591A /* SentrySpan.m */; };
720720
8EC4CF4A25C38DAA0093DEE9 /* SentrySpanStatus.h in Headers */ = {isa = PBXBuildFile; fileRef = 8EC4CF4725C38CAF0093DEE9 /* SentrySpanStatus.h */; settings = {ATTRIBUTES = (Public, ); }; };
721721
8EC4CF5025C3A0070093DEE9 /* SentrySpanContextTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EC4CF4F25C3A0070093DEE9 /* SentrySpanContextTests.swift */; };
@@ -1082,6 +1082,7 @@
10821082
FA7206DF2E0B37850072FDD4 /* SentryProfileCollector.h in Headers */ = {isa = PBXBuildFile; fileRef = FA7206DE2E0B37780072FDD4 /* SentryProfileCollector.h */; };
10831083
FA7206E12E0B37C80072FDD4 /* SentryProfileCollector.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA7206E02E0B37C60072FDD4 /* SentryProfileCollector.mm */; };
10841084
FA8A36182DEAA1EB0058D883 /* SentryThread+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = FA8A36172DEAA1EB0058D883 /* SentryThread+Private.h */; };
1085+
FA8AFCDD2E842932007A0E18 /* SentryPerformanceTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA8AFCDC2E84292E007A0E18 /* SentryPerformanceTracker.swift */; };
10851086
FA8AFCED2E8434A8007A0E18 /* SentryThreadInspector.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA8AFCE72E8434A0007A0E18 /* SentryThreadInspector.swift */; };
10861087
FA8AFCEF2E843903007A0E18 /* SentryFileIOTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA8AFCEE2E8438FF007A0E18 /* SentryFileIOTracker.swift */; };
10871088
FA8AFCFA2E844AB6007A0E18 /* SentryThreadsafeApplicationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA8AFCF42E844AB1007A0E18 /* SentryThreadsafeApplicationTests.swift */; };
@@ -2036,9 +2037,9 @@
20362037
8EAE8E5C2681768000D6958B /* URLSessionTaskMock.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = URLSessionTaskMock.h; sourceTree = "<group>"; };
20372038
8EAE8E5D2681768000D6958B /* URLSessionTaskMock.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = URLSessionTaskMock.m; sourceTree = "<group>"; };
20382039
8EAE9804261E87120073B6B3 /* SentryUIViewControllerPerformanceTracker.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryUIViewControllerPerformanceTracker.m; sourceTree = "<group>"; };
2039-
8EAE9809261E9F530073B6B3 /* SentryPerformanceTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryPerformanceTracker.h; path = include/SentryPerformanceTracker.h; sourceTree = "<group>"; };
2040+
8EAE9809261E9F530073B6B3 /* SentryPerformanceTrackerHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryPerformanceTrackerHelper.h; path = include/SentryPerformanceTrackerHelper.h; sourceTree = "<group>"; };
20402041
8EAE980A261E9F530073B6B3 /* SentryUIViewControllerPerformanceTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryUIViewControllerPerformanceTracker.h; path = include/SentryUIViewControllerPerformanceTracker.h; sourceTree = "<group>"; };
2041-
8EBF870726140D37001A6853 /* SentryPerformanceTracker.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryPerformanceTracker.m; sourceTree = "<group>"; };
2042+
8EBF870726140D37001A6853 /* SentryPerformanceTrackerHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryPerformanceTrackerHelper.m; sourceTree = "<group>"; };
20422043
8EC3AE7925CA23B600E7591A /* SentrySpan.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentrySpan.m; sourceTree = "<group>"; };
20432044
8EC4CF4725C38CAF0093DEE9 /* SentrySpanStatus.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentrySpanStatus.h; path = Public/SentrySpanStatus.h; sourceTree = "<group>"; };
20442045
8EC4CF4F25C3A0070093DEE9 /* SentrySpanContextTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySpanContextTests.swift; sourceTree = "<group>"; };
@@ -2170,7 +2171,6 @@
21702171
D808FB89281BCE46009A2A33 /* TestSentrySwizzleWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestSentrySwizzleWrapper.swift; sourceTree = "<group>"; };
21712172
D808FB90281BF6E9009A2A33 /* SentryUIEventTrackingIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUIEventTrackingIntegrationTests.swift; sourceTree = "<group>"; };
21722173
D80C990A2B0DFE410052F311 /* ExternalUIViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalUIViewController.swift; sourceTree = "<group>"; };
2173-
D8105B8D297FD16800299F03 /* SentryPerformanceTracker+Testing.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SentryPerformanceTracker+Testing.h"; sourceTree = "<group>"; };
21742174
D8137D52272B53070082656C /* TestSentrySpan.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TestSentrySpan.h; sourceTree = "<group>"; };
21752175
D8137D53272B53070082656C /* TestSentrySpan.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TestSentrySpan.m; sourceTree = "<group>"; };
21762176
D81988BF2BEBFFF70020E36C /* SentryReplayRecording.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryReplayRecording.swift; sourceTree = "<group>"; };
@@ -2427,6 +2427,7 @@
24272427
FA7206DE2E0B37780072FDD4 /* SentryProfileCollector.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SentryProfileCollector.h; sourceTree = "<group>"; };
24282428
FA7206E02E0B37C60072FDD4 /* SentryProfileCollector.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SentryProfileCollector.mm; sourceTree = "<group>"; };
24292429
FA8A36172DEAA1EB0058D883 /* SentryThread+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "SentryThread+Private.h"; path = "include/SentryThread+Private.h"; sourceTree = "<group>"; };
2430+
FA8AFCDC2E84292E007A0E18 /* SentryPerformanceTracker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryPerformanceTracker.swift; sourceTree = "<group>"; };
24302431
FA8AFCE72E8434A0007A0E18 /* SentryThreadInspector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryThreadInspector.swift; sourceTree = "<group>"; };
24312432
FA8AFCEE2E8438FF007A0E18 /* SentryFileIOTracker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryFileIOTracker.swift; sourceTree = "<group>"; };
24322433
FA8AFCF42E844AB1007A0E18 /* SentryThreadsafeApplicationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryThreadsafeApplicationTests.swift; sourceTree = "<group>"; };
@@ -3703,8 +3704,8 @@
37033704
8EA1ED092668F8C400E62B98 /* SentryUIViewControllerSwizzling.m */,
37043705
8EAE980A261E9F530073B6B3 /* SentryUIViewControllerPerformanceTracker.h */,
37053706
8EAE9804261E87120073B6B3 /* SentryUIViewControllerPerformanceTracker.m */,
3706-
8EAE9809261E9F530073B6B3 /* SentryPerformanceTracker.h */,
3707-
8EBF870726140D37001A6853 /* SentryPerformanceTracker.m */,
3707+
8EAE9809261E9F530073B6B3 /* SentryPerformanceTrackerHelper.h */,
3708+
8EBF870726140D37001A6853 /* SentryPerformanceTrackerHelper.m */,
37083709
D8BFE37029A3782F002E73F3 /* SentryTimeToDisplayTracker.h */,
37093710
D8BFE37129A3782F002E73F3 /* SentryTimeToDisplayTracker.m */,
37103711
);
@@ -3795,7 +3796,6 @@
37953796
7BF9EF8A2722D58700B5BBEF /* SentryInitializeForGettingSubclassesNotCalled.m */,
37963797
D8FFE50B2703DAAE00607131 /* SwizzlingCallTests.swift */,
37973798
7BE912B02721C76000E49E62 /* SentryPerformanceTrackingIntegrationTests.swift */,
3798-
D8105B8D297FD16800299F03 /* SentryPerformanceTracker+Testing.h */,
37993799
);
38003800
path = Performance;
38013801
sourceTree = "<group>";
@@ -4510,6 +4510,7 @@
45104510
isa = PBXGroup;
45114511
children = (
45124512
FAE57BF12E83049900B710F9 /* SentryDisplayLinkWrapper.swift */,
4513+
FA8AFCD62E84291F007A0E18 /* UIViewController */,
45134514
D468C0602D36699700964230 /* IO */,
45144515
);
45154516
path = Performance;
@@ -4903,6 +4904,14 @@
49034904
path = Core;
49044905
sourceTree = "<group>";
49054906
};
4907+
FA8AFCD62E84291F007A0E18 /* UIViewController */ = {
4908+
isa = PBXGroup;
4909+
children = (
4910+
FA8AFCDC2E84292E007A0E18 /* SentryPerformanceTracker.swift */,
4911+
);
4912+
path = UIViewController;
4913+
sourceTree = "<group>";
4914+
};
49064915
FABB48B22E59310D0071397E /* Transaction */ = {
49074916
isa = PBXGroup;
49084917
children = (
@@ -5007,7 +5016,7 @@
50075016
63AA76991EB9C1C200D153DE /* SentryDefines.h in Headers */,
50085017
D86B6835294348A400B8B1FC /* SentryAttachment+Private.h in Headers */,
50095018
84AF45A629A7FFA500FBB177 /* SentryProfiledTracerConcurrency.h in Headers */,
5010-
8EAE980B261E9F530073B6B3 /* SentryPerformanceTracker.h in Headers */,
5019+
8EAE980B261E9F530073B6B3 /* SentryPerformanceTrackerHelper.h in Headers */,
50115020
F48F75732E5FA649009D4E7D /* SentryBinaryImageCacheCallbacks.h in Headers */,
50125021
63FE718520DA4C1100CDBAE8 /* SentryCrashC.h in Headers */,
50135022
8EA1ED0D2669028C00E62B98 /* SentryUIViewControllerSwizzling.h in Headers */,
@@ -5895,6 +5904,7 @@
58955904
63FE713120DA4C1100CDBAE8 /* SentryCrashDynamicLinker.c in Sources */,
58965905
03F84D3527DD4191008FE43F /* SentryThreadHandle.cpp in Sources */,
58975906
0A2D8DA9289BC905008720F6 /* SentryViewHierarchyProviderHelper.m in Sources */,
5907+
FA8AFCDD2E842932007A0E18 /* SentryPerformanceTracker.swift in Sources */,
58985908
D84D2CDD2C2BF7370011AF8A /* SentryReplayEvent.swift in Sources */,
58995909
D8BC28CC2BFF78220054DA4D /* SentryRRWebTouchEvent.swift in Sources */,
59005910
D452FC592DDB4B1700AFF56F /* SentryWatchdogTerminationBreadcrumbProcessor.m in Sources */,
@@ -5930,7 +5940,7 @@
59305940
621F61F12BEA073A005E654F /* SentryEnabledFeaturesBuilder.swift in Sources */,
59315941
D88817D826D7149100BF2251 /* SentryTraceContext.m in Sources */,
59325942
D8F67B1B2BE9728600C9197B /* SentrySRDefaultBreadcrumbConverter.swift in Sources */,
5933-
8EBF870926140D37001A6853 /* SentryPerformanceTracker.m in Sources */,
5943+
8EBF870926140D37001A6853 /* SentryPerformanceTrackerHelper.m in Sources */,
59345944
D865893029D6ECA7000BE151 /* SentryCrashBinaryImageCache.c in Sources */,
59355945
D859696B27BECD8F0036A46E /* SentryCoreDataTrackingIntegration.m in Sources */,
59365946
7BD86EC7264A641D005439DB /* SentrySysctlObjC.m in Sources */,

SentryTestUtils/SentryTestUtils-ObjC-BridgingHeader.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#import "SentryHub+Test.h"
4040
#import "SentryLogC.h"
4141
#import "SentryNetworkTracker.h"
42-
#import "SentryPerformanceTracker+Testing.h"
4342
#import "SentrySDK+Private.h"
4443
#import "SentrySDKInternal+Tests.h"
4544
#import "SentryScopeSyncC.h"

Sources/Sentry/SentryDependencyContainer.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#import <SentryDebugImageProvider+HybridSDKs.h>
1515
#import <SentryDefaultAppStateManager.h>
1616
#import <SentryDependencyContainer.h>
17-
#import <SentryPerformanceTracker.h>
1817
#import <SentrySDK+Private.h>
1918
#import <SentrySwift.h>
2019
#import <SentrySwizzleWrapper.h>

Sources/Sentry/SentryHub.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#import "SentryLevelMapper.h"
1010
#import "SentryLogC.h"
1111
#import "SentryOptions+Private.h"
12-
#import "SentryPerformanceTracker.h"
1312
#import "SentryProfilingConditionals.h"
1413
#import "SentrySDK+Private.h"
1514
#import "SentrySamplerDecision.h"

Sources/Sentry/SentryPerformanceTracker.m renamed to Sources/Sentry/SentryPerformanceTrackerHelper.m

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#import "SentryPerformanceTracker.h"
1+
#import "SentryPerformanceTrackerHelper.h"
22
#import "SentryDependencyContainer.h"
33
#import "SentryHub+Private.h"
44
#import "SentryLogC.h"
@@ -22,18 +22,17 @@
2222

2323
NS_ASSUME_NONNULL_BEGIN
2424

25-
@interface SentryPerformanceTracker () <SentryTracerDelegate>
25+
@interface SentryPerformanceTrackerHelper () <SentryTracerDelegate>
2626

2727
@property (nonatomic, strong) NSMutableDictionary<SentrySpanId *, id<SentrySpan>> *spans;
28-
@property (nonatomic, strong) NSMutableArray<id<SentrySpan>> *activeSpanStack;
2928

3029
@end
3130

32-
@implementation SentryPerformanceTracker
31+
@implementation SentryPerformanceTrackerHelper
3332

34-
+ (SentryPerformanceTracker *)shared
33+
+ (SentryPerformanceTrackerHelper *)shared
3534
{
36-
static SentryPerformanceTracker *instance = nil;
35+
static SentryPerformanceTrackerHelper *instance = nil;
3736
static dispatch_once_t onceToken;
3837
dispatch_once(&onceToken, ^{ instance = [[self alloc] init]; });
3938
return instance;
@@ -49,7 +48,7 @@ - (instancetype)init
4948
}
5049

5150
- (SentrySpanId *)startSpanWithName:(NSString *)name
52-
nameSource:(SentryTransactionNameSource)source
51+
nameSource:(NSInteger)source
5352
operation:(NSString *)operation
5453
origin:(NSString *)origin
5554
{
@@ -122,7 +121,7 @@ - (SentrySpanId *)startSpanWithName:(NSString *)name
122121
}
123122

124123
- (void)measureSpanWithDescription:(NSString *)description
125-
nameSource:(SentryTransactionNameSource)source
124+
nameSource:(NSInteger)source
126125
operation:(NSString *)operation
127126
origin:(NSString *)origin
128127
inBlock:(void (^)(void))block
@@ -140,7 +139,7 @@ - (void)measureSpanWithDescription:(NSString *)description
140139
}
141140

142141
- (void)measureSpanWithDescription:(NSString *)description
143-
nameSource:(SentryTransactionNameSource)source
142+
nameSource:(NSInteger)source
144143
operation:(NSString *)operation
145144
origin:(NSString *)origin
146145
parentSpanId:(SentrySpanId *)parentSpanId

Sources/Sentry/SentryUIViewControllerPerformanceTracker.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
# import "SentryHub.h"
88
# import "SentryLogC.h"
99
# import "SentryOptions.h"
10-
# import "SentryPerformanceTracker.h"
1110
# import "SentrySDK+Private.h"
1211
# import "SentrySpanId.h"
1312
# import "SentrySpanOperation.h"
@@ -198,7 +197,7 @@ - (void)startRootSpanFor:(UIViewController *)controller
198197

199198
spanId = [self getSpanIdForViewController:controller];
200199
SentrySpan *_Nullable vcSpan
201-
= (SentrySpan *)[self.tracker getSpan:SENTRY_UNWRAP_NULLABLE(SentrySpanId, spanId)];
200+
= (SentrySpan *)[self.tracker getSpanForObjc:SENTRY_UNWRAP_NULLABLE(SentrySpanId, spanId)];
202201

203202
if (![vcSpan isKindOfClass:[SentryTracer self]]) {
204203
// Since TTID and TTFD are meant to the whole screen
@@ -274,7 +273,7 @@ - (SentrySwiftUISpanHelper *)startTimeToDisplayTrackerForScreen:(NSString *)scre
274273
waitForFullDisplay:(BOOL)waitforFullDisplay
275274
transactionId:(SentrySpanId *)transactionId;
276275
{
277-
id<SentrySpan> span = [SentryPerformanceTracker.shared getSpan:transactionId];
276+
id<SentrySpan> span = [SentryPerformanceTracker.shared getSpanForObjc:transactionId];
278277
if (span != nil && [span isKindOfClass:[SentryTracer class]]) {
279278
id<SentryInitialDisplayReporting> displayReporting =
280279
[self startTimeToDisplayTrackerForScreen:screenName
@@ -389,7 +388,7 @@ - (void)finishTransaction:(UIViewController *)controller
389388
};
390389

391390
[self.tracker activateSpan:spanId duringBlock:duringBlock];
392-
id<SentrySpan> vcSpan = [self.tracker getSpan:spanId];
391+
id<SentrySpan> vcSpan = [self.tracker getSpanForObjc:spanId];
393392
// If the current controller span has no parent,
394393
// it means it is the root transaction and need to be pop from the queue.
395394
if (vcSpan.parentSpanId == nil) {

0 commit comments

Comments
 (0)