From 42d3984685b96f958c76a2dff9c31693c85cb9de Mon Sep 17 00:00:00 2001 From: kyrylomiro Date: Wed, 6 Mar 2024 09:42:54 +0100 Subject: [PATCH] Improve logging and print url for debug --- pkg/actionsmetrics/event_reader.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/actionsmetrics/event_reader.go b/pkg/actionsmetrics/event_reader.go index 1136bdb28a9..daf6834928f 100644 --- a/pkg/actionsmetrics/event_reader.go +++ b/pkg/actionsmetrics/event_reader.go @@ -109,7 +109,7 @@ func (reader *EventReader) ProcessWorkflowJobEvent(ctx context.Context, event in log := reader.Log.WithValues(keysAndValues...) // switch on job status - switch action := e.GetAction(); action { + switch action := *e.WorkflowJob.Status; strings.ToLower(action) { case "queued": githubWorkflowJobsQueuedTotal.With(labels).Inc() @@ -125,7 +125,7 @@ func (reader *EventReader) ProcessWorkflowJobEvent(ctx context.Context, event in log.Error(err, "reading workflow job log") return } else { - log.Info("reading workflow_job logs") + log.Info("reading workflow_job logs for in progress job", "event", &e, "parseResult", &parseResult) } githubWorkflowJobQueueDurationSeconds.With(labels).Observe(parseResult.QueueTime.Seconds()) @@ -160,7 +160,7 @@ func (reader *EventReader) ProcessWorkflowJobEvent(ctx context.Context, event in s := parseResult.RunTime.Seconds() runTimeSeconds = &s - log.Info("reading workflow_job logs", "exit_code", exitCode, "run_time_seconds", &runTimeSeconds, "parseResult", &parseResult) + log.Info("reading workflow_job logs for completed job", "exit_code", exitCode, "run_time_seconds", &runTimeSeconds, "parseResult", &parseResult) } if *e.WorkflowJob.Conclusion == "failure" { @@ -232,6 +232,9 @@ func (reader *EventReader) fetchAndParseWorkflowJobLogs(ctx context.Context, e * if err != nil { return nil, err } + if *e.WorkflowJob.Status == "in_progress" { + fmt.Println("URL: ", url.String()) + } jobLogs, err := http.DefaultClient.Get(url.String()) if err != nil { return nil, err