Add more trace logging

This commit is contained in:
Michael Lumish 2021-03-29 12:49:20 -07:00
parent 8c7145ba5f
commit 6be480c58f
3 changed files with 9 additions and 2 deletions

View File

@ -191,7 +191,7 @@ export class EdsLoadBalancer implements LoadBalancer {
});
this.watcher = {
onValidUpdate: (update) => {
trace('Received EDS update for ' + this.edsServiceName + ': ' + JSON.stringify(update));
trace('Received EDS update for ' + this.edsServiceName + ': ' + JSON.stringify(update, undefined, 2));
this.latestEdsUpdate = update;
this.updateChild();
},

View File

@ -32,7 +32,7 @@ import getFirstUsableConfig = experimental.getFirstUsableConfig;
import ChannelControlHelper = experimental.ChannelControlHelper;
import registerLoadBalancerType = experimental.registerLoadBalancerType;
const TRACER_NAME = 'weighted_target';
const TRACER_NAME = 'xds_cluster_manager';
function trace(text: string): void {
experimental.trace(logVerbosity.DEBUG, TRACER_NAME, text);
@ -247,6 +247,7 @@ class XdsClusterManager implements LoadBalancer {
trace('Discarding address list update with unrecognized config ' + JSON.stringify(lbConfig.toJsonObject(), undefined, 2));
return;
}
trace('Received update with config: ' + JSON.stringify(lbConfig.toJsonObject(), undefined, 2));
const configChildren = lbConfig.getChildren();
// Delete children that are not in the new config
const namesToRemove: string[] = [];

View File

@ -40,6 +40,7 @@ import LoadBalancingConfig = experimental.LoadBalancingConfig;
import { XdsClusterManagerLoadBalancingConfig } from './load-balancer-xds-cluster-manager';
import { ExactValueMatcher, Fraction, FullMatcher, HeaderMatcher, Matcher, PathExactValueMatcher, PathPrefixValueMatcher, PathSafeRegexValueMatcher, PrefixValueMatcher, PresentValueMatcher, RangeValueMatcher, RejectValueMatcher, SafeRegexValueMatcher, SuffixValueMatcher, ValueMatcher } from './matcher';
import { RouteAction, SingleClusterRouteAction, WeightedCluster, WeightedClusterRouteAction } from './route-action';
import { LogVerbosity } from '@grpc/grpc-js/build/src/constants';
const TRACER_NAME = 'xds_resolver';
@ -337,9 +338,14 @@ class XdsResolver implements Resolver {
this.clusterRefcounts.set(name, {inLastConfig: true, refCount: 0});
}
}
let configSelectorLogCounter = 0;
const configSelector: ConfigSelector = (methodName, metadata) => {
for (const {matcher, action} of matchList) {
if (matcher.apply(methodName, metadata)) {
// 37 is coprime with most relevant numbers
if (configSelectorLogCounter % 37 === 0) {
trace('Call with method ' + methodName + ' and metadata ' + JSON.stringify(metadata.getMap(), undefined, 2) + ' matched ' + matcher.toString());
}
const clusterName = action.getCluster();
this.refCluster(clusterName);
const onCommitted = () => {