16
16
import Tracing
17
17
18
18
/// A ``Span`` created by the ``InMemoryTracer`` that will be retained in memory when ended.
19
- ///
20
- /// - SeeAlso: ``InMemoryTracer``
19
+ /// See ``InMemoryTracer/
21
20
public struct InMemorySpan : Span {
21
+
22
22
public let context : ServiceContext
23
23
public let spanContext : InMemorySpanContext
24
+
25
+ /// The ID of the overall trace this span belongs to.
26
+ public var traceID : String {
27
+ spanContext. spanID
28
+ }
29
+ /// The ID of this concrete span.
30
+ public var spanID : String {
31
+ spanContext. spanID
32
+ }
33
+ /// The ID of the parent span of this span, if there was any.
34
+ /// When this is `nil` it means this is the top-level span of this trace.
35
+ public var parentSpanID : String ? {
36
+ spanContext. parentSpanID
37
+ }
38
+
24
39
public let kind : SpanKind
25
40
public let startInstant : any TracerInstant
26
41
@@ -49,6 +64,8 @@ public struct InMemorySpan: Span {
49
64
self . onEnd = onEnd
50
65
}
51
66
67
+ /// The in memory span stops recording (storing mutations performed on the span) when it is ended.
68
+ /// In other words, a finished span no longer is mutable and will ignore all subsequent attempts to mutate.
52
69
public var isRecording : Bool {
53
70
_isRecording. withValue { $0 }
54
71
}
@@ -120,8 +137,8 @@ public struct InMemorySpan: Span {
120
137
let finishedSpan = FinishedInMemorySpan (
121
138
operationName: operationName,
122
139
context: context,
123
- kind: kind,
124
140
spanContext: spanContext,
141
+ kind: kind,
125
142
startInstant: startInstant,
126
143
endInstant: instant ( ) ,
127
144
attributes: attributes,
@@ -145,9 +162,40 @@ public struct InMemorySpan: Span {
145
162
/// that was recorded by the ``InMemoryTracer``.
146
163
public struct FinishedInMemorySpan : Sendable {
147
164
public var operationName : String
165
+
148
166
public var context : ServiceContext
149
- public var kind : SpanKind
150
167
public var spanContext : InMemorySpanContext
168
+
169
+ /// The ID of the overall trace this span belongs to.
170
+ public var traceID : String {
171
+ get {
172
+ spanContext. spanID
173
+ }
174
+ set {
175
+ spanContext. spanID = newValue
176
+ }
177
+ }
178
+ /// The ID of this concrete span.
179
+ public var spanID : String {
180
+ get {
181
+ spanContext. spanID
182
+ }
183
+ set {
184
+ spanContext. spanID = newValue
185
+ }
186
+ }
187
+ /// The ID of the parent span of this span, if there was any.
188
+ /// When this is `nil` it means this is the top-level span of this trace.
189
+ public var parentSpanID : String ? {
190
+ get {
191
+ spanContext. parentSpanID
192
+ }
193
+ set {
194
+ spanContext. parentSpanID = newValue
195
+ }
196
+ }
197
+
198
+ public var kind : SpanKind
151
199
public var startInstant : any TracerInstant
152
200
public var endInstant : any TracerInstant
153
201
public var attributes : SpanAttributes
0 commit comments