@@ -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,13 @@ 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+ let task : HTTPClient . Task < Delegate . Response > =
789+ Task < Delegate . Response > (
808790 eventLoop: taskEL,
809791 logger: logger,
792+ tracing: self . tracing,
810793 makeOrGetFileIOThreadPool: self . makeOrGetFileIOThreadPool
811794 )
812- }
813- #else
814- task = Task < Delegate . Response > (
815- eventLoop: taskEL,
816- logger: logger,
817- makeOrGetFileIOThreadPool: self . makeOrGetFileIOThreadPool
818- )
819- #endif // TracingSupport
820795
821796 do {
822797 let requestBag = try RequestBag (
@@ -929,9 +904,8 @@ public final class HTTPClient: Sendable {
929904 /// A method with access to the HTTP/2 stream channel that is called when creating the stream.
930905 public var http2StreamChannelDebugInitializer : ( @Sendable ( Channel ) -> EventLoopFuture < Void > ) ?
931906
932- #if TracingSupport
907+ /// Configuration how distributed traces are created and handled.
933908 public var tracing : TracingConfiguration = . init( )
934- #endif
935909
936910 public init (
937911 tlsConfiguration: TLSConfiguration ? = nil ,
@@ -1062,7 +1036,6 @@ public final class HTTPClient: Sendable {
10621036 self . http2StreamChannelDebugInitializer = http2StreamChannelDebugInitializer
10631037 }
10641038
1065- #if TracingSupport
10661039 public init (
10671040 tlsConfiguration: TLSConfiguration ? = nil ,
10681041 redirectConfiguration: RedirectConfiguration ? = nil ,
@@ -1090,10 +1063,8 @@ public final class HTTPClient: Sendable {
10901063 self . http2StreamChannelDebugInitializer = http2StreamChannelDebugInitializer
10911064 self . tracing = tracing
10921065 }
1093- #endif
10941066 }
10951067
1096- #if TracingSupport
10971068 public struct TracingConfiguration : Sendable {
10981069
10991070 @usableFromInline
@@ -1149,7 +1120,6 @@ public final class HTTPClient: Sendable {
11491120 public init ( ) { }
11501121 }
11511122 }
1152- #endif
11531123
11541124 /// Specifies how `EventLoopGroup` will be created and establishes lifecycle ownership.
11551125 public enum EventLoopGroupProvider {
0 commit comments