From c34e6193dfeefdeae9f673b18f94292dfb60b685 Mon Sep 17 00:00:00 2001 From: Mattie Conover Date: Tue, 2 Aug 2022 13:26:14 -0400 Subject: [PATCH] Kathy Fixes (#864) * correction * Fix timeout handling * kathy metric init * cleanup --- .../helm/helloworld-kathy/templates/stateful-set.yaml | 3 +++ typescript/infra/scripts/helloworld/kathy.ts | 9 +++++++++ typescript/utils/src/utils.ts | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/typescript/infra/helm/helloworld-kathy/templates/stateful-set.yaml b/typescript/infra/helm/helloworld-kathy/templates/stateful-set.yaml index 42744af4d..1533530e7 100644 --- a/typescript/infra/helm/helloworld-kathy/templates/stateful-set.yaml +++ b/typescript/infra/helm/helloworld-kathy/templates/stateful-set.yaml @@ -15,6 +15,9 @@ spec: template: metadata: labels: *metadata_labels + annotations: + prometheus.io/port: "9090" + prometheus.io/scrape: "true" spec: containers: - name: helloworld-kathy diff --git a/typescript/infra/scripts/helloworld/kathy.ts b/typescript/infra/scripts/helloworld/kathy.ts index 3de18fd70..af24f86ac 100644 --- a/typescript/infra/scripts/helloworld/kathy.ts +++ b/typescript/infra/scripts/helloworld/kathy.ts @@ -116,6 +116,15 @@ async function main() { }); }, sendFrequency); + // init the metrics because it can take a while for kathy to get through everything and we do not + // want the metrics to be reported as null in the meantime. + for (const { origin, destination: remote } of pairings) { + messagesSendCount.labels({ origin, remote, status: 'success' }).inc(0); + messagesSendCount.labels({ origin, remote, status: 'failure' }).inc(0); + messageSendSeconds.labels({ origin, remote }).inc(0); + messageReceiptSeconds.labels({ origin, remote }).inc(0); + } + for ( // in case we are restarting kathy, keep it from always running the exact same messages first let currentPairingIndex = Date.now() % pairings.length; diff --git a/typescript/utils/src/utils.ts b/typescript/utils/src/utils.ts index 90a5bd39d..e137c7363 100644 --- a/typescript/utils/src/utils.ts +++ b/typescript/utils/src/utils.ts @@ -181,7 +181,7 @@ export function timeout( if (!timeoutMs || timeoutMs <= 0) return promise; return new Promise((resolve, reject) => { setTimeout(() => { - throw new Error(message); + reject(new Error(message)); }, timeoutMs); promise.then(resolve).catch(reject); });