You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/Instrumentation/Instrument.swift
+18-10Lines changed: 18 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -14,20 +14,25 @@
14
14
15
15
import ServiceContextModule
16
16
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.
18
21
publicprotocolExtractor:Sendable{
19
22
/// The carrier to extract values from.
20
23
associatedtypeCarrier:Sendable
21
24
22
25
/// Extract the value for the given key from the `Carrier`.
23
26
///
24
27
/// - Parameters:
25
-
/// - key: The key to be extracted.
28
+
/// - key: The key to extract.
26
29
/// - carrier: The `Carrier` to extract from.
27
30
func extract(key:String, from carrier:Carrier)->String?
28
31
}
29
32
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.
31
36
publicprotocolInjector:Sendable{
32
37
/// The carrier to inject values into.
33
38
associatedtypeCarrier:Sendable
@@ -41,10 +46,13 @@ public protocol Injector: Sendable {
41
46
func inject(_ value:String, forKey key:String, into carrier:inoutCarrier)
42
47
}
43
48
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.
46
53
publicprotocolInstrument: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
+
///
48
56
/// It's quite common for `Instrument`s to come up with new values if they weren't passed along in the given `Carrier`.
49
57
///
50
58
/// - Parameters:
@@ -54,12 +62,12 @@ public protocol Instrument: Sendable {
54
62
func extract<Carrier, Extract>(_ carrier:Carrier, into context:inoutServiceContext, using extractor:Extract)
55
63
where Extract:Extractor, Extract.Carrier ==Carrier
56
64
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.
58
66
///
59
67
/// - 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`.
63
71
func inject<Carrier, Inject>(_ context:ServiceContext, into carrier:inoutCarrier, using injector:Inject)
Copy file name to clipboardExpand all lines: Sources/Instrumentation/MultiplexInstrument.swift
+17-5Lines changed: 17 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -14,14 +14,15 @@
14
14
15
15
import ServiceContextModule
16
16
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.
19
19
publicstructMultiplexInstrument{
20
20
privatevarinstruments:[Instrument]
21
21
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:)``
0 commit comments