Skip to content

Commit 3feb981

Browse files
authored
fixing docs (#198)
- update docs ordering to resolve swift-format lint concerns - adding deprecation summary to redirect readers to correct API for deprecated versions - updating .swift-format to preserve checking going forward resolves #182
1 parent db35d03 commit 3feb981

File tree

12 files changed

+69
-28
lines changed

12 files changed

+69
-28
lines changed

.swift-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
]
2626
},
2727
"rules" : {
28-
"AllPublicDeclarationsHaveDocumentation" : false,
28+
"AllPublicDeclarationsHaveDocumentation" : true,
2929
"AlwaysUseLiteralForEmptyCollectionInit" : false,
3030
"AlwaysUseLowerCamelCase" : false,
3131
"AmbiguousTrailingClosureOverload" : true,

Sources/InMemoryTracing/InMemoryTracer.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@ import Tracing
2727
/// ``popFinishedSpans()`` or any of the `clear...` methods (such as ``clearFinishedSpans()``)
2828
public struct InMemoryTracer: Tracer {
2929

30+
/// The strategy for generating trace and span identifiers.
3031
public let idGenerator: IDGenerator
3132

33+
/// A Boolean value that indicates whether the tracer records injected values.
3234
public let recordInjections: Bool
35+
/// A Boolean value that indicates whether the tracer records extracted values.
3336
public let recordExtractions: Bool
3437

3538
struct State {

Sources/Instrumentation/Locks.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,14 @@ extension ReadWriteLock {
194194
public final class LockedValueBox<Value: Sendable>: @unchecked Sendable {
195195
private let lock = ReadWriteLock()
196196
private var value: Value
197+
/// Creates a new locking instance for the value you provide.
197198
public init(_ value: Value) {
198199
self.value = value
199200
}
200201

202+
/// Provides access to the locked value with a writer lock for the duration of the closure that you provide.
203+
/// - Parameter work: The closure that provides the value within a writer lock.
204+
/// - Returns: The value that you return from the closure.
201205
public func withValue<R>(_ work: (inout Value) throws -> R) rethrows -> R {
202206
try self.lock.withWriterLock {
203207
try work(&self.value)

Sources/Instrumentation/NoOpInstrument.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import ServiceContextModule
1616

1717
/// A "no op" implementation of an Instrument.
1818
public struct NoOpInstrument: Instrument {
19+
/// Creates a new no-op instrument.
1920
public init() {}
2021
/// Extract values from a service context and inject them into the given carrier using the provided injector.
2122
///

Sources/Tracing/Tracer.swift

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,22 +346,25 @@ public func withSpan<T, Instant: TracerInstant>(
346346
}
347347
}
348348

349-
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
350349
/// Start a new span and automatically end when the operation completes,
351350
/// including recording the error in case the operation throws.
352351
///
352+
/// @DeprecationSummary {
353+
/// Use ``withSpan(_:at:context:ofKind:isolation:function:file:line:_:)`` instead.
354+
/// }
355+
///
353356
/// - Parameters:
354357
/// - operationName: The name of the operation being traced. This may be a handler function, a database call, and so on.
355358
/// - instant: The time instant at which the span started.
356359
/// - context: The `ServiceContext` providing information on where to start the new ``Span``.
357360
/// - kind: The ``SpanKind`` of the new ``Span``.
358-
/// - isolation: Defaulted parameter for inheriting isolation of calling actor.
359361
/// - function: The function name in which the span was started.
360362
/// - fileID: The `fileID` where the span was started.
361363
/// - line: The file line where the span was started.
362364
/// - operation: The operation that this span measures.
363365
/// - Returns: the value returned by `operation`.
364366
/// - Throws: the error the `operation` throws (if any).
367+
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
365368
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext
366369
public func withSpan<T, Instant: TracerInstant>(
367370
_ operationName: String,
@@ -433,11 +436,13 @@ public func withSpan<T>(
433436
}
434437
}
435438

436-
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
437-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext
438439
/// Start a new span and automatically end when the operation completes,
439440
/// including recording the error in case the operation throws.
440441
///
442+
/// @DeprecationSummary {
443+
/// Use ``withSpan(_:at:context:ofKind:isolation:function:file:line:_:)`` instead.
444+
/// }
445+
///
441446
/// - Parameters:
442447
/// - operationName: The name of the operation being traced. This may be a handler function, a database call, and so on.
443448
/// - context: The `ServiceContext` providing information on where to start the new ``Span``.
@@ -448,6 +453,8 @@ public func withSpan<T>(
448453
/// - operation: The operation that this span measures.
449454
/// - Returns: the value returned by `operation`.
450455
/// - Throws: the error the `operation` throws (if any).
456+
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
457+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext
451458
public func withSpan<T>(
452459
_ operationName: String,
453460
context: @autoclosure () -> ServiceContext = .current ?? .topLevel,
@@ -519,10 +526,13 @@ public func withSpan<T>(
519526
}
520527
}
521528

522-
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
523529
/// Start a new span and automatically end when the operation completes,
524530
/// including recording the error in case the operation throws.
525531
///
532+
/// @DeprecationSummary {
533+
/// Use ``withSpan(_:at:context:ofKind:isolation:function:file:line:_:)`` instead.
534+
/// }
535+
///
526536
/// - Parameters:
527537
/// - operationName: The name of the operation being traced. This may be a handler function, a database call, and so on.
528538
/// - context: The `ServiceContext` providing information on where to start the new ``Span``.
@@ -534,6 +544,7 @@ public func withSpan<T>(
534544
/// - operation: The operation that this span measures.
535545
/// - Returns: the value returned by `operation`.
536546
/// - Throws: the error the `operation` throws (if any).
547+
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
537548
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
538549
public func withSpan<T>(
539550
_ operationName: String,

Sources/Tracing/TracerProtocol+Legacy.swift

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,22 +338,25 @@ extension LegacyTracer {
338338
}
339339

340340
// swift-format-ignore: Spacing // fights with formatter
341-
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
342341
/// Start a new span and automatically end when the operation completes,
343342
/// including recording the error in case the operation throws.
344343
///
344+
/// @DeprecationSummary {
345+
/// Use ``withSpan(_:at:context:ofKind:isolation:function:file:line:_:)`` instead.
346+
/// }
347+
///
345348
/// - Parameters:
346349
/// - operationName: The name of the operation being traced. This may be a handler function, a database call, and so on.
347350
/// - instant: the time instant at which the span started.
348351
/// - context: The `ServiceContext` providing information on where to start the new ``Span``.
349352
/// - kind: The ``SpanKind`` of the new ``Span``.
350-
/// - isolation: Defaulted parameter for inheriting isolation of calling actor.
351353
/// - function: The function name in which the span started.
352354
/// - fileID: The `fileID` where the span started.
353355
/// - line: The file line where the span started.
354356
/// - operation: The operation that this span measures.
355357
/// - Returns: the value returned by `operation`.
356358
/// - Throws: the error the `operation` throws (if any).
359+
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
357360
public func withAnySpan<T, Instant: TracerInstant>(
358361
_ operationName: String,
359362
at instant: @autoclosure () -> Instant,
@@ -439,10 +442,13 @@ extension LegacyTracer {
439442
}
440443

441444
// swift-format-ignore: Spacing // fights with formatter
442-
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
443445
/// Start a new span and automatically end when the operation completes,
444446
/// including recording the error in case the operation throws.
445447
///
448+
/// @DeprecationSummary {
449+
/// Use ``withSpan(_:at:context:ofKind:isolation:function:file:line:_:)`` instead.
450+
/// }
451+
///
446452
/// - Parameters:
447453
/// - operationName: The name of the operation being traced. This may be a handler function, a database call, and so on.
448454
/// - context: The `ServiceContext` providing information on where to start the new ``Span``.
@@ -453,6 +459,7 @@ extension LegacyTracer {
453459
/// - operation: The operation that this span measures.
454460
/// - Returns: the value returned by `operation`.
455461
/// - Throws: the error the `operation` throws (if any).
462+
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
456463
public func withAnySpan<T>(
457464
_ operationName: String,
458465
context: @autoclosure () -> ServiceContext = .current ?? .topLevel,
@@ -647,10 +654,13 @@ extension Tracer {
647654
}
648655

649656
// swift-format-ignore: Spacing // fights with formatter
650-
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
651657
/// Start a new span and automatically end when the operation completes,
652658
/// including recording the error in case the operation throws.
653659
///
660+
/// @DeprecationSummary {
661+
/// Use ``withSpan(_:at:context:ofKind:isolation:function:file:line:_:)`` instead.
662+
/// }
663+
///
654664
/// - Parameters:
655665
/// - operationName: The name of the operation being traced. This may be a handler function, a database call, and so on.
656666
/// - context: The `ServiceContext` providing information on where to start the new ``Span``.
@@ -662,6 +672,7 @@ extension Tracer {
662672
/// - operation: The operation that this span measures.
663673
/// - Returns: the value returned by `operation`.
664674
/// - Throws: the error the `operation` throws (if any).
675+
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
665676
public func withAnySpan<T>(
666677
_ operationName: String,
667678
at instant: @autoclosure () -> some TracerInstant = DefaultTracerClock.now,

Sources/Tracing/TracerProtocol.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,12 @@ extension Tracer {
289289
}
290290

291291
// swift-format-ignore: Spacing // fights with formatter
292+
/// Start a new span and automatically end it when the operation completes,
293+
/// including recording the error in case the operation throws.
294+
///
295+
/// @DeprecationSummary {
296+
/// Use ``withSpan(_:context:ofKind:isolation:function:file:line:_:)`` instead
297+
/// }
292298
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
293299
public func withSpan<T>(
294300
_ operationName: String,
@@ -374,10 +380,13 @@ extension Tracer {
374380
}
375381

376382
// swift-format-ignore: Spacing // fights with formatter
377-
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
378383
/// Start a new span and automatically end it when the operation completes,
379384
/// including recording the error in case the operation throws.
380385
///
386+
/// @DeprecationSummary {
387+
/// Use ``withSpan(_:at:context:ofKind:isolation:function:file:line:_:)`` instead.
388+
/// }
389+
///
381390
/// - Parameters:
382391
/// - operationName: The name of the operation being traced. This may be a handler function, a database call, and so on.
383392
/// - context: The `ServiceContext` providing information on where to start the new ``Span``.
@@ -389,6 +398,7 @@ extension Tracer {
389398
/// - operation: The operation that this span measures.
390399
/// - Returns: the value returned by `operation`.
391400
/// - Throws: the error the `operation` throws (if any).
401+
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
392402
public func withSpan<T>(
393403
_ operationName: String,
394404
context: @autoclosure () -> ServiceContext = .current ?? .topLevel,

Sources/_TracingBenchmarks/SpanAttributesDSLBenchmark.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import _TracingBenchmarkTools
1919
// swift-format-ignore: DontRepeatTypeInStaticProperties
2020
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext
2121
enum DSLBenchmarks {
22+
/// Built-in span attribute DSL benchmarks
2223
public static let SpanAttributesDSLBenchmarks: [BenchmarkInfo] = [
2324
BenchmarkInfo(
2425
name: "SpanAttributesDSLBenchmarks.000_bench_empty",

Tests/TracingTests/DynamicTracepointTracerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ extension DynamicTracepointTestTracer {
229229
private let startTimestampNanosSinceEpoch: UInt64
230230
private(set) var endTimestampNanosSinceEpoch: UInt64?
231231

232-
public var operationName: String
232+
package var operationName: String
233233
private(set) var context: ServiceContext
234234
private(set) var isRecording: Bool = false
235235

Tests/TracingTests/SpanTests.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ extension SpanAttribute {
300300
}
301301

302302
extension SpanAttributes {
303-
public var sampleHttp: HTTPAttributes {
303+
package var sampleHttp: HTTPAttributes {
304304
get {
305305
.init(attributes: self)
306306
}
@@ -311,35 +311,35 @@ extension SpanAttributes {
311311
}
312312

313313
@dynamicMemberLookup
314-
public struct HTTPAttributes: SpanAttributeNamespace {
315-
public var attributes: SpanAttributes
316-
public init(attributes: SpanAttributes) {
314+
package struct HTTPAttributes: SpanAttributeNamespace {
315+
package var attributes: SpanAttributes
316+
package init(attributes: SpanAttributes) {
317317
self.attributes = attributes
318318
}
319319

320-
public struct NestedSpanAttributes: NestedSpanAttributesProtocol {
321-
public init() {}
320+
package struct NestedSpanAttributes: NestedSpanAttributesProtocol {
321+
package init() {}
322322

323-
public var statusCode: Key<Int> {
323+
package var statusCode: Key<Int> {
324324
"http.status_code"
325325
}
326326

327-
public var codesArray: Key<[Int]> {
327+
package var codesArray: Key<[Int]> {
328328
"http.codes_array"
329329
}
330330

331-
public var customType: Key<CustomAttributeValue> {
331+
package var customType: Key<CustomAttributeValue> {
332332
"http.custom_value"
333333
}
334334
}
335335
}
336336

337-
public struct CustomAttributeValue: Equatable, Sendable, CustomStringConvertible, SpanAttributeConvertible {
338-
public func toSpanAttribute() -> SpanAttribute {
337+
package struct CustomAttributeValue: Equatable, Sendable, CustomStringConvertible, SpanAttributeConvertible {
338+
package func toSpanAttribute() -> SpanAttribute {
339339
.stringConvertible(self)
340340
}
341341

342-
public var description: String {
342+
package var description: String {
343343
"CustomAttributeValue()"
344344
}
345345
}

0 commit comments

Comments
 (0)