Skip to content

Commit b80efc1

Browse files
committed
Expose SpanKind in TestSpan and FinishedTestSpan
1 parent f6b7db6 commit b80efc1

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

Sources/TracingTestKit/TestSpan.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,21 @@ import Tracing
1818
public struct TestSpan: Span {
1919
public let context: ServiceContext
2020
public let spanContext: TestSpanContext
21+
public let kind: SpanKind
2122
public let startInstant: any TracerInstant
2223

2324
init(
2425
operationName: String,
2526
context: ServiceContext,
2627
spanContext: TestSpanContext,
28+
kind: SpanKind,
2729
startInstant: any TracerInstant,
2830
onEnd: @escaping @Sendable (FinishedTestSpan) -> Void
2931
) {
3032
self._operationName = LockedValueBox(operationName)
3133
self.context = context
3234
self.spanContext = spanContext
35+
self.kind = kind
3336
self.startInstant = startInstant
3437
self.onEnd = onEnd
3538
}
@@ -105,6 +108,7 @@ public struct TestSpan: Span {
105108
let finishedSpan = FinishedTestSpan(
106109
operationName: operationName,
107110
context: context,
111+
kind: kind,
108112
spanContext: spanContext,
109113
startInstant: startInstant,
110114
endInstant: instant(),
@@ -149,6 +153,7 @@ public struct TestSpan: Span {
149153
public struct FinishedTestSpan: Sendable {
150154
public let operationName: String
151155
public let context: ServiceContext
156+
public let kind: SpanKind
152157
public let spanContext: TestSpanContext
153158
public let startInstant: any TracerInstant
154159
public let endInstant: any TracerInstant

Sources/TracingTestKit/TestTracer.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public struct TestTracer: Tracer {
5959
operationName: operationName,
6060
context: context,
6161
spanContext: spanContext,
62+
kind: kind,
6263
startInstant: instant()
6364
) { finishedSpan in
6465
_activeSpans.withValue { $0[spanContext] = nil }

Tests/TracingTestKitTests/TestTracerTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ struct TestTracerTests {
272272
operationName: "stub",
273273
context: .topLevel,
274274
spanContext: spanContext,
275+
kind: .internal,
275276
startInstant: startInstant,
276277
onEnd: { span in
277278
_finishedSpan.withValue { $0 = span }
@@ -449,6 +450,7 @@ extension TestSpan {
449450
operationName: "stub",
450451
context: .topLevel,
451452
spanContext: TestSpanContext(traceID: "stub", spanID: "stub", parentSpanID: nil),
453+
kind: .internal,
452454
startInstant: DefaultTracerClock().now,
453455
onEnd: { _ in }
454456
)

0 commit comments

Comments
 (0)