From 383dc6e2fa714d89f41c9b204ff526216611e9ab Mon Sep 17 00:00:00 2001 From: Spencer Henry Date: Wed, 12 Oct 2022 09:17:21 -0600 Subject: [PATCH] address mr comments Signed-off-by: Spencer Henry --- contrib/docs/tutorials/prometheus-metrics.md | 6 ++--- .../tasks/NunjucksWorkflowRunner.ts | 25 +++++++------------ 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/contrib/docs/tutorials/prometheus-metrics.md b/contrib/docs/tutorials/prometheus-metrics.md index a46a2286cd..56989e709c 100644 --- a/contrib/docs/tutorials/prometheus-metrics.md +++ b/contrib/docs/tutorials/prometheus-metrics.md @@ -106,9 +106,7 @@ There are some custom metrics that have been added to Backstage will be output f - `catalog_processing_duration_seconds`: Time spent executing the full processing flow - `catalog_processors_duration_seconds`: Time spent executing catalog processors - `catalog_processing_queue_delay_seconds`: The amount of delay between being scheduled for processing, and the start of actually being processed -- `scaffolder_task_success_count`: Tracks successful task runs. -- `scaffolder_task_error_count`: a count that track how many task runs error out +- `scaffolder_task_count`: Tracks successful task runs. - `scaffolder_task_duration`: a histogram which tracks the duration of a task run -- `scaffolder_step_success_count`: a count that tracks each step run -- `scaffolder_step_error_count`: a count that tracks how many steps error out +- `scaffolder_step_count`: a count that tracks each step run - `scaffolder_step_duration`: a histogram which tracks the duration of each step run diff --git a/plugins/scaffolder-backend/src/scaffolder/tasks/NunjucksWorkflowRunner.ts b/plugins/scaffolder-backend/src/scaffolder/tasks/NunjucksWorkflowRunner.ts index f651be4830..fa0e9d8402 100644 --- a/plugins/scaffolder-backend/src/scaffolder/tasks/NunjucksWorkflowRunner.ts +++ b/plugins/scaffolder-backend/src/scaffolder/tasks/NunjucksWorkflowRunner.ts @@ -230,7 +230,6 @@ export class NunjucksWorkflowRunner implements WorkflowRunner { const { taskLogger, streamLogger } = createStepLogger({ task, step }); if (task.isDryRun) { - await taskTrack.skipDryRun(step, action); const redactedSecrets = Object.fromEntries( Object.entries(task.secrets ?? {}).map(secret => [ secret[0], @@ -258,13 +257,7 @@ export class NunjucksWorkflowRunner implements WorkflowRunner { )}`, ); if (!action.supportsDryRun) { - task.emitLog( - `Skipping because ${action.id} does not support dry-run`, - { - stepId: step.id, - status: 'skipped', - }, - ); + await taskTrack.skipDryRun(step, action); const outputSchema = action.schema?.output; if (outputSchema) { context.steps[step.id] = { @@ -336,13 +329,13 @@ export class NunjucksWorkflowRunner implements WorkflowRunner { await stepTrack.markSuccessful(); } catch (err) { await taskTrack.markFailed(step, err); - stepTrack.markFailed(); + await stepTrack.markFailed(); throw err; } } const output = this.render(task.spec.output, context, renderTemplate); - taskTrack.markSuccessful(); + await taskTrack.markSuccessful(); return { output }; } finally { @@ -355,8 +348,8 @@ export class NunjucksWorkflowRunner implements WorkflowRunner { function scaffoldingTracker() { const taskCount = createCounterMetric({ - name: 'scaffolder_task_success_count', - help: 'Count of succesful task runs', + name: 'scaffolder_task_count', + help: 'Count of task runs', labelNames: ['template', 'user', 'result'], }); const taskDuration = createHistogramMetric({ @@ -365,8 +358,8 @@ function scaffoldingTracker() { labelNames: ['template', 'result'], }); const stepCount = createCounterMetric({ - name: 'scaffolder_step_success_count', - help: 'Count of successful step runs', + name: 'scaffolder_step_count', + help: 'Count of step runs', labelNames: ['template', 'step', 'result'], }); const stepDuration = createHistogramMetric({ @@ -394,7 +387,7 @@ function scaffoldingTracker() { }); } - function markSuccessful() { + async function markSuccessful() { taskCount.inc({ template, user, @@ -448,7 +441,7 @@ function scaffoldingTracker() { stepTimer({ result: 'ok' }); } - function markFailed() { + async function markFailed() { stepCount.inc({ template, step: step.name,