Skip to content

Commit

Permalink
test: HttpTransport finish spans for transaction (#4812)
Browse files Browse the repository at this point in the history
Finish the tracer and the child spans for the transaction envelope,
because they are usually finished when passed to the transaction so
we avoid potential side effects.
  • Loading branch information
philipphofmann authored Feb 10, 2025
1 parent 67bb6fa commit 18bf9a5
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Tests/SentryTests/Networking/SentryHttpTransportTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,20 @@ class SentryHttpTransportTests: XCTestCase {

func getTransactionEnvelope() -> SentryEnvelope {
let tracer = SentryTracer(transactionContext: TransactionContext(name: "SomeTransaction", operation: "SomeOperation"), hub: nil)

let child1 = tracer.startChild(operation: "child1")
let child2 = tracer.startChild(operation: "child2")
let child3 = tracer.startChild(operation: "child3")

child1.finish()
child2.finish()
child3.finish()

tracer.finish()

let transaction = Transaction(
trace: tracer,
children: [
tracer.startChild(operation: "child1"),
tracer.startChild(operation: "child2"),
tracer.startChild(operation: "child3")
]
children: [child1, child2, child3]
)

let transactionEnvelope = SentryEnvelope(id: transaction.eventId, items: [SentryEnvelopeItem(event: transaction), attachmentEnvelopeItem])
Expand Down

0 comments on commit 18bf9a5

Please sign in to comment.