From 030dec3a6fad2d0c7128c612dba6b03a4d78b250 Mon Sep 17 00:00:00 2001 From: Aryan Shah Date: Tue, 17 Sep 2024 14:20:11 +0100 Subject: [PATCH 1/2] Store the EventLoop description property upon initializing instead of computing it each time request is set. --- .../ConnectionPool/HTTP1/HTTP1ClientChannelHandler.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/AsyncHTTPClient/ConnectionPool/HTTP1/HTTP1ClientChannelHandler.swift b/Sources/AsyncHTTPClient/ConnectionPool/HTTP1/HTTP1ClientChannelHandler.swift index 86d2547ef..9e39a83d6 100644 --- a/Sources/AsyncHTTPClient/ConnectionPool/HTTP1/HTTP1ClientChannelHandler.swift +++ b/Sources/AsyncHTTPClient/ConnectionPool/HTTP1/HTTP1ClientChannelHandler.swift @@ -36,7 +36,7 @@ final class HTTP1ClientChannelHandler: ChannelDuplexHandler { if let newRequest = self.request { var requestLogger = newRequest.logger requestLogger[metadataKey: "ahc-connection-id"] = self.connectionIdLoggerMetadata - requestLogger[metadataKey: "ahc-el"] = "\(self.eventLoop)" + requestLogger[metadataKey: "ahc-el"] = self.eventLoopDescription self.logger = requestLogger if let idleReadTimeout = newRequest.requestOptions.idleReadTimeout { @@ -72,11 +72,13 @@ final class HTTP1ClientChannelHandler: ChannelDuplexHandler { private let backgroundLogger: Logger private var logger: Logger private let eventLoop: EventLoop + private let eventLoopDescription: Logger.MetadataValue private let connectionIdLoggerMetadata: Logger.MetadataValue var onConnectionIdle: () -> Void = {} init(eventLoop: EventLoop, backgroundLogger: Logger, connectionIdLoggerMetadata: Logger.MetadataValue) { self.eventLoop = eventLoop + self.eventLoopDescription = Logger.MetadataValue(stringLiteral: eventLoop.description) self.backgroundLogger = backgroundLogger self.logger = backgroundLogger self.connectionIdLoggerMetadata = connectionIdLoggerMetadata From d32fa8bccd55d95d7168d49498c4b0a2eac656b1 Mon Sep 17 00:00:00 2001 From: Aryan Shah Date: Thu, 19 Sep 2024 12:54:44 +0100 Subject: [PATCH 2/2] Use string interpolation to initialize Logger.MetadataValue --- .../ConnectionPool/HTTP1/HTTP1ClientChannelHandler.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/AsyncHTTPClient/ConnectionPool/HTTP1/HTTP1ClientChannelHandler.swift b/Sources/AsyncHTTPClient/ConnectionPool/HTTP1/HTTP1ClientChannelHandler.swift index 9e39a83d6..41a56c91b 100644 --- a/Sources/AsyncHTTPClient/ConnectionPool/HTTP1/HTTP1ClientChannelHandler.swift +++ b/Sources/AsyncHTTPClient/ConnectionPool/HTTP1/HTTP1ClientChannelHandler.swift @@ -78,7 +78,7 @@ final class HTTP1ClientChannelHandler: ChannelDuplexHandler { var onConnectionIdle: () -> Void = {} init(eventLoop: EventLoop, backgroundLogger: Logger, connectionIdLoggerMetadata: Logger.MetadataValue) { self.eventLoop = eventLoop - self.eventLoopDescription = Logger.MetadataValue(stringLiteral: eventLoop.description) + self.eventLoopDescription = "\(eventLoop.description)" self.backgroundLogger = backgroundLogger self.logger = backgroundLogger self.connectionIdLoggerMetadata = connectionIdLoggerMetadata