@@ -20,18 +20,7 @@ import Baggage
20
20
/// If you need to use more that one cross-cutting tool you can do so by using `MultiplexInstrument`.
21
21
///
22
22
/// # Access the Instrument
23
- /// There are two ways of getting the bootstrapped instrument.
24
- /// 1. `InstrumentationSystem.instrument`: Returns whatever you passed to `.bootstrap` as an `Instrument`.
25
- /// 2. `InstrumentationSystem.instrument(of: MyInstrument.self)`: Returns the bootstrapped `Instrument` if it's
26
- /// an instance of the given type or the first instance of `MyInstrument` if it's part of a `MultiplexInstrument`.
27
- ///
28
- /// ## What getter to use
29
- /// - Default to using `InstrumentationSystem.instrument`
30
- /// - Use `InstrumentationSystem.instrument(of: MyInstrument.self)` only if you need to use specific `MyInstrument` APIs
31
- ///
32
- /// Specific instrumentation libraries may also provide their own accessors as extensions, e.g. GreatInstrumentation could provide an
33
- /// `InstrumentationSystem.great` convenience accessor, so prefer using them if available. These accessors should call
34
- /// `.instrument(of: GreatInstrument.self)` under the hood to ensure they work when being used through a `MultiplexInstrument`.
23
+ /// `InstrumentationSystem.instrument`: Returns whatever you passed to `.bootstrap` as an `Instrument`.
35
24
public enum InstrumentationSystem {
36
25
private static let lock = ReadWriteLock ( )
37
26
private static var _instrument : Instrument = NoOpInstrument ( )
@@ -54,7 +43,9 @@ public enum InstrumentationSystem {
54
43
}
55
44
}
56
45
57
- // for our testing we want to allow multiple bootstrapping
46
+ /// For testing scenarios one may want to set instruments multiple times, rather than the set-once semantics enforced by `bootstrap()`.
47
+ ///
48
+ /// - Parameter instrument: the instrument to boostrap the system with, if `nil` the `NoOpInstrument` is bootstrapped.
58
49
internal static func bootstrapInternal( _ instrument: Instrument ? ) {
59
50
self . lock. withWriterLock {
60
51
self . _instrument = instrument ?? NoOpInstrument ( )
@@ -67,16 +58,6 @@ public enum InstrumentationSystem {
67
58
public static var instrument : Instrument {
68
59
return self . lock. withReaderLock { self . _instrument }
69
60
}
70
-
71
- /// Get an `Instrument` instance of the given type.
72
- ///
73
- /// When using `MultiplexInstrument`, this returns the first instance of the given type stored in the `MultiplexInstrument`.
74
- ///
75
- /// - Parameter instrumentType: The type of `Instrument` you want to retrieve an instance for.
76
- /// - Returns: An `Instrument` instance of the given type or `nil` if no `Instrument` of that type has been bootstrapped.
77
- public static func instrument< I> ( of instrumentType: I . Type ) -> I ? where I: Instrument {
78
- return self . _findInstrument ( where: { $0 is I } ) as? I
79
- }
80
61
}
81
62
82
63
extension InstrumentationSystem {
0 commit comments