diff --git a/packages/grpc-js/src/load-balancer-eds.ts b/packages/grpc-js/src/load-balancer-eds.ts index 15fd7287..bc812492 100644 --- a/packages/grpc-js/src/load-balancer-eds.ts +++ b/packages/grpc-js/src/load-balancer-eds.ts @@ -87,9 +87,9 @@ export class EdsLoadBalancer implements LoadBalancer { constructor(private readonly channelControlHelper: ChannelControlHelper) { this.childBalancer = new ChildLoadBalancerHandler({ - createSubchannel: (subchannelAddres, subchannelArgs) => + createSubchannel: (subchannelAddress, subchannelArgs) => this.channelControlHelper.createSubchannel( - subchannelAddres, + subchannelAddress, subchannelArgs ), requestReresolution: () => @@ -385,10 +385,13 @@ export class EdsLoadBalancer implements LoadBalancer { this.isWatcherActive = true; } - this.clusterDropStats = this.xdsClient.addClusterDropStats( - lbConfig.eds.cluster, - lbConfig.eds.edsServiceName ?? '' - ); + if (lbConfig.eds.lrsLoadReportingServerName) { + this.clusterDropStats = this.xdsClient.addClusterDropStats( + lbConfig.eds.lrsLoadReportingServerName, + lbConfig.eds.cluster, + lbConfig.eds.edsServiceName ?? '' + ); + } /* If updateAddressList is called after receiving an update and the update * is still valid, we want to update the child config with the information diff --git a/packages/grpc-js/src/xds-client.ts b/packages/grpc-js/src/xds-client.ts index 25bc748b..165e545b 100644 --- a/packages/grpc-js/src/xds-client.ts +++ b/packages/grpc-js/src/xds-client.ts @@ -791,10 +791,24 @@ export class XdsClient { } } + /** + * + * @param lrsServer The target name of the server to send stats to. An empty + * string indicates that the default LRS client should be used. Currently + * only the empty string is supported here. + * @param clusterName + * @param edsServiceName + */ addClusterDropStats( + lrsServer: string, clusterName: string, edsServiceName: string ): XdsClusterDropStats { + if (lrsServer !== '') { + return { + addCallDropped: category => {} + }; + } const clusterStats = this.clusterStatsMap.getOrCreate( clusterName, edsServiceName @@ -810,6 +824,8 @@ export class XdsClient { shutdown(): void { this.adsCall?.cancel(); this.adsClient?.close(); + this.lrsCall?.cancel(); + this.lrsClient?.close(); this.hasShutdown = true; } }