mirror of https://github.com/grpc/grpc-node.git
Add error logging to xDS interop client
This commit is contained in:
parent
1a47f78f4f
commit
82037fcdaf
|
@ -39,7 +39,7 @@ const loadedProto = grpc.loadPackageDefinition(packageDefinition) as unknown as
|
||||||
|
|
||||||
interface CallEndNotifier {
|
interface CallEndNotifier {
|
||||||
onCallSucceeded(peerName: string): void;
|
onCallSucceeded(peerName: string): void;
|
||||||
onCallFailed(): void;
|
onCallFailed(message: string): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
class CallSubscriber {
|
class CallSubscriber {
|
||||||
|
@ -47,6 +47,7 @@ class CallSubscriber {
|
||||||
private callsSucceededByPeer: {[key: string]: number} = {};
|
private callsSucceededByPeer: {[key: string]: number} = {};
|
||||||
private callsSucceeded = 0;
|
private callsSucceeded = 0;
|
||||||
private callsFinished = 0;
|
private callsFinished = 0;
|
||||||
|
private failureMessageCount: Map<string, number> = new Map<string, number>();
|
||||||
|
|
||||||
constructor(private callGoal: number, private onFinished: () => void) {}
|
constructor(private callGoal: number, private onFinished: () => void) {}
|
||||||
|
|
||||||
|
@ -56,6 +57,10 @@ class CallSubscriber {
|
||||||
|
|
||||||
private maybeOnFinished() {
|
private maybeOnFinished() {
|
||||||
if (this.callsFinished == this.callGoal) {
|
if (this.callsFinished == this.callGoal) {
|
||||||
|
console.log(`Out of a total of ${this.callsFinished} calls, ${this.callsSucceeded} succeeded`);
|
||||||
|
for (const [message, count] of this.failureMessageCount) {
|
||||||
|
console.log(`${count} failed with the message ${message}`);
|
||||||
|
}
|
||||||
this.onFinished();
|
this.onFinished();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,8 +75,9 @@ class CallSubscriber {
|
||||||
this.callsFinished += 1;
|
this.callsFinished += 1;
|
||||||
this.maybeOnFinished();
|
this.maybeOnFinished();
|
||||||
}
|
}
|
||||||
addCallFailed(): void {
|
addCallFailed(message: string): void {
|
||||||
this.callsFinished += 1;
|
this.callsFinished += 1;
|
||||||
|
this.failureMessageCount.set(message, (this.failureMessageCount.get(message) ?? 0) + 1);
|
||||||
this.maybeOnFinished();
|
this.maybeOnFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,9 +131,9 @@ class CallStatsTracker {
|
||||||
subscriber.addCallSucceeded(peerName);
|
subscriber.addCallSucceeded(peerName);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onCallFailed: () => {
|
onCallFailed: (message: string) => {
|
||||||
for (const subscriber of callSubscribers) {
|
for (const subscriber of callSubscribers) {
|
||||||
subscriber.addCallFailed();
|
subscriber.addCallFailed(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,12 +156,12 @@ function sendConstantQps(client: TestServiceClient, qps: number, failOnFailedRpc
|
||||||
}
|
}
|
||||||
completed = true;
|
completed = true;
|
||||||
completedWithError = true;
|
completedWithError = true;
|
||||||
notifier.onCallFailed();
|
notifier.onCallFailed(error.message);
|
||||||
} else {
|
} else {
|
||||||
anyCallSucceeded = true;
|
anyCallSucceeded = true;
|
||||||
if (gotMetadata) {
|
if (gotMetadata) {
|
||||||
if (hostname === null) {
|
if (hostname === null) {
|
||||||
notifier.onCallFailed()
|
notifier.onCallFailed('Hostname omitted from call metadata');
|
||||||
} else {
|
} else {
|
||||||
notifier.onCallSucceeded(hostname);
|
notifier.onCallSucceeded(hostname);
|
||||||
}
|
}
|
||||||
|
@ -167,7 +173,7 @@ function sendConstantQps(client: TestServiceClient, qps: number, failOnFailedRpc
|
||||||
gotMetadata = true;
|
gotMetadata = true;
|
||||||
if (completed && !completedWithError) {
|
if (completed && !completedWithError) {
|
||||||
if (hostname === null) {
|
if (hostname === null) {
|
||||||
notifier.onCallFailed();
|
notifier.onCallFailed('Hostname omitted from call metadata');
|
||||||
} else {
|
} else {
|
||||||
notifier.onCallSucceeded(hostname);
|
notifier.onCallSucceeded(hostname);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue