@@ -17,14 +17,14 @@ import Tracing
17
17
18
18
/// An in-memory implementation of the ``Tracer`` protocol which can be used either in testing,
19
19
/// or in manual collecting and interrogating traces within a process, and acting on them programatically.
20
- ///
20
+ ///
21
21
/// ### Span lifecycle
22
22
/// This tracer does _not_ automatically remove spans once they end.
23
23
/// Finished spans are retained and available for inspection using the `finishedSpans` property.
24
- /// Spans which have been started but have not yet been called `Span/end()` on are also available
24
+ /// Spans which have been started but have not yet been called `Span/end()` on are also available
25
25
/// for inspection using the ``activeSpans`` property.
26
- ///
27
- /// Spans are retained by the `InMemoryTracer` until they are explicitly removed, e.g. by using
26
+ ///
27
+ /// Spans are retained by the `InMemoryTracer` until they are explicitly removed, e.g. by using
28
28
/// ``popFinishedSpans()`` or any of the `clear...` methods (e.g. ``clearFinishedSpans()``)
29
29
public struct InMemoryTracer : Tracer {
30
30
@@ -41,15 +41,15 @@ public struct InMemoryTracer: Tracer {
41
41
private let _extractions = LockedValueBox < [ Extraction ] > ( [ ] )
42
42
43
43
/// Create a new ``InMemoryTracer``.
44
- ///
45
- /// - Parameters:
44
+ ///
45
+ /// - Parameters:
46
46
/// - Parameter idGenerator: strategy for generating trace and span identifiers
47
47
/// - Parameter idGenerator: strategy for generating trace and span identifiers
48
48
public init (
49
49
idGenerator: IDGenerator = . incrementing,
50
50
recordInjections: Bool = true ,
51
51
recordExtractions: Bool = true
52
- ) {
52
+ ) {
53
53
self . idGenerator = idGenerator
54
54
self . recordInjections = recordInjections
55
55
self . recordExtractions = recordExtractions
@@ -132,15 +132,15 @@ extension InMemoryTracer {
132
132
}
133
133
134
134
/// Gets, without removing, all the finished spans recorded by this tracer.
135
- ///
135
+ ///
136
136
/// - SeeAlso: `popFinishedSpans()`
137
137
public var finishedSpans : [ FinishedInMemorySpan ] {
138
138
_finishedSpans. withValue { $0 }
139
139
}
140
-
140
+
141
141
/// Returns, and removes, all finished spans recorded by this tracer.
142
142
public func popFinishedSpans( ) -> [ FinishedInMemorySpan ] {
143
- _finishedSpans. withValue { spans in
143
+ _finishedSpans. withValue { spans in
144
144
defer { spans = [ ] }
145
145
return spans
146
146
}
@@ -235,7 +235,6 @@ extension InMemoryTracer {
235
235
_extractions. withValue { $0 }
236
236
}
237
237
238
-
239
238
/// Represents a recorded call to the InMemoryTracer's ``Instrument/extract(_:into:using:)`` method.
240
239
public struct Extraction : Sendable {
241
240
/// The carrier object from which the context values were extracted from,
@@ -251,7 +250,7 @@ extension InMemoryTracer {
251
250
extension InMemoryTracer {
252
251
253
252
/// Can be used to customize how trace and span IDs are generated by the ``InMemoryTracer``.
254
- ///
253
+ ///
255
254
/// Defaults to a simple sequential numeric scheme (`span-1`, `span-2`, `trace-1`, `trace-2` etc).
256
255
public struct IDGenerator : Sendable {
257
256
public let nextTraceID : @Sendable ( ) -> String
0 commit comments