Use unique keys to identify healthchecks

Summary: Added unique keys for each healthcheck and used them to save already seen failures. Later I will also use them for gathering doctor analytics.

Reviewed By: jknoxville

Differential Revision: D19301583

fbshipit-source-id: 0c0aa977ea73ce555e0d9fb8e8ead844624fb9cd
This commit is contained in:
Anton Nikolaev
2020-01-08 08:10:36 -08:00
committed by Facebook Github Bot
parent cdb0990ac8
commit 751c778069
10 changed files with 560 additions and 249 deletions

View File

@@ -15,8 +15,8 @@ let runningHealthcheck: Promise<void>;
export type HealthcheckEventsHandler = {
updateHealthcheckResult: (
categoryIdx: number,
itemIdx: number,
categoryKey: string,
itemKey: string,
result: HealthcheckResult,
) => void;
startHealthchecks: (healthchecks: Healthchecks) => void;
@@ -41,17 +41,11 @@ async function launchHealthchecks(options: HealthcheckOptions): Promise<void> {
}
options.startHealthchecks(healthchecks);
const environmentInfo = await getEnvInfo();
const categories = Object.values(healthchecks);
for (const [categoryIdx, category] of categories.entries()) {
for (const [categoryKey, category] of Object.entries(healthchecks)) {
if (category.isSkipped) {
continue;
}
for (
let healthcheckIdx = 0;
healthcheckIdx < category.healthchecks.length;
healthcheckIdx++
) {
const h = category.healthchecks[healthcheckIdx];
for (const h of category.healthchecks) {
const checkResult = await h.run(environmentInfo);
const result: HealthcheckResult =
checkResult.hasProblem && h.isRequired
@@ -65,7 +59,7 @@ async function launchHealthchecks(options: HealthcheckOptions): Promise<void> {
helpUrl: checkResult.helpUrl,
}
: {status: 'SUCCESS'};
options.updateHealthcheckResult(categoryIdx, healthcheckIdx, result);
options.updateHealthcheckResult(categoryKey, h.key, result);
}
}
options.finishHealthchecks();