condense metrics and use a result label

Signed-off-by: Spencer Henry <shenry@qualtrics.com>
This commit is contained in:
Spencer Henry
2022-10-10 09:34:34 -06:00
parent 2c45c9d703
commit 1d4a87eea4
2 changed files with 17 additions and 35 deletions
+5 -17
View File
@@ -4,19 +4,13 @@
Added a set of default Prometheus metrics around scaffolding. See below for a list of metrics and an explanation of their labels:
- `scaffolder_task_success_count`: Tracks successful task runs.
Labels:
- `template`: The entity ref of the scaffolded template
- `user`: The entity ref of the user that invoked the template run
- `scaffolder_task_error_count`: a count that track how many task runs error out
- `scaffolder_task_count`: Tracks successful task runs.
Labels:
- `template`: The entity ref of the scaffolded template
- `user`: The entity ref of the user that invoked the template run
- `result`: A string describing whether the task ran successfully, errored out, or was skipped
- `scaffolder_task_duration`: a histogram which tracks the duration of a task run
@@ -25,19 +19,13 @@ Added a set of default Prometheus metrics around scaffolding. See below for a li
- `template`: The entity ref of the scaffolded template
- `result`: A boolean describing whether the task ran successfully
- `scaffolder_step_success_count`: a count that tracks each step run
Labels:
- `template`: The entity ref of the scaffolded template
- `step`: The name of the step that was run
- `scaffolder_step_error_count`: a count that tracks how many steps error out
- `scaffolder_step_count`: a count that tracks each step run
Labels:
- `template`: The entity ref of the scaffolded template
- `step`: The name of the step that was run
- `result`: A string describing whether the task ran successfully, errored out, or was skipped
- `scaffolder_step_duration`: a histogram which tracks the duration of each step run
@@ -45,6 +33,6 @@ Added a set of default Prometheus metrics around scaffolding. See below for a li
- `template`: The entity ref of the scaffolded template
- `step`: The name of the step that was run
- `result`: A boolean describing whether the task ran successfully
- `result`: A string describing whether the task ran successfully, errored out, or was skipped
You can find a guide for running Prometheus metrics here: https://github.com/backstage/backstage/blob/master/contrib/docs/tutorials/prometheus-metrics.md
@@ -354,30 +354,20 @@ export class NunjucksWorkflowRunner implements WorkflowRunner {
}
function scaffoldingTracker() {
const taskSuccesses = createCounterMetric({
const taskCount = createCounterMetric({
name: 'scaffolder_task_success_count',
help: 'Count of succesful task runs',
labelNames: ['template', 'user'],
});
const taskErrors = createCounterMetric({
name: 'scaffolder_task_error_count',
help: 'Count of failed task runs',
labelNames: ['template', 'user'],
labelNames: ['template', 'user', 'result'],
});
const taskDuration = createHistogramMetric({
name: 'scaffolder_task_duration',
help: 'Duration of a task run',
labelNames: ['template', 'result'],
});
const stepSuccesses = createCounterMetric({
const stepCount = createCounterMetric({
name: 'scaffolder_step_success_count',
help: 'Count of successful step runs',
labelNames: ['template', 'step'],
});
const stepErrors = createCounterMetric({
name: 'scaffolder_step_error_count',
help: 'Count of failed step runs',
labelNames: ['template', 'step'],
labelNames: ['template', 'step', 'result'],
});
const stepDuration = createHistogramMetric({
name: 'scaffolder_step_duration',
@@ -405,9 +395,10 @@ function scaffoldingTracker() {
}
function markSuccessful() {
taskSuccesses.inc({
taskCount.inc({
template,
user,
result: 'ok'
});
taskTimer({ result: 'ok' });
}
@@ -417,9 +408,10 @@ function scaffoldingTracker() {
stepId: step.id,
status: 'failed',
});
taskErrors.inc({
taskCount.inc({
template,
user,
result: 'failed'
});
taskTimer({ result: 'failed' });
}
@@ -448,17 +440,19 @@ function scaffoldingTracker() {
stepId: step.id,
status: 'completed',
});
stepSuccesses.inc({
stepCount.inc({
template,
step: step.name,
result: 'ok'
});
stepTimer({ result: 'ok' });
}
function markFailed() {
stepErrors.inc({
stepCount.inc({
template,
step: step.name,
result: 'failed'
});
stepTimer({ result: 'failed' });
}