Skip to content

Commit faa79fe

Browse files
authored
Merge pull request #2040 from nimf/http2-settings-tracing
Add HTTP/2 settings frame tracing
2 parents 703971f + ae2a2ac commit faa79fe

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

packages/grpc-js/src/logging.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ export function trace(
108108
tracer: string,
109109
text: string
110110
): void {
111-
if (
112-
!disabledTracers.has(tracer) &&
113-
(allEnabled || enabledTracers.has(tracer))
114-
) {
111+
if (isTracerEnabled(tracer)) {
115112
log(severity, new Date().toISOString() + ' | ' + tracer + ' | ' + text);
116113
}
117114
}
115+
116+
export function isTracerEnabled(tracer: string): boolean {
117+
return !disabledTracers.has(tracer) &&
118+
(allEnabled || enabledTracers.has(tracer));
119+
}

packages/grpc-js/src/subchannel.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,24 @@ export class Subchannel {
555555
(error as Error).message
556556
);
557557
});
558+
if (logging.isTracerEnabled(TRACER_NAME)) {
559+
session.on('remoteSettings', (settings: http2.Settings) => {
560+
this.trace(
561+
'new settings received' +
562+
(this.session !== session ? ' on the old connection' : '') +
563+
': ' +
564+
JSON.stringify(settings)
565+
);
566+
});
567+
session.on('localSettings', (settings: http2.Settings) => {
568+
this.trace(
569+
'local settings acknowledged by remote' +
570+
(this.session !== session ? ' on the old connection' : '') +
571+
': ' +
572+
JSON.stringify(settings)
573+
);
574+
});
575+
}
558576
}
559577

560578
private startConnectingInternal() {

0 commit comments

Comments
 (0)