Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Sources/Sentry/Public/SentryScope.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
@class SentryBreadcrumb;
@class SentryOptions;
@class SentryUser;
@class SentrySpanInternal;

NS_ASSUME_NONNULL_BEGIN

Expand Down
21 changes: 11 additions & 10 deletions Sources/Sentry/SentryBuildAppStartSpans.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#if SENTRY_HAS_UIKIT

SentrySpan *
SentrySpanInternal *
sentryBuildAppStartSpan(
SentryTracer *tracer, SentrySpanId *parentId, NSString *operation, NSString *description)
{
Expand All @@ -22,10 +22,10 @@
origin:SentryTraceOriginAutoAppStart
sampled:tracer.sampled];

return [[SentrySpan alloc] initWithTracer:tracer context:context framesTracker:nil];
return [[SentrySpanInternal alloc] initWithTracer:tracer context:context framesTracker:nil];
}

NSArray<SentrySpan *> *
NSArray<SentrySpanInternal *> *
sentryBuildAppStartSpans(
SentryTracer *tracer, SentryAppStartMeasurement *_Nullable appStartMeasurement)
{
Expand All @@ -50,44 +50,45 @@
return @[];
}

NSMutableArray<SentrySpan *> *appStartSpans = [NSMutableArray array];
NSMutableArray<SentrySpanInternal *> *appStartSpans = [NSMutableArray array];

NSDate *appStartEndTimestamp = [appStartMeasurement.appStartTimestamp
dateByAddingTimeInterval:appStartMeasurement.duration];

SentrySpan *appStartSpan = sentryBuildAppStartSpan(tracer, tracer.spanId, operation, type);
SentrySpanInternal *appStartSpan
= sentryBuildAppStartSpan(tracer, tracer.spanId, operation, type);
[appStartSpan setStartTimestamp:appStartMeasurement.appStartTimestamp];
[appStartSpan setTimestamp:appStartEndTimestamp];

[appStartSpans addObject:appStartSpan];

