File tree Expand file tree Collapse file tree 3 files changed +8
-9
lines changed
UseCases/Sources/HTTPEndToEnd Expand file tree Collapse file tree 3 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -15,13 +15,15 @@ import AsyncHTTPClient
15
15
import Baggage
16
16
import BaggageLogging
17
17
import Instrumentation
18
+ import Logging
18
19
import NIO
19
20
import NIOHTTP1
20
21
import NIOInstrumentation
21
22
22
23
struct InstrumentedHTTPClient {
23
24
private let client : HTTPClient
24
25
private let instrument : Instrument
26
+ private let logger = Logger ( label: " InstrumentedHTTPClient " )
25
27
26
28
init ( instrument: Instrument , eventLoopGroupProvider: HTTPClient . EventLoopGroupProvider ) {
27
29
self . client = HTTPClient ( eventLoopGroupProvider: eventLoopGroupProvider)
@@ -41,7 +43,7 @@ struct InstrumentedHTTPClient {
41
43
func execute( request: HTTPClient . Request , context: BaggageContext ) -> EventLoopFuture < HTTPClient . Response > {
42
44
var request = request
43
45
self . instrument. inject ( context, into: & request. headers, using: HTTPHeadersInjector ( ) )
44
- // context .logger.info("🌎 InstrumentedHTTPClient: Execute request")
46
+ self . logger. with ( context : context ) . info ( " 🌎 InstrumentedHTTPClient: Execute request " )
45
47
return self . client. execute ( request: request)
46
48
}
47
49
Original file line number Diff line number Diff line change 13
13
14
14
import AsyncHTTPClient
15
15
import Baggage
16
+ import BaggageLogging
16
17
import Instrumentation
17
18
import Logging
18
19
import NIO
@@ -39,12 +40,10 @@ final class OrderServiceHandler: ChannelInboundHandler {
39
40
40
41
self . instrument. extract ( requestHead. headers, into: & baggage, using: HTTPHeadersExtractor ( ) )
41
42
42
- // baggage.logger.info("🧾 Received order request")
43
- self . logger. info ( " 🧾 Received order request " )
43
+ self . logger. with ( context: baggage) . info ( " 🧾 Received order request " )
44
44
45
45
context. eventLoop. scheduleTask ( in: . seconds( 1 ) ) {
46
- // baggage.logger.info("🧾 Asking StorageService if your product exists")
47
- self . logger. info ( " 🧾 Asking StorageService if your product exists " )
46
+ self . logger. with ( context: baggage) . info ( " 🧾 Asking StorageService if your product exists " )
48
47
49
48
let request = try ! HTTPClient . Request ( url: " http://localhost:8081 " )
50
49
self . httpClient. execute ( request: request, context: baggage) . whenComplete { _ in
Original file line number Diff line number Diff line change @@ -35,12 +35,10 @@ final class StorageServiceHandler: ChannelInboundHandler {
35
35
var baggage = BaggageContext ( )
36
36
self . instrument. extract ( requestHead. headers, into: & baggage, using: HTTPHeadersExtractor ( ) )
37
37
38
- // baggage.logger.info("📦 Looking for the product")
39
- self . logger. info ( " 📦 Looking for the product " )
38
+ self . logger. with ( context: baggage) . info ( " 📦 Looking for the product " )
40
39
41
40
context. eventLoop. scheduleTask ( in: . seconds( 2 ) ) {
42
- // baggage.logger.info("📦 Found the product")
43
- self . logger. info ( " 📦 Found the product " )
41
+ self . logger. with ( context: baggage) . info ( " 📦 Found the product " )
44
42
let responseHead = HTTPResponseHead ( version: requestHead. version, status: . ok)
45
43
context. eventLoop. execute {
46
44
context. channel. write ( self . wrapOutboundOut ( . head( responseHead) ) , promise: nil )
You can’t perform that action at this time.
0 commit comments