Skip to content

Commit

Permalink
refactor: Convert constants SentryTraceOrigins to Swift (#4717)
Browse files Browse the repository at this point in the history
  • Loading branch information
philprime authored Jan 21, 2025
1 parent 9f57953 commit a0bb101
Show file tree
Hide file tree
Showing 21 changed files with 129 additions and 61 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

- Change macros TEST and TESTCI to SENTRY_TEST and SENTRY_TEST_CI (#4712)
- Convert constants SentrySpanOperation to Swift (#4718)
- Convert constants SentryTraceOrigins to Swift (#4717)

## 8.43.1-beta.0

Expand Down
16 changes: 13 additions & 3 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
621D9F2F2B9B0320003D94DE /* SentryCurrentDateProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 621D9F2E2B9B0320003D94DE /* SentryCurrentDateProvider.swift */; };
621F61F12BEA073A005E654F /* SentryEnabledFeaturesBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 621F61F02BEA073A005E654F /* SentryEnabledFeaturesBuilder.swift */; };
6221BBCA2CAA932100C627CA /* SentryANRType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6221BBC92CAA932100C627CA /* SentryANRType.swift */; };
622C08D829E546F4002571D4 /* SentryTraceOrigins.h in Headers */ = {isa = PBXBuildFile; fileRef = 622C08D729E546F4002571D4 /* SentryTraceOrigins.h */; };
622C08DB29E554B9002571D4 /* SentrySpanContext+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 622C08D929E554B9002571D4 /* SentrySpanContext+Private.h */; };
62375FB92B47F9F000CC55F1 /* SentryDependencyContainerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62375FB82B47F9F000CC55F1 /* SentryDependencyContainerTests.swift */; };
623C45B02A651D8200D9E88B /* SentryCoreDataTracker+Test.m in Sources */ = {isa = PBXBuildFile; fileRef = 623C45AF2A651D8200D9E88B /* SentryCoreDataTracker+Test.m */; };
Expand Down Expand Up @@ -788,6 +787,9 @@
A8AFFCD42907E0CA00967CD7 /* SentryRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8AFFCD32907E0CA00967CD7 /* SentryRequestTests.swift */; };
A8F17B2E2901765900990B25 /* SentryRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = A8F17B2D2901765900990B25 /* SentryRequest.m */; };
A8F17B342902870300990B25 /* SentryHttpStatusCodeRange.m in Sources */ = {isa = PBXBuildFile; fileRef = A8F17B332902870300990B25 /* SentryHttpStatusCodeRange.m */; };
D48724DB2D352597005DE483 /* SentryTraceOrigin.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48724DA2D352591005DE483 /* SentryTraceOrigin.swift */; };
D48724E22D354D16005DE483 /* SentryTraceOriginTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48724E12D354D16005DE483 /* SentryTraceOriginTests.swift */; };
D48E8B8B2D3E79610032E35E /* SentryTraceOrigin.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48E8B8A2D3E79610032E35E /* SentryTraceOrigin.swift */; };
D48724DD2D354939005DE483 /* SentrySpanOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48724DC2D354934005DE483 /* SentrySpanOperation.swift */; };
D48724E02D3549CA005DE483 /* SentrySpanOperationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48724DF2D3549C6005DE483 /* SentrySpanOperationTests.swift */; };
D48E8B9D2D3E82AC0032E35E /* SentrySpanOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48E8B9C2D3E82AC0032E35E /* SentrySpanOperation.swift */; };
Expand Down Expand Up @@ -1115,7 +1117,6 @@
621D9F2E2B9B0320003D94DE /* SentryCurrentDateProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryCurrentDateProvider.swift; sourceTree = "<group>"; };
621F61F02BEA073A005E654F /* SentryEnabledFeaturesBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryEnabledFeaturesBuilder.swift; sourceTree = "<group>"; };
6221BBC92CAA932100C627CA /* SentryANRType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryANRType.swift; sourceTree = "<group>"; };
622C08D729E546F4002571D4 /* SentryTraceOrigins.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryTraceOrigins.h; path = include/SentryTraceOrigins.h; sourceTree = "<group>"; };
622C08D929E554B9002571D4 /* SentrySpanContext+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "SentrySpanContext+Private.h"; path = "include/SentrySpanContext+Private.h"; sourceTree = "<group>"; };
62375FB82B47F9F000CC55F1 /* SentryDependencyContainerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryDependencyContainerTests.swift; sourceTree = "<group>"; };
623C45AE2A651C4500D9E88B /* SentryCoreDataTracker+Test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SentryCoreDataTracker+Test.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1890,6 +1891,9 @@
A8AFFCD32907E0CA00967CD7 /* SentryRequestTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryRequestTests.swift; sourceTree = "<group>"; };
A8F17B2D2901765900990B25 /* SentryRequest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryRequest.m; sourceTree = "<group>"; };
A8F17B332902870300990B25 /* SentryHttpStatusCodeRange.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryHttpStatusCodeRange.m; sourceTree = "<group>"; };
D48724DA2D352591005DE483 /* SentryTraceOrigin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryTraceOrigin.swift; sourceTree = "<group>"; };
D48724E12D354D16005DE483 /* SentryTraceOriginTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryTraceOriginTests.swift; sourceTree = "<group>"; };
D48E8B8A2D3E79610032E35E /* SentryTraceOrigin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryTraceOrigin.swift; sourceTree = "<group>"; };
D48724DC2D354934005DE483 /* SentrySpanOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySpanOperation.swift; sourceTree = "<group>"; };
D48724DF2D3549C6005DE483 /* SentrySpanOperationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySpanOperationTests.swift; sourceTree = "<group>"; };
D48E8B9C2D3E82AC0032E35E /* SentrySpanOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySpanOperation.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3630,6 +3634,7 @@
8ECC674325C23A1F000E2BF6 /* SentrySpanContext.m */,
622C08D929E554B9002571D4 /* SentrySpanContext+Private.h */,
8E4E7C7325DAAB49006AB9E2 /* SentrySpanProtocol.h */,
7B3B83712833832B0001FDEB /* SentrySpanOperations.h */,
622C08D729E546F4002571D4 /* SentryTraceOrigins.h */,
8E4E7C6C25DAAAFE006AB9E2 /* SentrySpan.h */,
84A789092C0E9F5800FF0803 /* SentrySpan+Private.h */,
Expand Down Expand Up @@ -3676,6 +3681,7 @@
D48724D92D35258A005DE483 /* Transactions */ = {
isa = PBXGroup;
children = (
D48724DA2D352591005DE483 /* SentryTraceOrigin.swift */,
D48724DC2D354934005DE483 /* SentrySpanOperation.swift */,
);
path = Transactions;
Expand All @@ -3684,6 +3690,7 @@
D48724DE2D3549C1005DE483 /* Transactions */ = {
isa = PBXGroup;
children = (
D48724E12D354D16005DE483 /* SentryTraceOriginTests.swift */,
D48724DF2D3549C6005DE483 /* SentrySpanOperationTests.swift */,
);
path = Transactions;
Expand Down Expand Up @@ -3777,6 +3784,7 @@
D8199DB629376ECC0074249E /* SentryTracedView.swift */,
D48E8B9C2D3E82AC0032E35E /* SentrySpanOperation.swift */,
D8A65B5C2C98656000974B74 /* SentryReplayView.swift */,
D48E8B8A2D3E79610032E35E /* SentryTraceOrigin.swift */,
);
path = SentrySwiftUI;
sourceTree = "<group>";
Expand Down Expand Up @@ -4136,7 +4144,6 @@
8E4E7C6D25DAAAFE006AB9E2 /* SentryTransaction.h in Headers */,
63FE715D20DA4C1100CDBAE8 /* SentryCrashSymbolicator.h in Headers */,
D8ACE3CF2762187D00F5A213 /* SentryFileIOTrackingIntegration.h in Headers */,
622C08D829E546F4002571D4 /* SentryTraceOrigins.h in Headers */,
7BECF42226145C5D00D9826E /* SentryMechanismMeta.h in Headers */,
63FE718920DA4C1100CDBAE8 /* SentryCrash.h in Headers */,
63AA769A1EB9C1C200D153DE /* SentryLog.h in Headers */,
Expand Down Expand Up @@ -4961,6 +4968,7 @@
7BC9A20628F41781001E7C4C /* SentryMeasurementUnit.m in Sources */,
63FE71A020DA4C1100CDBAE8 /* SentryCrashInstallation.m in Sources */,
63FE713520DA4C1100CDBAE8 /* SentryCrashMemory.c in Sources */,
D48724DB2D352597005DE483 /* SentryTraceOrigin.swift in Sources */,
63FE714520DA4C1100CDBAE8 /* SentryCrashObjC.c in Sources */,
63FE710520DA4C1000CDBAE8 /* SentryAsyncSafeLog.c in Sources */,
0A2D8D5B289815C0008720F6 /* SentryBaseIntegration.m in Sources */,
Expand Down Expand Up @@ -5223,6 +5231,7 @@
0A1B497328E597DD00D7BFA3 /* TestLogOutput.swift in Sources */,
D8CB742E294B294B00A5F964 /* MockUIScene.m in Sources */,
7BA61CBD247BC6B900C130A8 /* TestSentryCrashBinaryImageProvider.swift in Sources */,
D48724E22D354D16005DE483 /* SentryTraceOriginTests.swift in Sources */,
7BFA69F627E0840400233199 /* SentryANRTrackingIntegrationTests.swift in Sources */,
7BBD18B62451807600427C76 /* SentryDefaultRateLimitsTests.swift in Sources */,
63FE720620DA66EC00CDBAE8 /* SentryCrashMonitor_AppState_Tests.m in Sources */,
Expand Down Expand Up @@ -5307,6 +5316,7 @@
D8199DC129376EEC0074249E /* SentryTracedView.swift in Sources */,
D48E8B9D2D3E82AC0032E35E /* SentrySpanOperation.swift in Sources */,
D8199DBF29376EE20074249E /* SentryInternal.m in Sources */,
D48E8B8B2D3E79610032E35E /* SentryTraceOrigin.swift in Sources */,
D8A65B5D2C98656800974B74 /* SentryReplayView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
3 changes: 1 addition & 2 deletions Sources/Sentry/Profiling/SentryLaunchProfiling.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
# import "SentrySamplingContext.h"
# import "SentrySwift.h"
# import "SentryTime.h"
# import "SentryTraceOrigins.h"
# import "SentryTracer+Private.h"
# import "SentryTracerConfiguration.h"
# import "SentryTransactionContext+Private.h"
Expand Down Expand Up @@ -99,7 +98,7 @@
[[SentryTransactionContext alloc] initWithName:@"launch"
nameSource:kSentryTransactionNameSourceCustom
operation:SentrySpanOperation.appLifecycle
origin:SentryTraceOriginAutoAppStartProfile
origin:SentryTraceOrigin.autoAppStartProfile
sampled:kSentrySampleDecisionYes];
context.sampleRate = tracesRate;
return context;
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/SentryBuildAppStartSpans.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#import "SentrySpan.h"
#import "SentrySpanContext+Private.h"
#import "SentrySpanId.h"
#import "SentryTraceOrigins.h"
#import "SentrySwift.h"
#import "SentryTracer.h"
#import <Foundation/Foundation.h>
#import <SentryBuildAppStartSpans.h>
Expand All @@ -19,7 +19,7 @@
parentId:parentId
operation:operation
spanDescription:description
origin:SentryTraceOriginAutoAppStart
origin:SentryTraceOrigin.autoAppStart
sampled:tracer.sampled];

return [[SentrySpan alloc] initWithTracer:tracer context:context framesTracker:nil];
Expand Down
5 changes: 2 additions & 3 deletions Sources/Sentry/SentryCoreDataTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#import "SentryStacktrace.h"
#import "SentrySwift.h"
#import "SentryThreadInspector.h"
#import "SentryTraceOrigins.h"

@implementation SentryCoreDataTracker {
SentryPredicateDescriptor *predicateDescriptor;
Expand Down Expand Up @@ -41,7 +40,7 @@ - (NSArray *)managedObjectContext:(NSManagedObjectContext *)context
[SentrySDK.currentHub.scope useSpan:^(id<SentrySpan> _Nullable span) {
fetchSpan = [span startChildWithOperation:SentrySpanOperation.coredataFetchOperation
description:[self descriptionFromRequest:request]];
fetchSpan.origin = SentryTraceOriginAutoDBCoreData;
fetchSpan.origin = SentryTraceOrigin.autoDBCoreData;
}];

if (fetchSpan) {
Expand Down Expand Up @@ -80,7 +79,7 @@ - (BOOL)managedObjectContext:(NSManagedObjectContext *)context
saveSpan = [span startChildWithOperation:SentrySpanOperation.coredataSaveOperation
description:[self descriptionForOperations:operations
inContext:context]];
saveSpan.origin = SentryTraceOriginAutoDBCoreData;
saveSpan.origin = SentryTraceOrigin.autoDBCoreData;
}];

if (saveSpan) {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/SentryFileIOTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
#import "SentrySpan.h"
#import "SentrySpanProtocol.h"
#import "SentryStacktrace.h"
#import "SentrySwift.h"
#import "SentryThread.h"
#import "SentryThreadInspector.h"
#import "SentryTraceOrigins.h"
#import "SentryTracer.h"

const NSString *SENTRY_TRACKING_COUNTER_KEY = @"SENTRY_TRACKING_COUNTER_KEY";
Expand Down Expand Up @@ -179,7 +179,7 @@ - (BOOL)measureNSFileManagerCreateFileAtPath:(NSString *)path
ioSpan = [span startChildWithOperation:operation
description:[self transactionDescriptionForFile:path
fileSize:size]];
ioSpan.origin = SentryTraceOriginAutoNSData;
ioSpan.origin = SentryTraceOrigin.autoNSData;
}];

if (ioSpan == nil) {
Expand Down
5 changes: 2 additions & 3 deletions Sources/Sentry/SentryHub.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#import "SentrySerialization.h"
#import "SentrySession+Private.h"
#import "SentrySwift.h"
#import "SentryTraceOrigins.h"
#import "SentryTracer.h"
#import "SentryTransaction.h"
#import "SentryTransactionContext+Private.h"
Expand Down Expand Up @@ -345,7 +344,7 @@ - (void)captureReplayEvent:(SentryReplayEvent *)replayEvent
initWithName:name
nameSource:kSentryTransactionNameSourceCustom
operation:operation
origin:SentryTraceOriginManual]];
origin:SentryTraceOrigin.manual]];
}

- (id<SentrySpan>)startTransactionWithName:(NSString *)name
Expand All @@ -356,7 +355,7 @@ - (void)captureReplayEvent:(SentryReplayEvent *)replayEvent
initWithName:name
nameSource:kSentryTransactionNameSourceCustom
operation:operation
origin:SentryTraceOriginManual]
origin:SentryTraceOrigin.manual]
bindToScope:bindToScope];
}

Expand Down
3 changes: 1 addition & 2 deletions Sources/Sentry/SentryNetworkTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#import "SentryThreadInspector.h"
#import "SentryTraceContext.h"
#import "SentryTraceHeader.h"
#import "SentryTraceOrigins.h"
#import "SentryTracer.h"
#import "SentryUser.h"
#import <objc/runtime.h>
Expand Down Expand Up @@ -191,7 +190,7 @@ - (void)urlSessionTaskResume:(NSURLSessionTask *)sessionTask
description:[NSString stringWithFormat:@"%@ %@",
sessionTask.currentRequest.HTTPMethod,
safeUrl.sanitizedUrl]];
netSpan.origin = SentryTraceOriginAutoHttpNSURLSession;
netSpan.origin = SentryTraceOrigin.autoHttpNSURLSession;

[netSpan setDataValue:sessionTask.currentRequest.HTTPMethod
forKey:@"http.request.method"];
Expand Down
3 changes: 1 addition & 2 deletions Sources/Sentry/SentrySpanContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#import "SentrySampleDecision+Private.h"
#import "SentrySpanId.h"
#import "SentrySwift.h"
#import "SentryTraceOrigins.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -51,7 +50,7 @@ - (instancetype)initWithTraceId:(SentryId *)traceId
parentId:parentId
operation:operation
spanDescription:description
origin:SentryTraceOriginManual
origin:SentryTraceOrigin.manual
sampled:sampled];
}

Expand Down
7 changes: 3 additions & 4 deletions Sources/Sentry/SentryTimeToDisplayTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# import "SentrySpanContext.h"
# import "SentrySpanId.h"
# import "SentrySwift.h"
# import "SentryTraceOrigins.h"
# import "SentryTracer.h"

# import <UIKit/UIKit.h>
Expand Down Expand Up @@ -64,14 +63,14 @@ - (BOOL)startForTracer:(SentryTracer *)tracer
self.initialDisplaySpan =
[tracer startChildWithOperation:SentrySpanOperation.uiLoadInitialDisplay
description:[NSString stringWithFormat:@"%@ initial display", _name]];
self.initialDisplaySpan.origin = SentryTraceOriginAutoUITimeToDisplay;
self.initialDisplaySpan.origin = SentryTraceOrigin.autoUITimeToDisplay;

if (self.waitForFullDisplay) {
SENTRY_LOG_DEBUG(@"Starting full display span");
self.fullDisplaySpan =
[tracer startChildWithOperation:SentrySpanOperation.uiLoadFullDisplay
description:[NSString stringWithFormat:@"%@ full display", _name]];
self.fullDisplaySpan.origin = SentryTraceOriginManualUITimeToDisplay;
self.fullDisplaySpan.origin = SentryTraceOrigin.manualUITimeToDisplay;

// By concept TTID and TTFD spans should have the same beginning,
// which also should be the same of the transaction starting.
Expand All @@ -83,7 +82,7 @@ - (BOOL)startForTracer:(SentryTracer *)tracer
[SentryDependencyContainer.sharedInstance.framesTracker addListener:self];

[tracer setShouldIgnoreWaitForChildrenCallback:^(id<SentrySpan> span) {
if (span.origin == SentryTraceOriginAutoUITimeToDisplay) {
if ([span.origin isEqualToString:SentryTraceOrigin.autoUITimeToDisplay]) {
return YES;
} else {
return NO;
Expand Down
1 change: 0 additions & 1 deletion Sources/Sentry/SentryTracer.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#import "SentryThreadWrapper.h"
#import "SentryTime.h"
#import "SentryTraceContext.h"
#import "SentryTraceOrigins.h"
#import "SentryTracer+Private.h"
#import "SentryTransaction.h"
#import "SentryTransactionContext.h"
Expand Down
6 changes: 3 additions & 3 deletions Sources/Sentry/SentryTransactionContext.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#import "SentryLog.h"
#include "SentryProfilingConditionals.h"
#import "SentrySpanContext+Private.h"
#import "SentrySwift.h"
#import "SentryThread.h"
#include "SentryThreadHandle.hpp"
#import "SentryTraceOrigins.h"
#import "SentryTransactionContext+Private.h"

NS_ASSUME_NONNULL_BEGIN
Expand All @@ -27,7 +27,7 @@ - (instancetype)initWithName:(NSString *)name
return [self initWithName:name
nameSource:kSentryTransactionNameSourceCustom
operation:operation
origin:SentryTraceOriginManual
origin:SentryTraceOrigin.manual
sampled:sampled];
}

Expand All @@ -41,7 +41,7 @@ - (instancetype)initWithName:(NSString *)name
return [self initWithName:name
nameSource:kSentryTransactionNameSourceCustom
operation:operation
origin:SentryTraceOriginManual
origin:SentryTraceOrigin.manual
traceId:traceId
spanId:spanId
parentSpanId:parentSpanId
Expand Down
3 changes: 1 addition & 2 deletions Sources/Sentry/SentryUIEventTrackerTransactionMode.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# import <SentrySDK.h>
# import <SentryScope.h>
# import <SentrySpanId.h>
# import <SentryTraceOrigins.h>
# import <SentryTracer.h>
# import <SentryTransactionContext+Private.h>

Expand Down Expand Up @@ -66,7 +65,7 @@ - (void)handleUIEvent:(NSString *)action
[[SentryTransactionContext alloc] initWithName:action
nameSource:kSentryTransactionNameSourceComponent
operation:operation
origin:SentryTraceOriginUIEventTracker];
origin:SentryTraceOrigin.autoUiEventTracker];

__block SentryTracer *transaction;
[SentrySDK.currentHub.scope useSpan:^(id<SentrySpan> _Nullable span) {
Expand Down
Loading

0 comments on commit a0bb101

Please sign in to comment.