Skip to content

Commit 07a1420

Browse files
committed
updates to Instrumentation module symbols
1 parent 04fc8bf commit 07a1420

File tree

5 files changed

+54
-27
lines changed

5 files changed

+54
-27
lines changed

Sources/Instrumentation/Instrument.swift

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,25 @@
1414

1515
import ServiceContextModule
1616

17-
/// Conforming types are used to extract values from a specific `Carrier`.
17+
/// A type that allows tracing to extract values from an associated carrier.
18+
///
19+
/// The assocaited type, `Carrier`, is a service request such as an HTTP request,
20+
/// that has string values that can be extracted to provide information for a tracing span.
1821
public protocol Extractor: Sendable {
1922
/// The carrier to extract values from.
2023
associatedtype Carrier: Sendable
2124

2225
/// Extract the value for the given key from the `Carrier`.
2326
///
2427
/// - Parameters:
25-
/// - key: The key to be extracted.
28+
/// - key: The key to extract.
2629
/// - carrier: The `Carrier` to extract from.
2730
func extract(key: String, from carrier: Carrier) -> String?
2831
}
2932

30-
/// Conforming types are used to inject values into a specific `Carrier`.
33+
/// A type that allows you to inject values to an associated carrier.
34+
///
35+
/// The associated type, `Carrier`, is often a client or outgoing request into which values are inserted for tracing spans.
3136
public protocol Injector: Sendable {
3237
/// The carrier to inject values into.
3338
associatedtype Carrier: Sendable
@@ -41,10 +46,13 @@ public protocol Injector: Sendable {
4146
func inject(_ value: String, forKey key: String, into carrier: inout Carrier)
4247
}
4348

44-
/// Conforming types are usually cross-cutting tools like tracers. They are agnostic of what specific `Carrier` is used
45-
/// to propagate metadata across boundaries, but instead just specify what values to use for which keys.
49+
/// A type that represents a cross-cutting tool, such as a tracer, that provides the a means to extract and inject service contexts into an associated carrier.
50+
///
51+
/// The types are agnostic of the specific `Carrier` used to propagate metadata across API boundaries.
52+
/// Instead they specify the values to use for which keys.
4653
public protocol Instrument: Sendable {
47-
/// Extract values from a `Carrier` by using the given extractor and inject them into the given `ServiceContext`.
54+
/// Extract values from a carrier, using the given extractor, and inject them into the provided service context.
55+
///
4856
/// It's quite common for `Instrument`s to come up with new values if they weren't passed along in the given `Carrier`.
4957
///
5058
/// - Parameters:
@@ -54,12 +62,12 @@ public protocol Instrument: Sendable {
5462
func extract<Carrier, Extract>(_ carrier: Carrier, into context: inout ServiceContext, using extractor: Extract)
5563
where Extract: Extractor, Extract.Carrier == Carrier
5664

57-
/// Extract values from a `ServiceContext` and inject them into the given `Carrier` using the given ``Injector``.
65+
/// Extract values from a service context and inject them into the given carrier using the provided injector.
5866
///
5967
/// - Parameters:
60-
/// - context: The `ServiceContext` from which relevant information will be extracted.
61-
/// - carrier: The `Carrier` into which this information will be injected.
62-
/// - injector: The ``Injector`` used to inject extracted `ServiceContext` into the given `Carrier`.
68+
/// - context: The `ServiceContext` from which relevant information is extracted.
69+
/// - carrier: The `Carrier` into which this information is injected.
70+
/// - injector: The ``Injector`` to use to inject extracted `ServiceContext` into the given `Carrier`.
6371
func inject<Carrier, Inject>(_ context: ServiceContext, into carrier: inout Carrier, using injector: Inject)
6472
where Inject: Injector, Inject.Carrier == Carrier
6573
}

Sources/Instrumentation/InstrumentationSystem.swift

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,20 @@
1414

1515
import ServiceContextModule
1616

17-
/// `InstrumentationSystem` is a global facility where the default cross-cutting tool can be configured.
17+
/// A global facility where the default cross-cutting tool can be configured.
18+
///
1819
/// It is set up just once in a given program to select the desired ``Instrument`` implementation.
1920
///
20-
/// # Bootstrap multiple Instruments
21+
/// ### Bootstrap multiple Instruments
2122
/// If you need to use more that one cross-cutting tool you can do so by using ``MultiplexInstrument``.
2223
///
23-
/// # Access the Instrument
24-
/// ``instrument``: Returns whatever you passed to ``bootstrap(_:)`` as an ``Instrument``.
24+
/// ## Topics
25+
///
26+
/// ### Configuring the Instrument
27+
/// - ``bootstrap(_:)``
28+
///
29+
/// ### Accessing the Instrument
30+
/// - ``instrument``: Returns whatyou pass to ``bootstrap(_:)`` as an ``Instrument``.
2531
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext
2632
public enum InstrumentationSystem {
2733
/// Marked as @unchecked Sendable due to the synchronization being
@@ -73,7 +79,8 @@ public enum InstrumentationSystem {
7379
/// Globally select the desired ``Instrument`` implementation.
7480
///
7581
/// - Parameter instrument: The ``Instrument`` you want to share globally within your system.
76-
/// - Warning: Do not call this method more than once. This will lead to a crash.
82+
///
83+
/// > Warning: Do not call this method more than once. This will lead to a crash.
7784
public static func bootstrap(_ instrument: Instrument) {
7885
self.shared.bootstrap(instrument)
7986
}
@@ -85,7 +92,7 @@ public enum InstrumentationSystem {
8592
self.shared.bootstrapInternal(instrument)
8693
}
8794

88-
/// Returns the globally configured ``Instrument``.
95+
/// Returns the globally configured instrument.
8996
///
9097
/// Defaults to a no-op ``Instrument`` if ``bootstrap(_:)`` wasn't called before.
9198
public static var instrument: Instrument {

Sources/Instrumentation/Locks.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ public final class ReadWriteLock {
9393
}
9494

9595
extension ReadWriteLock {
96-
/// Acquire the reader lock for the duration of the given block.
96+
/// Acquire a reader lock for the duration of the given block.
9797
///
9898
/// This convenience method should be preferred to `lock` and `unlock` in
99-
/// most situations, as it ensures that the lock will be released regardless
99+
/// most situations, as it ensures that the lock is released regardless
100100
/// of how `body` exits.
101101
///
102102
/// - Parameter body: The block to execute while holding the lock.
@@ -110,10 +110,10 @@ extension ReadWriteLock {
110110
return try body()
111111
}
112112

113-
/// Acquire the writer lock for the duration of the given block.
113+
/// Acquire a writer lock for the duration of the given block.
114114
///
115115
/// This convenience method should be preferred to `lock` and `unlock` in
116-
/// most situations, as it ensures that the lock will be released regardless
116+
/// most situations, as it ensures that the lock is released regardless
117117
/// of how `body` exits.
118118
///
119119
/// - Parameter body: The block to execute while holding the lock.
@@ -128,7 +128,7 @@ extension ReadWriteLock {
128128
}
129129
}
130130

131-
/// A wrapper providing locked access to a value.
131+
/// A wrapper that provides locked access to a value.
132132
///
133133
/// Marked as @unchecked Sendable due to the synchronization being
134134
/// performed manually using locks.

Sources/Instrumentation/MultiplexInstrument.swift

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414

1515
import ServiceContextModule
1616

17-
/// A pseudo-``Instrument`` that may be used to instrument using multiple other ``Instrument``s across a
18-
/// common `ServiceContext`.
17+
/// A pseudo instrument to use to instrument using multiple instrumentss across a
18+
/// common service context.
1919
public struct MultiplexInstrument {
2020
private var instruments: [Instrument]
2121

22-
/// Create a ``MultiplexInstrument``.
23-
///
24-
/// - Parameter instruments: An array of ``Instrument``s, each of which will be used to ``Instrument/inject(_:into:using:)`` or ``Instrument/extract(_:into:using:)``
22+
/// Create a multiplex instrument.
23+
///
24+
/// - Parameter instruments: An array of ``Instrument``, each of which the tracer uses to
25+
/// ``Instrument/inject(_:into:using:)`` or ``Instrument/extract(_:into:using:)``
2526
/// through the same `ServiceContext`.
2627
public init(_ instruments: [Instrument]) {
2728
self.instruments = instruments
@@ -35,11 +36,22 @@ extension MultiplexInstrument {
3536
}
3637

3738
extension MultiplexInstrument: Instrument {
39+
/// Extract values from a service context and inject them into the given carrier using the provided injector.
40+
///
41+
/// - Parameters:
42+
/// - context: The `ServiceContext` from which relevant information is extracted.
43+
/// - carrier: The `Carrier` into which this information is injected.
44+
/// - injector: The ``Injector`` to use to inject extracted `ServiceContext` into the given `Carrier`.
3845
public func inject<Carrier, Inject>(_ context: ServiceContext, into carrier: inout Carrier, using injector: Inject)
3946
where Inject: Injector, Carrier == Inject.Carrier {
4047
for instrument in self.instruments { instrument.inject(context, into: &carrier, using: injector) }
4148
}
4249

50+
/// Extract values from a carrier, using the given extractor, and inject them into the provided service context.
51+
/// - Parameters:
52+
/// - carrier: The `Carrier` that was used to propagate values across boundaries.
53+
/// - context: The `ServiceContext` into which these values should be injected.
54+
/// - extractor: The ``Extractor`` that extracts values from the given `Carrier`.
4355
public func extract<Carrier, Extract>(
4456
_ carrier: Carrier,
4557
into context: inout ServiceContext,

Sources/Instrumentation/NoOpInstrument.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import ServiceContextModule
1616

17-
/// A "no op" implementation of an ``Instrument``.
17+
/// A "no op" implementation of an Instrument.
1818
public struct NoOpInstrument: Instrument {
1919
public init() {}
2020

0 commit comments

Comments
 (0)