File tree Expand file tree Collapse file tree 4 files changed +14
-2
lines changed
Sources/TracingInstrumentation
Tests/TracingInstrumentationTests Expand file tree Collapse file tree 4 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ public struct NoOpTracingInstrument: TracingInstrument {
54
54
55
55
public mutating func addEvent( _ event: SpanEvent ) { }
56
56
57
+ public func recordError( _ error: Error ) { }
58
+
57
59
public var attributes : SpanAttributes {
58
60
get {
59
61
[ : ]
Original file line number Diff line number Diff line change @@ -41,6 +41,12 @@ public protocol Span {
41
41
/// - Parameter event: The `SpanEvent` to add to this `Span`.
42
42
mutating func addEvent( _ event: SpanEvent )
43
43
44
+ /// Record an error of the given type described by the the given message.
45
+ ///
46
+ /// - Parameters:
47
+ /// - error: The error to be recorded.
48
+ mutating func recordError( _ error: Error )
49
+
44
50
/// The attributes describing this `Span`.
45
51
var attributes : SpanAttributes { get set }
46
52
@@ -83,7 +89,7 @@ extension Span {
83
89
// MARK: Span Event
84
90
85
91
/// An event that occurred during a `Span`.
86
- public struct SpanEvent {
92
+ public struct SpanEvent : Equatable {
87
93
/// The human-readable name of this `SpanEvent`.
88
94
public let name : String
89
95
@@ -299,7 +305,7 @@ extension SpanAttribute: ExpressibleByArrayLiteral {
299
305
300
306
/// A collection of `SpanAttribute`s.
301
307
@dynamicMemberLookup
302
- public struct SpanAttributes {
308
+ public struct SpanAttributes : Equatable {
303
309
private var _attributes = [ String: SpanAttribute] ( )
304
310
305
311
/// Create a set of attributes by wrapping the given dictionary.
Original file line number Diff line number Diff line change @@ -131,6 +131,8 @@ private final class TracedLockPrintlnTracer: TracingInstrument {
131
131
self . events. append ( event)
132
132
}
133
133
134
+ func recordError( _ error: Error ) { }
135
+
134
136
mutating func end( at timestamp: Timestamp ) {
135
137
self . endTimestamp = timestamp
136
138
print ( " span [ \( self . operationName) : \( self . context [ TaskIDKey . self] ?? " no-name " ) ] @ \( timestamp) : end " )
Original file line number Diff line number Diff line change @@ -168,6 +168,8 @@ struct TestSpan: Span {
168
168
self . events. append ( event)
169
169
}
170
170
171
+ func recordError( _ error: Error ) { }
172
+
171
173
mutating func end( at timestamp: Timestamp ) {
172
174
self . endTimestamp = timestamp
173
175
self . onEnd ( self )
You can’t perform that action at this time.
0 commit comments