diff --git a/pkg/actionsmetrics/event_reader.go b/pkg/actionsmetrics/event_reader.go index 3800052975..fcbff5e9e4 100644 --- a/pkg/actionsmetrics/event_reader.go +++ b/pkg/actionsmetrics/event_reader.go @@ -215,14 +215,21 @@ func (reader *EventReader) ProcessWorkflowJobEvent(ctx context.Context, event in if *e.WorkflowJob.Conclusion == "success" && repoName == "client" { for _, step := range e.WorkflowJob.Steps { + conclusion := step.Conclusion + startedAt := step.StartedAt + completedAt := step.CompletedAt + if conclusion == nil || startedAt == nil || completedAt == nil { + continue + } + stepLabels := extraLabel("step_name", *step.Name, labels) - stepLabels["step_conclusion"] = *step.Conclusion + stepLabels["step_conclusion"] = *conclusion - stepDuration := step.CompletedAt.Sub(step.StartedAt.Time) + stepDuration := completedAt.Sub(startedAt.Time) githubWorkflowJobStepDurationSeconds.With(stepLabels).Observe(stepDuration.Seconds()) - log.Info("processed step in the repository", "repo", repoName, "step_name", *step.Name, "step_conclusion", *step.Conclusion) + log.Info("processed step in the repository", "repo", repoName, "step_name", *step.Name, "step_conclusion", *conclusion) } } }