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

fix(sdk): hatchery step log delay numeric #6456

Merged
merged 1 commit into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions sdk/hatchery/hatchery.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,8 @@ func SendSpawnInfo(ctx context.Context, h Interface, jobID int64, spawnMsg sdk.S

func logStepInfo(ctx context.Context, step string, queued time.Time) {
if id := ctx.Value(LogFieldJobID); id != nil {
ctx = context.WithValue(ctx, LogFieldJobStep, step)
ctx = context.WithValue(ctx, LogFieldJobStepDelay, time.Since(queued).Milliseconds())
ctx = context.WithValue(ctx, LogFieldStep, step)
ctx = context.WithValue(ctx, LogFieldStepDelay, time.Since(queued).Nanoseconds())
richardlt marked this conversation as resolved.
Show resolved Hide resolved
log.Info(ctx, "step: %s job: %s", step, id)
}
}
8 changes: 8 additions & 0 deletions sdk/hatchery/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ func spawnWorkerForJob(ctx context.Context, h Interface, j workerStarterRequest)
ctx = context.WithValue(ctx, LogFieldWorkflow, arg.WorkflowName)
ctx = context.WithValue(ctx, LogFieldNodeRun, arg.NodeRunName)

var serviceCount int
for i := range arg.Requirements {
if arg.Requirements[i].Type == sdk.ServiceRequirement {
serviceCount++
}
}
ctx = context.WithValue(ctx, LogFieldServiceCount, serviceCount)

// Get a JWT to authentified the worker
jwt, err := NewWorkerToken(h.Service().Name, h.GetPrivateKey(), time.Now().Add(1*time.Hour), arg)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions sdk/hatchery/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ const (

var (
LogFieldJobID = log.Field("action_metadata_job_id")
LogFieldJobStep = log.Field("hatchery_job_step")
LogFieldJobStepDelay = log.Field("hatchery_job_step_delay")
LogFieldStep = log.Field("hatchery_step")
LogFieldStepDelay = log.Field("hatchery_step_delay_num")
LogFieldProjectID = log.Field("worker_project_id")
LogFieldProject = log.Field("worker_project")
LogFieldWorkflow = log.Field("worker_workflow")
LogFieldNodeRunID = log.Field("worker_node_run_id")
LogFieldNodeRun = log.Field("worker_node_run")
LogFieldModel = log.Field("worker_model")
LogFieldServiceCount = log.Field("worker_service_count")
LogFieldServiceCount = log.Field("worker_service_count_num")
)

func init() {
log.RegisterField(LogFieldJobID)
log.RegisterField(LogFieldJobStep)
log.RegisterField(LogFieldJobStepDelay)
log.RegisterField(LogFieldStep)
log.RegisterField(LogFieldStepDelay)
log.RegisterField(LogFieldProjectID)
log.RegisterField(LogFieldProject)
log.RegisterField(LogFieldWorkflow)
Expand Down