-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(utils): internal metrics (#1762)
* add module for internal metrics * eslint * add module * bump versions * Trigger Build
- Loading branch information
Showing
7 changed files
with
56 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
function canSend() { | ||
return process.env["PUSHGATEWAY_URL"] && process.env["CI_JOB_NAME"]; | ||
} | ||
|
||
function getFromCI() { | ||
return [ | ||
process.env["CI_JOB_ID"], | ||
process.env["CI_JOB_NAME"], | ||
process.env["CI_PROJECT_NAME"] || "", | ||
process.env["PUSHGATEWAY_URL"], | ||
]; | ||
} | ||
|
||
export async function registerSpawnElapsedTimeSecs(elapsed: number) { | ||
if (canSend()) { | ||
const [jobId, jobName, projectName, pushGatewayUrl] = getFromCI(); | ||
const metricName = "zombie_network_ready_secs"; | ||
const help = `# HELP ${metricName} Elapsed time to spawn the network in seconds`; | ||
const type = `# TYPE ${metricName} gauge`; | ||
const metricString = `${metricName}{job_id="${jobId}", job_name="${jobName}", project_name="${projectName}"} ${elapsed}`; | ||
const body = [help, type, metricString, "\n"].join("\n"); | ||
await fetch(pushGatewayUrl!, { | ||
method: "POST", | ||
body, | ||
}); | ||
} | ||
} | ||
|
||
export async function registerTotalElapsedTimeSecs(elapsed: number) { | ||
if (canSend()) { | ||
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 body = [help, type, metricString, "\n"].join("\n"); | ||
await fetch(pushGatewayUrl!, { | ||
method: "POST", | ||
body, | ||
}); | ||
} | ||
} |