@@ -36,16 +36,16 @@ public class ObservabilitySystem {
36
36
}
37
37
38
38
/// Create an ObservabilitySystem with a single diagnostics handler.
39
- public convenience init ( _ handler: @escaping ( ObservabilityScope , Diagnostic ) -> Void ) {
39
+ public convenience init ( _ handler: @escaping @ Sendable ( ObservabilityScope , Diagnostic ) -> Void ) {
40
40
self . init ( SingleDiagnosticsHandler ( handler) )
41
41
}
42
42
43
43
private struct SingleDiagnosticsHandler : ObservabilityHandlerProvider , DiagnosticsHandler {
44
- var diagnosticsHandler : DiagnosticsHandler { self }
44
+ var diagnosticsHandler : DiagnosticsHandler { self }
45
45
46
- let underlying : ( ObservabilityScope , Diagnostic ) -> Void
46
+ let underlying : @ Sendable ( ObservabilityScope , Diagnostic ) -> Void
47
47
48
- init ( _ underlying: @escaping ( ObservabilityScope , Diagnostic ) -> Void ) {
48
+ init ( _ underlying: @escaping @ Sendable ( ObservabilityScope , Diagnostic ) -> Void ) {
49
49
self . underlying = underlying
50
50
}
51
51
@@ -61,12 +61,12 @@ public protocol ObservabilityHandlerProvider {
61
61
62
62
// MARK: - ObservabilityScope
63
63
64
- public final class ObservabilityScope : DiagnosticsEmitterProtocol , CustomStringConvertible {
64
+ public final class ObservabilityScope : DiagnosticsEmitterProtocol , Sendable , CustomStringConvertible {
65
65
public let description : String
66
66
private let parent : ObservabilityScope ?
67
67
private let metadata : ObservabilityMetadata ?
68
68
69
- private var diagnosticsHandler : DiagnosticsHandlerWrapper
69
+ private let diagnosticsHandler : DiagnosticsHandlerWrapper
70
70
71
71
fileprivate init (
72
72
description: String ,
@@ -150,7 +150,7 @@ public final class ObservabilityScope: DiagnosticsEmitterProtocol, CustomStringC
150
150
151
151
// MARK: - Diagnostics
152
152
153
- public protocol DiagnosticsHandler {
153
+ public protocol DiagnosticsHandler : Sendable {
154
154
func handleDiagnostic( scope: ObservabilityScope , diagnostic: Diagnostic )
155
155
}
156
156
@@ -252,7 +252,7 @@ public struct DiagnosticsEmitter: DiagnosticsEmitterProtocol {
252
252
}
253
253
}
254
254
255
- public struct Diagnostic : CustomStringConvertible {
255
+ public struct Diagnostic : Sendable , CustomStringConvertible {
256
256
public let severity : Severity
257
257
public let message : String
258
258
public internal ( set) var metadata : ObservabilityMetadata ?
@@ -324,7 +324,7 @@ public struct Diagnostic: CustomStringConvertible {
324
324
Self ( severity: . debug, message: message. description, metadata: metadata)
325
325
}
326
326
327
- public enum Severity : Comparable {
327
+ public enum Severity : Comparable , Sendable {
328
328
case error
329
329
case warning
330
330
case info
@@ -380,10 +380,10 @@ public struct Diagnostic: CustomStringConvertible {
380
380
// FIXME: we currently require that Value conforms to CustomStringConvertible which sucks
381
381
// ideally Value would conform to Equatable but that has generic requirement
382
382
// luckily, this is about to change so we can clean this up soon
383
- public struct ObservabilityMetadata : CustomDebugStringConvertible {
383
+ public struct ObservabilityMetadata : Sendable , CustomDebugStringConvertible {
384
384
public typealias Key = ObservabilityMetadataKey
385
385
386
- private var _storage = [ AnyKey: Any ] ( )
386
+ private var _storage = [ AnyKey: Sendable ] ( )
387
387
388
388
public init ( ) { }
389
389
@@ -414,7 +414,7 @@ public struct ObservabilityMetadata: CustomDebugStringConvertible {
414
414
///
415
415
/// - Parameter body: The closure to be invoked for each item stored in this `ObservabilityMetadata`,
416
416
/// passing the type-erased key and the associated value.
417
- public func forEach( _ body: ( AnyKey , Any ) throws -> Void ) rethrows {
417
+ public func forEach( _ body: ( AnyKey , Sendable ) throws -> Void ) rethrows {
418
418
try self . _storage. forEach { key, value in
419
419
try body ( key, value)
420
420
}
@@ -473,7 +473,7 @@ public struct ObservabilityMetadata: CustomDebugStringConvertible {
473
473
}
474
474
475
475
/// A type-erased `ObservabilityMetadataKey` used when iterating through the `ObservabilityMetadata` using its `forEach` method.
476
- public struct AnyKey {
476
+ public struct AnyKey : Sendable {
477
477
/// The key's type represented erased to an `Any.Type`.
478
478
public let keyType : Any . Type
479
479
@@ -485,7 +485,7 @@ public struct ObservabilityMetadata: CustomDebugStringConvertible {
485
485
486
486
public protocol ObservabilityMetadataKey {
487
487
/// The type of value uniquely identified by this key.
488
- associatedtype Value
488
+ associatedtype Value : Sendable
489
489
}
490
490
491
491
extension ObservabilityMetadata . AnyKey : Hashable {
@@ -569,11 +569,11 @@ extension ObservabilityMetadata {
569
569
}
570
570
}
571
571
572
- private enum LegacyLocationKey : Key {
572
+ private enum LegacyLocationKey : Key , Sendable {
573
573
typealias Value = DiagnosticLocationWrapper
574
574
}
575
575
576
- public struct DiagnosticLocationWrapper : CustomStringConvertible {
576
+ public struct DiagnosticLocationWrapper : Sendable , CustomStringConvertible {
577
577
let underlying : DiagnosticLocation
578
578
579
579
public init ( _ underlying: DiagnosticLocation ) {
@@ -597,11 +597,11 @@ extension ObservabilityMetadata {
597
597
}
598
598
}
599
599
600
- private enum LegacyDataKey : Key {
600
+ private enum LegacyDataKey : Key , Sendable {
601
601
typealias Value = DiagnosticDataWrapper
602
602
}
603
603
604
- struct DiagnosticDataWrapper : CustomStringConvertible {
604
+ struct DiagnosticDataWrapper : Sendable , CustomStringConvertible {
605
605
let underlying : DiagnosticData
606
606
607
607
public init ( _ underlying: DiagnosticData ) {
0 commit comments