Skip to content

Commit 428c5c3

Browse files
authored
Log when receiving GOAWAY frames (#1476)
1 parent 20bba23 commit 428c5c3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Sources/GRPC/GRPCIdleHandler.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,11 @@ internal final class GRPCIdleHandler: ChannelInboundHandler {
287287
let frame = self.unwrapInboundIn(data)
288288

289289
switch frame.payload {
290-
case .goAway:
290+
case let .goAway(lastStreamID, errorCode, _):
291+
self.stateMachine.logger.debug("received GOAWAY frame", metadata: [
292+
MetadataKey.h2GoAwayLastStreamID: "\(Int(lastStreamID))",
293+
MetadataKey.h2GoAwayError: "\(errorCode.networkCode)",
294+
])
291295
self.perform(operations: self.stateMachine.receiveGoAway())
292296
case let .settings(.settings(settings)):
293297
self.perform(operations: self.stateMachine.receiveSettings(settings))

Sources/GRPC/Logger.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ enum MetadataKey {
2929
static let h2Payload = "h2_payload"
3030
static let h2Headers = "h2_headers"
3131
static let h2DataBytes = "h2_data_bytes"
32+
static let h2GoAwayError = "h2_goaway_error"
33+
static let h2GoAwayLastStreamID = "h2_goaway_last_stream_id"
3234

3335
static let error = "error"
3436
}

0 commit comments

Comments
 (0)