Skip to content

Commit da66707

Browse files
committed
HTTP/2 flow control tracing
subchannel_flowctrl tracer, if enabled, logs local and remote window sizes of subchannel's HTTP2 session to debug log on the start of every call.
1 parent faa79fe commit da66707

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

doc/environment_variables.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ can be set.
3737
- `server_call` - Traces server handling of individual requests
3838
- `subchannel` - Traces subchannel connectivity state and errors
3939
- `subchannel_refcount` - Traces subchannel refcount changes
40+
- `subchannel_flowctrl` - Traces HTTP/2 flow control
4041

4142
The following tracers are added by the `@grpc/grpc-js-xds` library:
4243
- `cds_balancer` - Traces the CDS load balancing policy

packages/grpc-js/src/subchannel.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { SubchannelRef, ChannelzTrace, ChannelzChildrenTracker, SubchannelInfo,
4141
const clientVersion = require('../../package.json').version;
4242

4343
const TRACER_NAME = 'subchannel';
44+
const FLOW_CONTROL_TRACER_NAME = 'subchannel_flowctrl';
4445

4546
const MIN_CONNECT_TIMEOUT_MS = 20000;
4647
const INITIAL_BACKOFF_MS = 1000;
@@ -324,6 +325,10 @@ export class Subchannel {
324325
logging.trace(LogVerbosity.DEBUG, 'subchannel_refcount', '(' + this.channelzRef.id + ') ' + this.subchannelAddressString + ' ' + text);
325326
}
326327

328+
private flowControlTrace(text: string): void {
329+
logging.trace(LogVerbosity.DEBUG, FLOW_CONTROL_TRACER_NAME, '(' + this.channelzRef.id + ') ' + this.subchannelAddressString + ' ' + text);
330+
}
331+
327332
private handleBackoffTimer() {
328333
if (this.continueConnecting) {
329334
this.transitionToState(
@@ -848,6 +853,12 @@ export class Subchannel {
848853
' with headers\n' +
849854
headersString
850855
);
856+
this.flowControlTrace(
857+
'local window size: ' +
858+
this.session!.state.localWindowSize +
859+
' remote window size: ' +
860+
this.session!.state.remoteWindowSize
861+
);
851862
const streamSession = this.session;
852863
let statsTracker: SubchannelCallStatsTracker;
853864
if (this.channelzEnabled) {

0 commit comments

Comments
 (0)