Skip to content

Commit 6476063

Browse files
authored
feat: add additional connection tracing for CRT engine (#796)
1 parent 66e95fb commit 6476063

File tree

5 files changed

+11
-3
lines changed

5 files changed

+11
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"id": "f20a2e6c-7e63-4fa5-9be4-311e7b56869f",
3+
"type": "feature",
4+
"description": "Add additional tracing events for connections in CRT engines"
5+
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ kotlinLoggingVersion=3.0.0
4444
slf4jVersion=2.0.6
4545

4646
# crt
47-
crtKotlinVersion=0.6.7
47+
crtKotlinVersion=0.6.8-SNAPSHOT

runtime/protocol/http-client-engines/http-client-engine-crt/common/src/aws/smithy/kotlin/runtime/http/engine/crt/CrtHttpEngine.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,11 @@ public class CrtHttpEngine(public val config: CrtHttpEngineConfig) : HttpClientE
9595
val conn = withTimeoutOrNull(config.connectionAcquireTimeout) {
9696
manager.acquireConnection()
9797
} ?: throw ClientException("timed out waiting for an HTTP connection to be acquired from the pool")
98+
logger.trace { "Acquired connection ${conn.id}" }
9899

99100
val respHandler = SdkStreamResponseHandler(conn, callContext)
100101
callContext.job.invokeOnCompletion {
101-
logger.warn { "completing handler; cause=$it" }
102+
logger.trace { "completing handler; cause=$it" }
102103
// ensures the stream is driven to completion regardless of what the downstream consumer does
103104
respHandler.complete()
104105
}

runtime/protocol/http-client-engines/http-client-engine-crt/common/src/aws/smithy/kotlin/runtime/http/engine/crt/SdkStreamResponseHandler.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,12 @@ internal class SdkStreamResponseHandler(
200200
val forceClose = !streamCompleted
201201

202202
if (forceClose) {
203-
logger.debug { "stream did not complete before job, forcing connection shutdown! handler=$this; conn=$conn; stream=$crtStream" }
203+
logger.debug { "stream did not complete before job, forcing connection shutdown! handler=$this; conn=$conn; conn.id=${conn.id}; stream=$crtStream" }
204204
conn.shutdown()
205205
cancelled = true
206206
}
207207

208+
logger.trace { "Closing connection ${conn.id}" }
208209
conn.close()
209210
}
210211
}

runtime/protocol/http-client-engines/http-client-engine-crt/common/test/aws/smithy/kotlin/runtime/http/engine/crt/SdkStreamResponseHandlerTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class SdkStreamResponseHandlerTest {
3232
}
3333

3434
private class MockHttpClientConnection : HttpClientConnection {
35+
override val id: String = "<mock connection>"
3536
var isClosed: Boolean = false
3637
override fun close() { isClosed = true }
3738
override fun makeRequest(httpReq: HttpRequest, handler: HttpStreamResponseHandler): HttpStream { throw UnsupportedOperationException("not implemented for test") }

0 commit comments

Comments
 (0)