Skip to content

Commit ddc9b9a

Browse files
authored
ref: Make SentryTracer sub class of SentrySpan (#2675)
SentryTracer is the core of performance, and it gets bigger and bigger with each new feature, therefore is getting harder to understand it. This is the first step to reduce it. The goal in the future is to extract more behavior from it and use DI as replacement.
1 parent 56deb55 commit ddc9b9a

File tree

8 files changed

+64
-292
lines changed

8 files changed

+64
-292
lines changed

Samples/iOS-SwiftUI/iOS-SwiftUI-UITests/LaunchUITests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,4 @@ class LaunchUITests: XCTestCase {
2424
XCTAssertEqual(transactionName.label, "Content View Body")
2525
XCTAssertEqual(childParentId.label, transactionId.label)
2626
}
27-
2827
}

Sources/Sentry/SentrySpan.m

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#import "SentryLog.h"
88
#import "SentryMeasurementValue.h"
99
#import "SentryNoOpSpan.h"
10+
#import "SentrySerializable.h"
11+
#import "SentrySpanContext.h"
1012
#import "SentrySpanId.h"
1113
#import "SentryTime.h"
1214
#import "SentryTraceHeader.h"
@@ -24,12 +26,10 @@ @implementation SentrySpan {
2426
BOOL _isFinished;
2527
}
2628

27-
- (instancetype)initWithTracer:(SentryTracer *)tracer context:(SentrySpanContext *)context
29+
- (instancetype)initWithContext:(SentrySpanContext *)context
2830
{
2931
if (self = [super init]) {
30-
SENTRY_LOG_DEBUG(
31-
@"Created span %@ for trace ID %@", context.spanId.sentrySpanIdString, tracer.traceId);
32-
_tracer = tracer;
32+
SENTRY_LOG_DEBUG(@"Created span %@", context.spanId.sentrySpanIdString);
3333
self.startTimestamp = [SentryCurrentDate date];
3434
_data = [[NSMutableDictionary alloc] init];
3535
_tags = [[NSMutableDictionary alloc] init];
@@ -46,6 +46,14 @@ - (instancetype)initWithTracer:(SentryTracer *)tracer context:(SentrySpanContext
4646
return self;
4747
}
4848

49+
- (instancetype)initWithTracer:(SentryTracer *)tracer context:(SentrySpanContext *)context
50+
{
51+
if (self = [self initWithContext:context]) {
52+
_tracer = tracer;
53+
}
54+
return self;
55+
}
56+
4957
- (id<SentrySpan>)startChildWithOperation:(NSString *)operation
5058
{
5159
return [self startChildWithOperation:operation description:nil];

0 commit comments

Comments
 (0)