Merge pull request #2085 from murgatroid99/grpc-js_keepalive_traces

grpc-js: Add more details to keepalive ping tracing
This commit is contained in:
Michael Lumish 2022-04-11 14:36:31 -07:00 committed by GitHub
commit 0feeab3d09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 6 deletions

View File

@ -321,6 +321,10 @@ export class Subchannel {
logging.trace(LogVerbosity.DEBUG, 'subchannel_internals', '(' + this.channelzRef.id + ') ' + this.subchannelAddressString + ' ' + text); logging.trace(LogVerbosity.DEBUG, 'subchannel_internals', '(' + this.channelzRef.id + ') ' + this.subchannelAddressString + ' ' + text);
} }
private keepaliveTrace(text: string): void {
logging.trace(LogVerbosity.DEBUG, 'keepalive', '(' + this.channelzRef.id + ') ' + this.subchannelAddressString + ' ' + text);
}
private handleBackoffTimer() { private handleBackoffTimer() {
if (this.continueConnecting) { if (this.continueConnecting) {
this.transitionToState( this.transitionToState(
@ -351,18 +355,15 @@ export class Subchannel {
if (this.channelzEnabled) { if (this.channelzEnabled) {
this.keepalivesSent += 1; this.keepalivesSent += 1;
} }
logging.trace( this.keepaliveTrace('Sending ping with timeout ' + this.keepaliveTimeoutMs + 'ms');
LogVerbosity.DEBUG,
'keepalive',
'(' + this.channelzRef.id + ') ' + this.subchannelAddressString + ' ' +
'Sending ping'
);
this.keepaliveTimeoutId = setTimeout(() => { this.keepaliveTimeoutId = setTimeout(() => {
this.keepaliveTrace('Ping timeout passed without response');
this.transitionToState([ConnectivityState.READY], ConnectivityState.IDLE); this.transitionToState([ConnectivityState.READY], ConnectivityState.IDLE);
}, this.keepaliveTimeoutMs); }, this.keepaliveTimeoutMs);
this.keepaliveTimeoutId.unref?.(); this.keepaliveTimeoutId.unref?.();
this.session!.ping( this.session!.ping(
(err: Error | null, duration: number, payload: Buffer) => { (err: Error | null, duration: number, payload: Buffer) => {
this.keepaliveTrace('Received ping response');
clearTimeout(this.keepaliveTimeoutId); clearTimeout(this.keepaliveTimeoutId);
} }
); );