Skip to content

Commit

Permalink
ref: Make SentryTracer sub class of SentrySpan (#2675)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
brustolin committed Feb 3, 2023
1 parent 56deb55 commit ddc9b9a
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 292 deletions.
Expand Up @@ -24,5 +24,4 @@ class LaunchUITests: XCTestCase {
XCTAssertEqual(transactionName.label, "Content View Body")
XCTAssertEqual(childParentId.label, transactionId.label)
}

}
16 changes: 12 additions & 4 deletions Sources/Sentry/SentrySpan.m
Expand Up @@ -7,6 +7,8 @@
#import "SentryLog.h"
#import "SentryMeasurementValue.h"
#import "SentryNoOpSpan.h"
#import "SentrySerializable.h"
#import "SentrySpanContext.h"
#import "SentrySpanId.h"
#import "SentryTime.h"
#import "SentryTraceHeader.h"
Expand All @@ -24,12 +26,10 @@ @implementation SentrySpan {
BOOL _isFinished;
}

- (instancetype)initWithTracer:(SentryTracer *)tracer context:(SentrySpanContext *)context
- (instancetype)initWithContext:(SentrySpanContext *)context
{
if (self = [super init]) {
SENTRY_LOG_DEBUG(
@"Created span %@ for trace ID %@", context.spanId.sentrySpanIdString, tracer.traceId);
_tracer = tracer;
SENTRY_LOG_DEBUG(@"Created span %@", context.spanId.sentrySpanIdString);
self.startTimestamp = [SentryCurrentDate date];
_data = [[NSMutableDictionary alloc] init];
_tags = [[NSMutableDictionary alloc] init];
Expand All @@ -46,6 +46,14 @@ - (instancetype)initWithTracer:(SentryTracer *)tracer context:(SentrySpanContext
return self;
}

- (instancetype)initWithTracer:(SentryTracer *)tracer context:(SentrySpanContext *)context
{
if (self = [self initWithContext:context]) {
_tracer = tracer;
}
return self;
}

- (id<SentrySpan>)startChildWithOperation:(NSString *)operation
{
return [self startChildWithOperation:operation description:nil];
Expand Down

0 comments on commit ddc9b9a

Please sign in to comment.