Skip to content

Commit

Permalink
fix(sdk): hatchery step log delay millisecond (#6454)
Browse files Browse the repository at this point in the history
Signed-off-by: richardlt <richard.le.terrier@gmail.com>
  • Loading branch information
richardlt committed Feb 13, 2023
1 parent 9e332b3 commit 7417899
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions sdk/hatchery/hatchery.go
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, LogFieldStep, step)
ctx = context.WithValue(ctx, LogFieldDelay, time.Since(queued).Milliseconds())
ctx = context.WithValue(ctx, LogFieldJobStep, step)
ctx = context.WithValue(ctx, LogFieldJobStepDelay, time.Since(queued).Milliseconds())
log.Info(ctx, "step: %s job: %s", step, id)
}
}
4 changes: 1 addition & 3 deletions sdk/hatchery/starter.go
Expand Up @@ -201,9 +201,7 @@ func spawnWorkerForJob(ctx context.Context, h Interface, j workerStarterRequest)
}
arg.WorkerToken = jwt

ctx = context.WithValue(ctx, LogFieldStep, "starting-worker-spawn")
ctx = context.WithValue(ctx, LogFieldDelay, time.Since(j.queued).Nanoseconds())
log.Info(ctx, "starting worker spawn for job with id: %d", j.id)
logStepInfo(ctx, "starting-worker-spawn", j.queued)

ctxSpawnWorker, next := telemetry.Span(ctx, "hatchery.SpawnWorker", telemetry.Tag(telemetry.TagWorker, arg.WorkerName))
errSpawn := h.SpawnWorker(ctxSpawnWorker, arg)
Expand Down
8 changes: 4 additions & 4 deletions sdk/hatchery/types.go
Expand Up @@ -28,8 +28,8 @@ const (

var (
LogFieldJobID = log.Field("action_metadata_job_id")
LogFieldStep = log.Field("hatchery_step")
LogFieldDelay = log.Field("hatchery_step_delay")
LogFieldJobStep = log.Field("hatchery_job_step")
LogFieldJobStepDelay = log.Field("hatchery_job_step_delay")
LogFieldProjectID = log.Field("worker_project_id")
LogFieldProject = log.Field("worker_project")
LogFieldWorkflow = log.Field("worker_workflow")
Expand All @@ -41,8 +41,8 @@ var (

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

0 comments on commit 7417899

Please sign in to comment.