Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve logging and print url for debug #17

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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