Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send status as part of the metrics to prometheus #1941

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions javascript/packages/orchestrator/src/test-runner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,12 @@ export async function run(

suite.afterAll("teardown", async function () {
this.timeout(180 * 1000);
// report metric
const testEnd = performance.now();
const elapsedSecs = Math.round((testEnd - testStart) / 1000);
debug(`\t 🕰 [Test] elapsed time: ${elapsedSecs} secs`);
let success: boolean = false;
if (network && !network.wasRunning) {
// report metric
const testEnd = performance.now();
const elapsedSecs = Math.round((testEnd - testStart) / 1000);
debug(`\t 🕰 [Test] elapsed time: ${elapsedSecs} secs`);
if (inCI) await registerTotalElapsedTimeSecs(elapsedSecs);

let logsPath;
try {
logsPath = await network.dumpLogs(false);
Expand All @@ -157,6 +156,8 @@ export async function run(
console.log(
`\n\n\t${decorators.red("❌ One or more of your test failed...")}`,
);
} else {
success = true;
}

// All test passed, just remove the network
Expand Down Expand Up @@ -227,6 +228,8 @@ export async function run(
}
}
}
// submit metric
if (inCI) await registerTotalElapsedTimeSecs(elapsedSecs, success);
return;
});

Expand Down
8 changes: 6 additions & 2 deletions javascript/packages/utils/src/zombieMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ export async function registerSpawnElapsedTimeSecs(elapsed: number) {
}
}

export async function registerTotalElapsedTimeSecs(elapsed: number) {
export async function registerTotalElapsedTimeSecs(
elapsed: number,
success: boolean,
) {
if (canSend()) {
const status = success ? "pass" : "fail";
const [jobId, jobName, projectName, pushGatewayUrl] = getFromCI();
const metricName = "zombie_test_complete_secs";
const help = `# HELP ${metricName} Elapsed time to complete the test job in seconds (including spawning, but not teardown)`;
const type = `# TYPE ${metricName} gauge`;
const metricString = `${metricName}{job_id="${jobId}", job_name="${jobName}", project_name="${projectName}"} ${elapsed}`;
const metricString = `${metricName}{job_id="${jobId}", job_name="${jobName}", project_name="${projectName}"}, status="${status}" ${elapsed}`;
const body = [help, type, metricString, "\n"].join("\n");
await fetch(pushGatewayUrl!, {
method: "POST",
Expand Down
Loading