1212//
1313//===----------------------------------------------------------------------===//
1414
15- import Baggage
16- import BaggageLogging
15+ import BaggageContext
1716import Foundation
1817import Instrumentation
19- import TracingInstrumentation
18+ import Tracing
2019import Logging
2120import NIO
2221import NIOConcurrencyHelpers
@@ -233,7 +232,7 @@ public class HTTPClient {
233232 /// - url: Remote URL.
234233 /// - context: Baggage context associated with this request
235234 /// - deadline: Point in time by which the request must complete.
236- public func get( url: String , context: LoggingBaggageContextCarrier , deadline: NIODeadline ? = nil ) -> EventLoopFuture < Response > {
235+ public func get( url: String , context: BaggageContext , deadline: NIODeadline ? = nil ) -> EventLoopFuture < Response > {
237236 return self . execute ( . GET, url: url, context: context, deadline: deadline)
238237 }
239238
@@ -244,7 +243,7 @@ public class HTTPClient {
244243 /// - context: Baggage context associated with this request
245244 /// - body: Request body.
246245 /// - deadline: Point in time by which the request must complete.
247- public func post( url: String , context: LoggingBaggageContextCarrier , body: Body ? = nil , deadline: NIODeadline ? = nil ) -> EventLoopFuture < Response > {
246+ public func post( url: String , context: BaggageContext , body: Body ? = nil , deadline: NIODeadline ? = nil ) -> EventLoopFuture < Response > {
248247 return self . execute ( . POST, url: url, context: context, body: body, deadline: deadline)
249248 }
250249
@@ -255,7 +254,7 @@ public class HTTPClient {
255254 /// - context: Baggage context associated with this request
256255 /// - body: Request body.
257256 /// - deadline: Point in time by which the request must complete.
258- public func patch( url: String , context: LoggingBaggageContextCarrier , body: Body ? = nil , deadline: NIODeadline ? = nil ) -> EventLoopFuture < Response > {
257+ public func patch( url: String , context: BaggageContext , body: Body ? = nil , deadline: NIODeadline ? = nil ) -> EventLoopFuture < Response > {
259258 return self . execute ( . PATCH, url: url, context: context, body: body, deadline: deadline)
260259 }
261260
@@ -266,7 +265,7 @@ public class HTTPClient {
266265 /// - context: Baggage context associated with this request
267266 /// - body: Request body.
268267 /// - deadline: Point in time by which the request must complete.
269- public func put( url: String , context: LoggingBaggageContextCarrier , body: Body ? = nil , deadline: NIODeadline ? = nil ) -> EventLoopFuture < Response > {
268+ public func put( url: String , context: BaggageContext , body: Body ? = nil , deadline: NIODeadline ? = nil ) -> EventLoopFuture < Response > {
270269 return self . execute ( . PUT, url: url, context: context, body: body, deadline: deadline)
271270 }
272271
@@ -276,7 +275,7 @@ public class HTTPClient {
276275 /// - url: Remote URL.
277276 /// - context: Baggage context associated with this request
278277 /// - deadline: The time when the request must have been completed by.
279- public func delete( url: String , context: LoggingBaggageContextCarrier , deadline: NIODeadline ? = nil ) -> EventLoopFuture < Response > {
278+ public func delete( url: String , context: BaggageContext , deadline: NIODeadline ? = nil ) -> EventLoopFuture < Response > {
280279 return self . execute ( . DELETE, url: url, context: context, deadline: deadline)
281280 }
282281
@@ -288,7 +287,7 @@ public class HTTPClient {
288287 /// - context: Baggage context associated with this request
289288 /// - body: Request body.
290289 /// - deadline: Point in time by which the request must complete.
291- public func execute( _ method: HTTPMethod = . GET, url: String , context: LoggingBaggageContextCarrier , body: Body ? = nil , deadline: NIODeadline ? = nil ) -> EventLoopFuture < Response > {
290+ public func execute( _ method: HTTPMethod = . GET, url: String , context: BaggageContext , body: Body ? = nil , deadline: NIODeadline ? = nil ) -> EventLoopFuture < Response > {
292291 do {
293292 let request = try Request ( url: url, method: method, body: body)
294293 return self . execute ( request: request, context: context, deadline: deadline)
@@ -306,7 +305,7 @@ public class HTTPClient {
306305 /// - context: Baggage context associated with this request
307306 /// - body: Request body.
308307 /// - deadline: Point in time by which the request must complete.
309- public func execute( _ method: HTTPMethod = . GET, socketPath: String , urlPath: String , context: LoggingBaggageContextCarrier , body: Body ? = nil , deadline: NIODeadline ? = nil ) -> EventLoopFuture < Response > {
308+ public func execute( _ method: HTTPMethod = . GET, socketPath: String , urlPath: String , context: BaggageContext , body: Body ? = nil , deadline: NIODeadline ? = nil ) -> EventLoopFuture < Response > {
310309 do {
311310 guard let url = URL ( httpURLWithSocketPath: socketPath, uri: urlPath) else {
312311 throw HTTPClientError . invalidURL
@@ -328,7 +327,7 @@ public class HTTPClient {
328327 /// - body: Request body.
329328 /// - deadline: Point in time by which the request must complete.
330329 /// - logger: The logger to use for this request.
331- public func execute( _ method: HTTPMethod = . GET, secureSocketPath: String , urlPath: String , context: LoggingBaggageContextCarrier , body: Body ? = nil , deadline: NIODeadline ? = nil ) -> EventLoopFuture < Response > {
330+ public func execute( _ method: HTTPMethod = . GET, secureSocketPath: String , urlPath: String , context: BaggageContext , body: Body ? = nil , deadline: NIODeadline ? = nil ) -> EventLoopFuture < Response > {
332331 do {
333332 guard let url = URL ( httpsURLWithSocketPath: secureSocketPath, uri: urlPath) else {
334333 throw HTTPClientError . invalidURL
@@ -346,7 +345,7 @@ public class HTTPClient {
346345 /// - request: HTTP request to execute.
347346 /// - context: Baggage context associated with this request
348347 /// - deadline: Point in time by which the request must complete.
349- public func execute( request: Request , context: LoggingBaggageContextCarrier , deadline: NIODeadline ? = nil ) -> EventLoopFuture < Response > {
348+ public func execute( request: Request , context: BaggageContext , deadline: NIODeadline ? = nil ) -> EventLoopFuture < Response > {
350349 let accumulator = ResponseAccumulator ( request: request)
351350 return self . execute ( request: request, delegate: accumulator, context: context, deadline: deadline) . futureResult
352351 }
@@ -358,7 +357,7 @@ public class HTTPClient {
358357 /// - eventLoop: NIO Event Loop preference.
359358 /// - context: Baggage context associated with this request
360359 /// - deadline: Point in time by which the request must complete.
361- public func execute( request: Request , eventLoop: EventLoopPreference , context: LoggingBaggageContextCarrier , deadline: NIODeadline ? = nil ) -> EventLoopFuture < Response > {
360+ public func execute( request: Request , eventLoop: EventLoopPreference , context: BaggageContext , deadline: NIODeadline ? = nil ) -> EventLoopFuture < Response > {
362361 let accumulator = ResponseAccumulator ( request: request)
363362 return self . execute ( request: request, delegate: accumulator, eventLoop: eventLoop, context: context, deadline: deadline) . futureResult
364363 }
@@ -372,7 +371,7 @@ public class HTTPClient {
372371 /// - deadline: Point in time by which the request must complete.
373372 public func execute< Delegate: HTTPClientResponseDelegate > ( request: Request ,
374373 delegate: Delegate ,
375- context: LoggingBaggageContextCarrier ,
374+ context: BaggageContext ,
376375 deadline: NIODeadline ? = nil ) -> Task < Delegate . Response > {
377376 return self . execute ( request: request, delegate: delegate, eventLoop: . indifferent, context: context, deadline: deadline)
378377 }
@@ -388,9 +387,9 @@ public class HTTPClient {
388387 public func execute< Delegate: HTTPClientResponseDelegate > ( request: Request ,
389388 delegate: Delegate ,
390389 eventLoop eventLoopPreference: EventLoopPreference ,
391- context: LoggingBaggageContextCarrier ,
390+ context: BaggageContext ,
392391 deadline: NIODeadline ? = nil ) -> Task < Delegate . Response > {
393- var span = InstrumentationSystem . tracingInstrument . startSpan ( named: request. method. rawValue, context : context, ofKind: . client)
392+ let span = InstrumentationSystem . tracer . startSpan ( named: request. method. rawValue, baggage : context. baggage , ofKind: . client)
394393 span. attributes. http. method = request. method. rawValue
395394 span. attributes. http. scheme = request. scheme
396395 span. attributes. http. target = request. uri
@@ -402,7 +401,7 @@ public class HTTPClient {
402401 // TODO: net.peer.ip / Not required, but recommended
403402
404403 var request = request
405- InstrumentationSystem . instrument. inject ( span. context . baggage, into: & request. headers, using: HTTPHeadersInjector ( ) )
404+ InstrumentationSystem . instrument. inject ( span. baggage, into: & request. headers, using: HTTPHeadersInjector ( ) )
406405
407406 let logger = context. logger. attachingRequestInformation ( request, requestID: globalRequestID. add ( 1 ) )
408407
0 commit comments