Skip to content

Commit

Permalink
Improve logging and print url for debug (#17)
Browse files Browse the repository at this point in the history
Co-authored-by: kyrylomiro <[email protected]>
  • Loading branch information
kyrylomiro and kyrylomiro authored Mar 6, 2024
1 parent 6c0f8c7 commit 50f7890
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pkg/actionsmetrics/event_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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", "workflow_job_status", *e.WorkflowJob.Status, "parseResult", &parseResult)
}

githubWorkflowJobQueueDurationSeconds.With(labels).Observe(parseResult.QueueTime.Seconds())
Expand Down Expand Up @@ -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" {
Expand Down Expand Up @@ -232,6 +232,15 @@ func (reader *EventReader) fetchAndParseWorkflowJobLogs(ctx context.Context, e *
if err != nil {
return nil, err
}
if *e.WorkflowJob.Status == "in_progress" {
if strings.Contains(url.String(), "actions-results") {
return &ParseResult{
ExitCode: "",
QueueTime: time.Duration(0),
RunTime: time.Duration(0),
}, nil
}
}
jobLogs, err := http.DefaultClient.Get(url.String())
if err != nil {
return nil, err
Expand Down

0 comments on commit 50f7890

Please sign in to comment.