From 624106b9967c1b984387555cafe2b249ee8e0a18 Mon Sep 17 00:00:00 2001 From: David Yaffe Date: Wed, 22 Jan 2025 14:36:09 -0500 Subject: [PATCH] add logging --- .../ClientRuntime/Networking/Http/CRT/CRTClientEngine.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/ClientRuntime/Networking/Http/CRT/CRTClientEngine.swift b/Sources/ClientRuntime/Networking/Http/CRT/CRTClientEngine.swift index 0d511e655..b3a336dc2 100644 --- a/Sources/ClientRuntime/Networking/Http/CRT/CRTClientEngine.swift +++ b/Sources/ClientRuntime/Networking/Http/CRT/CRTClientEngine.swift @@ -419,7 +419,7 @@ public class CRTClientEngine: HTTPClient { let acquireConnectionStart = Date().timeIntervalSinceReferenceDate logger.info("TEST LOGGER WORKS BEFORE ACQUIRE STREAM") // Retry logic for acquiring the stream - let stream = try await retryWithBackoff(maxRetries: 3, initialDelay: 0.5) { + let stream = try await retryWithBackoff(maxRetries: 3, initialDelay: 2) { try await connectionMgr.acquireStream(requestOptions: requestOptions) } let acquireConnectionEnd = Date().timeIntervalSinceReferenceDate @@ -484,6 +484,8 @@ public class CRTClientEngine: HTTPClient { if attempt >= maxRetries - 1 { throw error // Exhaust retries } + let logger = SwiftLogger(label: "RetryAcquireStreamLogger") + logger.info("RETRYING ACQUIRE STREAM DUE TO \(error)") await Task.sleep(UInt64(delay * 1_000_000_000)) // Delay before retry delay *= 2 // Exponential backoff attempt += 1