Skip to content

Commit

Permalink
ref: Remove unused start transaction methods in hub (#2887)
Browse files Browse the repository at this point in the history
Remove not required unused start transaction methods in the SentryHub.
  • Loading branch information
philipphofmann authored Apr 11, 2023
1 parent d09c797 commit 11ccc16
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 44 deletions.
22 changes: 0 additions & 22 deletions Sources/Sentry/SentryHub.m
Original file line number Diff line number Diff line change
Expand Up @@ -309,16 +309,6 @@ - (SentryId *)captureEvent:(SentryEvent *)event
operation:operation]];
}

- (id<SentrySpan>)startTransactionWithName:(NSString *)name
nameSource:(SentryTransactionNameSource)source
operation:(NSString *)operation
{
return [self
startTransactionWithContext:[[SentryTransactionContext alloc] initWithName:name
nameSource:source
operation:operation]];
}

- (id<SentrySpan>)startTransactionWithName:(NSString *)name
operation:(NSString *)operation
bindToScope:(BOOL)bindToScope
Expand All @@ -330,18 +320,6 @@ - (SentryId *)captureEvent:(SentryEvent *)event
bindToScope:bindToScope];
}

- (id<SentrySpan>)startTransactionWithName:(NSString *)name
nameSource:(SentryTransactionNameSource)source
operation:(NSString *)operation
bindToScope:(BOOL)bindToScope
{
return
[self startTransactionWithContext:[[SentryTransactionContext alloc] initWithName:name
nameSource:source
operation:operation]
bindToScope:bindToScope];
}

- (id<SentrySpan>)startTransactionWithContext:(SentryTransactionContext *)transactionContext
{
return [self startTransactionWithContext:transactionContext customSamplingContext:@{}];
Expand Down
5 changes: 1 addition & 4 deletions Sources/Sentry/SentrySDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,14 @@ + (SentryId *)captureEvent:(SentryEvent *)event withScope:(SentryScope *)scope

+ (id<SentrySpan>)startTransactionWithName:(NSString *)name operation:(NSString *)operation
{
return [SentrySDK.currentHub startTransactionWithName:name
nameSource:kSentryTransactionNameSourceCustom
operation:operation];
return [SentrySDK.currentHub startTransactionWithName:name operation:operation];
}

+ (id<SentrySpan>)startTransactionWithName:(NSString *)name
operation:(NSString *)operation
bindToScope:(BOOL)bindToScope
{
return [SentrySDK.currentHub startTransactionWithName:name
nameSource:kSentryTransactionNameSourceCustom
operation:operation
bindToScope:bindToScope];
}
Expand Down
9 changes: 0 additions & 9 deletions Sources/Sentry/include/SentryHub+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@ SentryHub (Private)

- (void)closeCachedSessionWithTimestamp:(NSDate *_Nullable)timestamp;

- (id<SentrySpan>)startTransactionWithName:(NSString *)name
nameSource:(SentryTransactionNameSource)source
operation:(NSString *)operation;

- (id<SentrySpan>)startTransactionWithName:(NSString *)name
nameSource:(SentryTransactionNameSource)source
operation:(NSString *)operation
bindToScope:(BOOL)bindToScope;

- (SentryTracer *)startTransactionWithContext:(SentryTransactionContext *)transactionContext
bindToScope:(BOOL)bindToScope
customSamplingContext:(NSDictionary<NSString *, id> *)customSamplingContext
Expand Down
26 changes: 17 additions & 9 deletions Tests/SentryTests/SentrySDKTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class SentrySDKTests: XCTestCase {
}

let message = "message"
let operation = "ui.load"
let transactionName = "Load Main Screen"

init() {
CurrentDate.setCurrentDateProvider(currentDate)
Expand Down Expand Up @@ -344,24 +346,23 @@ class SentrySDKTests: XCTestCase {
func testStartTransaction() {
givenSdkWithHub()

let operation = "ui.load"
let name = "Load Main Screen"
let transaction = SentrySDK.startTransaction(name: name, operation: operation)

XCTAssertEqual(operation, transaction.operation)
let tracer = transaction as! SentryTracer
XCTAssertEqual(name, tracer.traceContext.transaction)
let transaction = SentrySDK.startTransaction(name: fixture.transactionName, operation: fixture.operation)

assertTransaction(transaction: transaction)

XCTAssertNil(SentrySDK.span)
}

func testStartTransaction_WithBindToScope() {
givenSdkWithHub()

let span = SentrySDK.startTransaction(name: "Some Transaction", operation: "Operations", bindToScope: true)
let transaction = SentrySDK.startTransaction(name: fixture.transactionName, operation: fixture.operation, bindToScope: true)

assertTransaction(transaction: transaction)

let newSpan = SentrySDK.span

XCTAssert(span === newSpan)
XCTAssert(transaction === newSpan)
}

func testInstallIntegrations() {
Expand Down Expand Up @@ -709,6 +710,13 @@ class SentrySDKTests: XCTestCase {
XCTAssertEqual(fixture.scope, hubScope)
}

private func assertTransaction(transaction: Span) {
XCTAssertEqual(fixture.operation, transaction.operation)
let tracer = transaction as! SentryTracer
XCTAssertEqual(fixture.transactionName, tracer.traceContext.transaction)
XCTAssertEqual(.custom, tracer.transactionContext.nameSource)
}

private func advanceTime(bySeconds: TimeInterval) {
fixture.currentDate.setDate(date: fixture.currentDate.date().addingTimeInterval(bySeconds))
}
Expand Down

0 comments on commit 11ccc16

Please sign in to comment.