Skip to content

Commit 960a14e

Browse files
committed
add test
1 parent 9ffb95e commit 960a14e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Tests/TracingTests/TracerTests.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,22 @@ final class TracerTests: XCTestCase {
369369
tracer.withAnySpan("", context: .topLevel) { _ in }
370370
}
371371

372+
func testWithSpanShouldNotMissPropagatingInstant() {
373+
let tracer = TestTracer()
374+
InstrumentationSystem.bootstrapInternal(tracer)
375+
defer {
376+
InstrumentationSystem.bootstrapInternal(nil)
377+
}
378+
379+
let clock = DefaultTracerClock()
380+
381+
let instant = clock.now
382+
withSpan("span", at: instant) { _ in }
383+
384+
let span = tracer.spans.first!
385+
XCTAssertEqual(span.startTimestampNanosSinceEpoch, instant.nanosecondsSinceEpoch)
386+
}
387+
372388
#if swift(>=5.7.0)
373389
// @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
374390
/// Helper method to execute async operations until we can use async tests (currently incompatible with the generated LinuxMain file).

0 commit comments

Comments
 (0)