if (!appStartMeasurement.isPreWarmed) {
SentrySpan *premainSpan
SentrySpanInternal *premainSpan
= sentryBuildAppStartSpan(tracer, appStartSpan.spanId, operation, @"Pre Runtime Init");
[premainSpan setStartTimestamp:appStartMeasurement.appStartTimestamp];
[premainSpan setTimestamp:appStartMeasurement.runtimeInitTimestamp];
[appStartSpans addObject:premainSpan];

SentrySpan *runtimeInitSpan = sentryBuildAppStartSpan(
SentrySpanInternal *runtimeInitSpan = sentryBuildAppStartSpan(
tracer, appStartSpan.spanId, operation, @"Runtime Init to Pre Main Initializers");
[runtimeInitSpan setStartTimestamp:appStartMeasurement.runtimeInitTimestamp];
[runtimeInitSpan setTimestamp:appStartMeasurement.moduleInitializationTimestamp];
[appStartSpans addObject:runtimeInitSpan];
}

SentrySpan *appInitSpan
SentrySpanInternal *appInitSpan
= sentryBuildAppStartSpan(tracer, appStartSpan.spanId, operation, @"UIKit Init");
[appInitSpan setStartTimestamp:appStartMeasurement.moduleInitializationTimestamp];
[appInitSpan setTimestamp:appStartMeasurement.sdkStartTimestamp];
[appStartSpans addObject:appInitSpan];

SentrySpan *didFinishLaunching
SentrySpanInternal *didFinishLaunching
= sentryBuildAppStartSpan(tracer, appStartSpan.spanId, operation, @"Application Init");
[didFinishLaunching setStartTimestamp:appStartMeasurement.sdkStartTimestamp];
[didFinishLaunching setTimestamp:appStartMeasurement.didFinishLaunchingTimestamp];
[appStartSpans addObject:didFinishLaunching];

SentrySpan *frameRenderSpan
SentrySpanInternal *frameRenderSpan
= sentryBuildAppStartSpan(tracer, appStartSpan.spanId, operation, @"Initial Frame Render");
[frameRenderSpan setStartTimestamp:appStartMeasurement.didFinishLaunchingTimestamp];
[frameRenderSpan setTimestamp:appStartEndTimestamp];
Expand Down
10 changes: 5 additions & 5 deletions Sources/Sentry/SentryCoreDataTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ - (NSArray *)managedObjectContext:(NSManagedObjectContext *)context
error:(NSError **)error
originalImp:(NSArray *(NS_NOESCAPE ^)(NSFetchRequest *, NSError **))original
{
id<SentrySpan> _Nullable currentSpan = [SentrySDKInternal.currentHub.scope span];
id<SentrySpan> _Nullable fetchSpan;
SentrySpanInternal *_Nullable currentSpan = [SentrySDKInternal.currentHub.scope span];
SentrySpanInternal *_Nullable fetchSpan;
if (currentSpan) {
NSString *spanDescription = [self descriptionFromRequest:request];
fetchSpan = [currentSpan startChildWithOperation:SentrySpanOperationCoredataFetchOperation
Expand All @@ -56,7 +56,7 @@ - (NSArray *)managedObjectContext:(NSManagedObjectContext *)context
NSArray *result = original(request, error);

if (fetchSpan) {
[self addExtraInfoToSpan:(SentrySpan *)fetchSpan withContext:context];
[self addExtraInfoToSpan:fetchSpan withContext:context];

[fetchSpan setDataValue:[NSNumber numberWithInteger:result.count] forKey:@"read_count"];
[fetchSpan
Expand Down Expand Up @@ -103,7 +103,7 @@ - (BOOL)managedObjectContext:(NSManagedObjectContext *)context
BOOL result = original(error);

if (saveSpan) {
[self addExtraInfoToSpan:(SentrySpan *)saveSpan withContext:context];
[self addExtraInfoToSpan:saveSpan withContext:context];
[saveSpan finishWithStatus:result ? kSentrySpanStatusOk : kSentrySpanStatusInternalError];

SENTRY_LOG_DEBUG(@"SentryCoreDataTracker automatically finished span with status: %@",
Expand All @@ -113,7 +113,7 @@ - (BOOL)managedObjectContext:(NSManagedObjectContext *)context
return result;
}

- (void)addExtraInfoToSpan:(SentrySpan *)span withContext:(NSManagedObjectContext *)context
- (void)addExtraInfoToSpan:(SentrySpanInternal *)span withContext:(NSManagedObjectContext *)context
{
BOOL isMainThread = [NSThread isMainThread];

Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryCrashIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
void
sentry_finishAndSaveTransaction(void)
{
SentrySpan *span = [SentrySDKInternal.currentHub.scope getCastedInternalSpan];
SentrySpanInternal *_Nullable span = [SentrySDKInternal.currentHub.scope getCastedInternalSpan];

if (span != nil) {
SentryTracer *tracer = [span tracer];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ - (void)startRootSpanFor:(UIViewController *)controller
}

spanId = [self getSpanIdForViewController:controller];
SentrySpan *_Nullable vcSpan
= (SentrySpan *)[self.tracker getSpan:SENTRY_UNWRAP_NULLABLE(SentrySpanId, spanId)];
SentrySpanInternal *_Nullable vcSpan
= (SentrySpanInternal *)[self.tracker getSpan:SENTRY_UNWRAP_NULLABLE(SentrySpanId, spanId)];

if (![vcSpan isKindOfClass:[SentryTracer self]]) {
// Since TTID and TTFD are meant to the whole screen
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryFileIOTrackerHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ - (void)mainThreadExtraInfo:(id<SentrySpan>)span
// and we should not report it as an issue.
[span setDataValue:@(NO) forKey:SPAN_DATA_BLOCKED_MAIN_THREAD];
} else {
[((SentrySpan *)span) setFrames:frames];
[((SentrySpanInternal *)span) setFrames:frames];
}
}

Expand Down
1 change: 1 addition & 0 deletions Sources/Sentry/SentrySDKInternal.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#import "SentryScope.h"
#import "SentrySerialization.h"
#import "SentrySessionReplayIntegration.h"
#import "SentrySpan.h"
#import "SentrySwift.h"
#import "SentryTransactionContext.h"
#import "SentryUseNSExceptionCallstackWrapper.h"
Expand Down
8 changes: 4 additions & 4 deletions Sources/Sentry/SentryScope.m
Original file line number Diff line number Diff line change
Expand Up @@ -147,23 +147,23 @@ - (void)setPropagationContext:(SentryPropagationContext *)propagationContext
}
}

- (nullable id<SentrySpan>)span
- (nullable SentrySpanInternal *)span
{
@synchronized(_spanLock) {
return _span;
}
}

- (nullable SentrySpan *)getCastedInternalSpan
- (nullable SentrySpanInternal *)getCastedInternalSpan
{
id<SentrySpan> span = self.span;

if (span == nil) {
return nil;
}

if (span && [span isKindOfClass:[SentrySpan class]]) {
return (SentrySpan *)span;
if (span && [span isKindOfClass:[SentrySpanInternal class]]) {
return (SentrySpanInternal *)span;
}

SENTRY_LOG_DEBUG(@"The span on the scope is not of type SentrySpan, returning nil.");
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/SentrySpan.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@

NS_ASSUME_NONNULL_BEGIN

@interface SentrySpan ()
@interface SentrySpanInternal ()
@end

@implementation SentrySpan {
@implementation SentrySpanInternal {
NSMutableDictionary<NSString *, id> *_data;
NSMutableDictionary<NSString *, id> *_tags;
NSObject *_stateLock;
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/SentryTimeToDisplayTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ - (BOOL)startForTracer:(SentryTracer *)tracer
}

SENTRY_LOG_DEBUG(@"Starting initial display span");
self.initialDisplaySpan = (SentrySpan *)[tracer
self.initialDisplaySpan = (SentrySpanInternal *)[tracer
startChildWithOperation:SentrySpanOperationUiLoadInitialDisplay
description:[NSString stringWithFormat:@"%@ initial display", _name]];
self.initialDisplaySpan.origin = SentryTraceOriginAutoUITimeToDisplay;

if (self.waitForFullDisplay) {
SENTRY_LOG_DEBUG(@"Starting full display span");
self.fullDisplaySpan = (SentrySpan *)[tracer
self.fullDisplaySpan = (SentrySpanInternal *)[tracer
startChildWithOperation:SentrySpanOperationUiLoadFullDisplay
description:[NSString stringWithFormat:@"%@ full display", _name]];
self.fullDisplaySpan.origin = SentryTraceOriginManualUITimeToDisplay;
Expand Down
21 changes: 11 additions & 10 deletions Sources/Sentry/SentryTracer.m
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,11 @@ - (BOOL)isAutoGeneratedTransaction
spanDescription:description
sampled:self.sampled];

SentrySpan *child =
[[SentrySpan alloc] initWithTracer:self
context:context
SentrySpanInternal *child = [[SentrySpanInternal alloc]
initWithTracer:self
context:context
#if SENTRY_HAS_UIKIT
framesTracker:SentryDependencyContainer.sharedInstance.framesTracker
framesTracker:SentryDependencyContainer.sharedInstance.framesTracker
#endif // SENTRY_HAS_UIKIT
];
child.startTimestamp = [SentryDependencyContainer.sharedInstance.dateProvider date];
Expand Down Expand Up @@ -724,7 +724,8 @@ - (SentryTransaction *)toTransaction
#if SENTRY_HAS_UIKIT
[self addFrameStatistics];

NSArray<id<SentrySpan>> *appStartSpans = sentryBuildAppStartSpans(self, appStartMeasurement);
NSArray<SentrySpanInternal *> *appStartSpans
= sentryBuildAppStartSpans(self, appStartMeasurement);
capacity = _children.count + appStartSpans.count;
#else
capacity = _children.count;
Expand All @@ -744,12 +745,12 @@ - (SentryTransaction *)toTransaction
transaction.transaction = self.transactionContext.name;

NSMutableArray *framesOfAllSpans = [NSMutableArray array];
if ([(SentrySpan *)self frames]) {
if ([(SentrySpanInternal *)self frames]) {
[framesOfAllSpans addObjectsFromArray:SENTRY_UNWRAP_NULLABLE(NSArray<SentryFrame *>,
[(SentrySpan *)self frames])];
[(SentrySpanInternal *)self frames])];
}

for (SentrySpan *span in spans) {
for (SentrySpanInternal *span in spans) {
if (span.frames) {
[framesOfAllSpans
addObjectsFromArray:SENTRY_UNWRAP_NULLABLE(NSArray<SentryFrame *>, span.frames)];
Expand Down Expand Up @@ -924,8 +925,8 @@ + (nullable SentryTracer *)getTracer:(id<SentrySpan> _Nullable)span

if ([span isKindOfClass:[SentryTracer class]]) {
return (SentryTracer *)span;
} else if ([span isKindOfClass:[SentrySpan class]]) {
return [(SentrySpan *)span tracer];
} else if ([span isKindOfClass:[SentrySpanInternal class]]) {
return [(SentrySpanInternal *)span tracer];
}
return nil;
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/include/SentryBuildAppStartSpans.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#import "SentryDefines.h"

@class SentryTracer;
@class SentrySpan;
@class SentrySpanInternal;
@class SentryAppStartMeasurement;

NS_ASSUME_NONNULL_BEGIN

#if SENTRY_HAS_UIKIT

NSArray<SentrySpan *> *sentryBuildAppStartSpans(
NSArray<SentrySpanInternal *> *sentryBuildAppStartSpans(
SentryTracer *tracer, SentryAppStartMeasurement *_Nullable appStartMeasurement);

#endif // SENTRY_HAS_UIKIT
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/include/SentryNoOpSpan.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

NS_ASSUME_NONNULL_BEGIN

@interface SentryNoOpSpan : SentrySpan
@interface SentryNoOpSpan : SentrySpanInternal
SENTRY_NO_INIT

+ (instancetype)shared;
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/include/SentryScope+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@class SentryAttachment;
@class SentryPropagationContext;
@class SentrySession;
@class SentrySpan;
@class SentrySpanInternal;

@protocol SentryScopeObserver;

Expand Down Expand Up @@ -47,7 +47,7 @@ NS_ASSUME_NONNULL_BEGIN

- (NSArray<SentryBreadcrumb *> *)breadcrumbs;

- (nullable SentrySpan *)getCastedInternalSpan;
- (nullable SentrySpanInternal *)getCastedInternalSpan;

/**
* used to add values in event context.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/include/SentrySpan+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

static NSString *_Nonnull const kSentrySpanStatusSerializationKey = @"status";

@interface SentrySpan ()
@interface SentrySpanInternal ()

#if SENTRY_TARGET_PROFILING_SUPPORTED
@property (copy, nonatomic) NSString *_Nullable profileSessionID;
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/include/SentrySpan.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
@class SentryFramesTracker;
#endif // SENTRY_HAS_UIKIT

@interface SentrySpan : NSObject <SentrySpan, SentrySerializable>
@interface SentrySpanInternal : NSObject <SentrySpan, SentrySerializable>
SENTRY_NO_INIT

/**
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/include/SentryTracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static const NSTimeInterval SENTRY_AUTO_TRANSACTION_MAX_DURATION = 500.0;

@end

@interface SentryTracer : SentrySpan
@interface SentryTracer : SentrySpanInternal

@property (nonatomic, strong) SentryTransactionContext *transactionContext;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,14 @@ private extension SentryCoreDataTrackerTests {
XCTAssert(try XCTUnwrap(dbSpan.data["db.name"] as? NSString).contains(databaseFilename), file: file, line: line)

if mainThread {
guard let frames = (dbSpan as? SentrySpan)?.frames else {
guard let frames = (dbSpan as? SentrySpanInternal)?.frames else {
XCTFail("File IO Span in the main thread has no frames", file: file, line: line)
return
}
XCTAssertEqual(frames.first, TestData.mainFrame, file: file, line: line)
XCTAssertEqual(frames.last, TestData.testFrame, file: file, line: line)
} else {
XCTAssertNil((dbSpan as? SentrySpan)?.frames, file: file, line: line)
XCTAssertNil((dbSpan as? SentrySpanInternal)?.frames, file: file, line: line)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ class SentryFileIOTrackerTests: XCTestCase {
thread.stacktrace = stackTrace
fixture.threadInspector.allThreads = [thread]

var span: SentrySpan?
var span: SentrySpanInternal?

sut.measure(fixture.data, writeToFile: fixture.filePath, atomically: false, origin: "custom.origin") { _, _ -> Bool in
span = self.firstSpan(transaction) as? SentrySpan
span = self.firstSpan(transaction) as? SentrySpanInternal
XCTAssertFalse(span?.isFinished ?? true)
return true
}
Expand Down Expand Up @@ -384,7 +384,7 @@ class SentryFileIOTrackerTests: XCTestCase {
XCTAssertEqual(span?.data["blocked_main_thread"] as? Bool ?? false, mainThread)

if mainThread {
guard let frames = (span as? SentrySpan)?.frames else {
guard let frames = (span as? SentrySpanInternal)?.frames else {
XCTFail("File IO Span in the main thread has no frames", file: file, line: line)
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ - (void)assertTransactionForOperation:(NSString *)operation block:(void (^)(void

block();

SentrySpan *ioSpan = (SentrySpan *)parentTransaction.children.firstObject;
SentrySpanInternal *ioSpan = (SentrySpanInternal *)parentTransaction.children.firstObject;

XCTAssertEqual(parentTransaction.children.count, 1);
XCTAssertEqual([ioSpan.data[@"file.size"] unsignedIntValue], someData.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ - (void)assertTransactionForOperation:(NSString *)operation

XCTAssertEqual(parentTransaction.children.count, spanCount);

SentrySpan *ioSpan = (SentrySpan *)parentTransaction.children.firstObject;
SentrySpanInternal *ioSpan = (SentrySpanInternal *)parentTransaction.children.firstObject;
if (spanCount > 0) {
XCTAssertEqual([ioSpan.data[@"file.size"] unsignedIntValue], someData.length);
XCTAssertEqualObjects(ioSpan.data[@"file.path"], filePath);
Expand Down
Loading
Loading