@@ -23,10 +23,7 @@ import NIOPosix
2323import NIOSSL
2424import NIOTLS
2525import NIOTransportServices
26-
27- #if TracingSupport
2826import Tracing
29- #endif
3027
3128extension Logger {
3229 private func requestInfo( _ request: HTTPClient . Request ) -> Logger . Metadata . Value {
@@ -77,12 +74,17 @@ public final class HTTPClient: Sendable {
7774 private let state : NIOLockedValueBox < State >
7875 private let canBeShutDown : Bool
7976
80- #if TracingSupport
77+ /// Tracer configured for this HTTPClient at configuration time.
8178 @available ( macOS 10 . 15 , iOS 13 , tvOS 13 , watchOS 6 , * )
8279 public var tracer : ( any Tracer ) ? {
8380 configuration. tracing. tracer
8481 }
85- #endif // TracingSupport
82+
83+ /// Access to tracing configuration in order to get configured attribute keys etc.
84+ @usableFromInline
85+ package var tracing : TracingConfiguration {
86+ self . configuration. tracing
87+ }
8688
8789 static let loggingDisabled = Logger ( label: " AHC-do-not-log " , factory: { _ in SwiftLogNoOpLogHandler ( ) } )
8890
@@ -748,28 +750,17 @@ public final class HTTPClient: Sendable {
748750 ]
749751 )
750752
751- let failedTask : Task < Delegate . Response > ? = self . state. withLockedValue { state in
753+ let failedTask : Task < Delegate . Response > ? = self . state. withLockedValue { state -> ( Task < Delegate . Response > ? ) in
752754 switch state {
753755 case . upAndRunning:
754756 return nil
755757 case . shuttingDown, . shutDown:
756758 logger. debug ( " client is shutting down, failing request " )
757- #if TracingSupport
758- if #available( macOS 10 . 15 , iOS 13 , tvOS 13 , watchOS 6 , * ) {
759- return Task< Delegate . Response> . failedTask(
760- eventLoop: taskEL,
761- error: HTTPClientError . alreadyShutdown,
762- logger: logger,
763- tracer: tracer,
764- makeOrGetFileIOThreadPool: self . makeOrGetFileIOThreadPool
765- )
766- }
767- #endif // TracingSupport
768-
769759 return Task< Delegate . Response> . failedTask(
770760 eventLoop: taskEL,
771761 error: HTTPClientError . alreadyShutdown,
772762 logger: logger,
763+ tracing: tracing,
773764 makeOrGetFileIOThreadPool: self . makeOrGetFileIOThreadPool
774765 )
775766 }
@@ -794,29 +785,14 @@ public final class HTTPClient: Sendable {
794785 }
795786 } ( )
796787
797- let task : HTTPClient . Task < Delegate . Response >
798- #if TracingSupport
799- if #available( macOS 10 . 15 , iOS 13 , tvOS 13 , watchOS 6 , * ) {
800- task = Task < Delegate . Response > (
801- eventLoop: taskEL,
802- logger: logger,
803- tracer: tracer,
804- makeOrGetFileIOThreadPool: self . makeOrGetFileIOThreadPool
805- )
806- } else {
807- task = Task < Delegate . Response > (
788+
789+ let task : HTTPClient . Task < Delegate . Response > =
790+ Task < Delegate . Response > (
808791 eventLoop: taskEL,
809792 logger: logger,
793+ tracing: self . tracing,
810794 makeOrGetFileIOThreadPool: self . makeOrGetFileIOThreadPool
811795 )
812- }
813- #else
814- task = Task < Delegate . Response > (
815- eventLoop: taskEL,
816- logger: logger,
817- makeOrGetFileIOThreadPool: self . makeOrGetFileIOThreadPool
818- )
819- #endif // TracingSupport
820796
821797 do {
822798 let requestBag = try RequestBag (
@@ -929,9 +905,8 @@ public final class HTTPClient: Sendable {
929905 /// A method with access to the HTTP/2 stream channel that is called when creating the stream.
930906 public var http2StreamChannelDebugInitializer : ( @Sendable ( Channel ) -> EventLoopFuture < Void > ) ?
931907
932- #if TracingSupport
908+ /// Configuration how distributed traces are created and handled.
933909 public var tracing : TracingConfiguration = . init( )
934- #endif
935910
936911 public init (
937912 tlsConfiguration: TLSConfiguration ? = nil ,
@@ -1062,7 +1037,6 @@ public final class HTTPClient: Sendable {
10621037 self . http2StreamChannelDebugInitializer = http2StreamChannelDebugInitializer
10631038 }
10641039
1065- #if TracingSupport
10661040 public init (
10671041 tlsConfiguration: TLSConfiguration ? = nil ,
10681042 redirectConfiguration: RedirectConfiguration ? = nil ,
@@ -1090,10 +1064,8 @@ public final class HTTPClient: Sendable {
10901064 self . http2StreamChannelDebugInitializer = http2StreamChannelDebugInitializer
10911065 self . tracing = tracing
10921066 }
1093- #endif
10941067 }
10951068
1096- #if TracingSupport
10971069 public struct TracingConfiguration : Sendable {
10981070
10991071 @usableFromInline
@@ -1149,7 +1121,6 @@ public final class HTTPClient: Sendable {
11491121 public init ( ) { }
11501122 }
11511123 }
1152- #endif
11531124
11541125 /// Specifies how `EventLoopGroup` will be created and establishes lifecycle ownership.
11551126 public enum EventLoopGroupProvider {
0 commit comments