@@ -19,7 +19,7 @@ import Tracing
19
19
///
20
20
/// See ``InMemoryTracer``
21
21
public struct InMemorySpan : Span {
22
-
22
+
23
23
/// The service context of the span.
24
24
public let context : ServiceContext
25
25
/// The in-memory span context.
@@ -41,7 +41,7 @@ public struct InMemorySpan: Span {
41
41
public var parentSpanID : String ? {
42
42
spanContext. parentSpanID
43
43
}
44
-
44
+
45
45
/// The kind of span
46
46
public let kind : SpanKind
47
47
/// The time instant the span started.
@@ -55,7 +55,7 @@ public struct InMemorySpan: Span {
55
55
private let _status = LockedValueBox < SpanStatus ? > ( nil )
56
56
private let _isRecording = LockedValueBox < Bool > ( true )
57
57
private let onEnd : @Sendable ( FinishedInMemorySpan ) -> Void
58
-
58
+
59
59
/// Creates a new in-memory span
60
60
/// - Parameters:
61
61
/// - operationName: The operation name this span represents.
@@ -88,7 +88,7 @@ public struct InMemorySpan: Span {
88
88
public var isRecording : Bool {
89
89
_isRecording. withValue { $0 }
90
90
}
91
-
91
+
92
92
/// The operation name the span represents.
93
93
public var operationName : String {
94
94
get {
@@ -99,7 +99,7 @@ public struct InMemorySpan: Span {
99
99
_operationName. withValue { $0 = newValue }
100
100
}
101
101
}
102
-
102
+
103
103
/// The span attributes.
104
104
public var attributes : SpanAttributes {
105
105
get {
@@ -110,36 +110,36 @@ public struct InMemorySpan: Span {
110
110
_attributes. withValue { $0 = newValue }
111
111
}
112
112
}
113
-
113
+
114
114
/// The events associated with the span.
115
115
public var events : [ SpanEvent ] {
116
116
_events. withValue { $0 }
117
117
}
118
-
118
+
119
119
/// Adds an event you provide to the span.
120
120
/// - Parameter event: The event to record.
121
121
public func addEvent( _ event: SpanEvent ) {
122
122
guard isRecording else { return }
123
123
_events. withValue { $0. append ( event) }
124
124
}
125
-
125
+
126
126
/// The span links.
127
127
public var links : [ SpanLink ] {
128
128
_links. withValue { $0 }
129
129
}
130
-
130
+
131
131
/// Adds a link to the span.
132
132
/// - Parameter link: The link to add.
133
133
public func addLink( _ link: SpanLink ) {
134
134
guard isRecording else { return }
135
135
_links. withValue { $0. append ( link) }
136
136
}
137
-
137
+
138
138
/// The errors recorded by the span.
139
139
public var errors : [ RecordedError ] {
140
140
_errors. withValue { $0 }
141
141
}
142
-
142
+
143
143
/// Records an error to the span.
144
144
/// - Parameters:
145
145
/// - error: The error to record.
@@ -155,19 +155,19 @@ public struct InMemorySpan: Span {
155
155
$0. append ( RecordedError ( error: error, attributes: attributes, instant: instant ( ) ) )
156
156
}
157
157
}
158
-
158
+
159
159
/// The status of the span.
160
160
public var status : SpanStatus ? {
161
161
_status. withValue { $0 }
162
162
}
163
-
163
+
164
164
/// Updates the status of the span to the value you provide.
165
165
/// - Parameter status: The status to set.
166
166
public func setStatus( _ status: SpanStatus ) {
167
167
guard isRecording else { return }
168
168
_status. withValue { $0 = status }
169
169
}
170
-
170
+
171
171
/// Finishes the span.
172
172
/// - Parameter instant: the time instant the span completed.
173
173
public func end( at instant: @autoclosure ( ) -> some TracerInstant ) {
@@ -192,7 +192,7 @@ public struct InMemorySpan: Span {
192
192
)
193
193
onEnd ( finishedSpan)
194
194
}
195
-
195
+
196
196
/// An error recorded to a span.
197
197
public struct RecordedError : Sendable {
198
198
/// The recorded error.
@@ -208,7 +208,7 @@ public struct InMemorySpan: Span {
208
208
public struct FinishedInMemorySpan : Sendable {
209
209
/// The name of the operation the span represents.
210
210
public var operationName : String
211
-
211
+
212
212
/// The service context of the finished span.
213
213
public var context : ServiceContext
214
214
/// The in-memory span context.
@@ -250,7 +250,7 @@ public struct FinishedInMemorySpan: Sendable {
250
250
spanContext. parentSpanID = newValue
251
251
}
252
252
}
253
-
253
+
254
254
/// The kind of span.
255
255
public var kind : SpanKind
256
256
/// The time instant the span started.
0 commit comments