Skip to content

Commit

Permalink
Merge pull request #2040 from nimf/http2-settings-tracing
Browse files Browse the repository at this point in the history
Add HTTP/2 settings frame tracing
  • Loading branch information
murgatroid99 committed Feb 9, 2022
2 parents 703971f + ae2a2ac commit faa79fe
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/grpc-js/src/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ export function trace(
tracer: string,
text: string
): void {
if (
!disabledTracers.has(tracer) &&
(allEnabled || enabledTracers.has(tracer))
) {
if (isTracerEnabled(tracer)) {
log(severity, new Date().toISOString() + ' | ' + tracer + ' | ' + text);
}
}

export function isTracerEnabled(tracer: string): boolean {
return !disabledTracers.has(tracer) &&
(allEnabled || enabledTracers.has(tracer));
}
18 changes: 18 additions & 0 deletions packages/grpc-js/src/subchannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,24 @@ export class Subchannel {
(error as Error).message
);
});
if (logging.isTracerEnabled(TRACER_NAME)) {
session.on('remoteSettings', (settings: http2.Settings) => {
this.trace(
'new settings received' +
(this.session !== session ? ' on the old connection' : '') +
': ' +
JSON.stringify(settings)
);
});
session.on('localSettings', (settings: http2.Settings) => {
this.trace(
'local settings acknowledged by remote' +
(this.session !== session ? ' on the old connection' : '') +
': ' +
JSON.stringify(settings)
);
});
}
}

private startConnectingInternal() {
Expand Down

0 comments on commit faa79fe

Please sign in to comment.