Skip to content

Commit cf109e0

Browse files
committed
adds abstracts and cleans up existing abstracts to full sentences, removes some passive voice, and apply style guidelines.
1 parent 4f7035b commit cf109e0

File tree

9 files changed

+581
-299
lines changed

9 files changed

+581
-299
lines changed

Sources/Instrumentation/NoOpInstrument.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,23 @@ import ServiceContextModule
1717
/// A "no op" implementation of an Instrument.
1818
public struct NoOpInstrument: Instrument {
1919
public init() {}
20-
20+
/// Extract values from a service context and inject them into the given carrier using the provided injector.
21+
///
22+
/// - Parameters:
23+
/// - context: The `ServiceContext` from which relevant information is extracted.
24+
/// - carrier: The `Carrier` into which this information is injected.
25+
/// - injector: The ``Injector`` to use to inject extracted `ServiceContext` into the given `Carrier`.
2126
public func inject<Carrier, Inject>(_ context: ServiceContext, into carrier: inout Carrier, using injector: Inject)
2227
where Inject: Injector, Carrier == Inject.Carrier {
2328
// no-op
2429
}
2530

31+
/// Extract values from a carrier, using the given extractor, and inject them into the provided service context.
32+
///
33+
/// - Parameters:
34+
/// - carrier: The `Carrier` that was used to propagate values across boundaries.
35+
/// - context: The `ServiceContext` into which these values should be injected.
36+
/// - extractor: The ``Extractor`` that extracts values from the given `Carrier`.
2637
public func extract<Carrier, Extract>(
2738
_ carrier: Carrier,
2839
into context: inout ServiceContext,

Sources/Tracing/NoOpTracer.swift

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,22 @@
1818
/// Tracer that ignores all operations, used when no tracing is required.
1919
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext
2020
public struct NoOpTracer: LegacyTracer {
21+
22+
/// The type used to represent a span.
2123
public typealias Span = NoOpSpan
2224

25+
/// Creates a no-op tracer.
2326
public init() {}
2427

28+
/// Start a new span using the global bootstrapped tracer reimplementation.
29+
/// - Parameters:
30+
/// - operationName: The name of the operation being traced. This may be a handler function, database call, ...
31+
/// - context: The `ServiceContext` providing information on where to start the new ``Span``.
32+
/// - kind: The ``SpanKind`` of the new ``Span``.
33+
/// - instant: the time instant at which the span started
34+
/// - function: The function name in which the span was started
35+
/// - fileID: The `fileID` where the span was started.
36+
/// - line: The file line where the span was started.
2537
public func startAnySpan<Instant: TracerInstant>(
2638
_ operationName: String,
2739
context: @autoclosure () -> ServiceContext,
@@ -34,13 +46,31 @@ public struct NoOpTracer: LegacyTracer {
3446
NoOpSpan(context: context())
3547
}
3648

49+
/// Export all ended spans to the configured backend that have not yet been exported.
50+
///
51+
/// This function should only be called in cases where it is absolutely necessary,
52+
/// such as when using some FaaS providers that may suspend the process after an invocation, but before the backend exports the completed spans.
53+
///
54+
/// This function should not block indefinitely, implementations should offer a configurable timeout for flush operations.
3755
public func forceFlush() {}
3856

57+
/// Extract values from a service context and inject them into the given carrier using the provided injector.
58+
///
59+
/// - Parameters:
60+
/// - context: The `ServiceContext` from which relevant information is extracted.
61+
/// - carrier: The `Carrier` into which this information is injected.
62+
/// - injector: The `Injector` to use to inject extracted `ServiceContext` into the given `Carrier`.
3963
public func inject<Carrier, Inject>(_ context: ServiceContext, into carrier: inout Carrier, using injector: Inject)
4064
where Inject: Injector, Carrier == Inject.Carrier {
4165
// no-op
4266
}
4367

68+
/// Extract values from a carrier, using the given extractor, and inject them into the provided service context.
69+
///
70+
/// - Parameters:
71+
/// - carrier: The `Carrier` that was used to propagate values across boundaries.
72+
/// - context: The `ServiceContext` into which these values should be injected.
73+
/// - extractor: The `Extractor` that extracts values from the given `Carrier`.
4474
public func extract<Carrier, Extract>(
4575
_ carrier: Carrier,
4676
into context: inout ServiceContext,
@@ -50,12 +80,18 @@ public struct NoOpTracer: LegacyTracer {
5080
// no-op
5181
}
5282

83+
/// A span created by the no-op tracer.
84+
///
85+
/// This span maintains its context, but does not record events, links, or errors and provides no attributes.
5386
public struct NoOpSpan: Tracing.Span {
87+
/// The service context of the span.
5488
public let context: ServiceContext
89+
/// A Boolean value that indicates whether the span is actively recording updates.
5590
public var isRecording: Bool {
5691
false
5792
}
5893

94+
/// The operation name this span represents.
5995
public var operationName: String {
6096
get {
6197
"noop"
@@ -65,22 +101,35 @@ public struct NoOpTracer: LegacyTracer {
65101
}
66102
}
67103

104+
/// Creates a new no-op span with the context you provide.
105+
/// - Parameter context: The service context.
68106
public init(context: ServiceContext) {
69107
self.context = context
70108
}
71-
109+
/// Updates the status of the span to the value you provide.
110+
/// - Parameter status: The status to set.
72111
public func setStatus(_ status: SpanStatus) {}
73112

113+
/// Adds a link to the span.
114+
/// - Parameter link: The link to add.
74115
public func addLink(_ link: SpanLink) {}
75116

117+
/// Adds an event you provide to the span.
118+
/// - Parameter event: The event to record.
76119
public func addEvent(_ event: SpanEvent) {}
77120

121+
/// Records an error to the span.
122+
/// - Parameters:
123+
/// - error: The error to record.
124+
/// - attributes: Span attributes associated with the error.
125+
/// - instant: The time instant of the error.
78126
public func recordError<Instant: TracerInstant>(
79127
_ error: Error,
80128
attributes: SpanAttributes,
81129
at instant: @autoclosure () -> Instant
82130
) {}
83131

132+
/// The span attributes.
84133
public var attributes: SpanAttributes {
85134
get {
86135
[:]
@@ -90,6 +139,8 @@ public struct NoOpTracer: LegacyTracer {
90139
}
91140
}
92141

142+
/// Finishes the span.
143+
/// - Parameter instant: the time instant the span completed.
93144
public func end<Instant: TracerInstant>(at instant: @autoclosure () -> Instant) {
94145
// ignore
95146
}
@@ -98,6 +149,15 @@ public struct NoOpTracer: LegacyTracer {
98149

99150
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
100151
extension NoOpTracer: Tracer {
152+
/// Start a new span using the global bootstrapped tracer reimplementation.
153+
/// - Parameters:
154+
/// - operationName: The name of the operation being traced. This may be a handler function, database call, ...
155+
/// - context: The `ServiceContext` providing information on where to start the new ``Span``.
156+
/// - kind: The ``SpanKind`` of the new ``Span``.
157+
/// - instant: the time instant at which the span started
158+
/// - function: The function name in which the span was started
159+
/// - fileID: The `fileID` where the span was started.
160+
/// - line: The file line where the span was started.
101161
public func startSpan<Instant: TracerInstant>(
102162
_ operationName: String,
103163
context: @autoclosure () -> ServiceContext,

0 commit comments

Comments
 (0)