From 6279b9bf66b6b64cf8455c6c946420ccf11da873 Mon Sep 17 00:00:00 2001 From: Yevgeniy Miretskiy Date: Wed, 8 Sep 2021 09:25:58 -0400 Subject: [PATCH] jobs,schedule: Annotate context with schedule ID. Annotate context passed to job execution with the schedule ID. Release Justification: Low danger, observability imporovement; category 4. Release Notes: None --- pkg/jobs/job_scheduler.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/jobs/job_scheduler.go b/pkg/jobs/job_scheduler.go index 89171176b684..bc29ca74357d 100644 --- a/pkg/jobs/job_scheduler.go +++ b/pkg/jobs/job_scheduler.go @@ -31,6 +31,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/util/metric" "github.com/cockroachdb/cockroach/pkg/util/stop" "github.com/cockroachdb/errors" + "github.com/cockroachdb/logtags" ) // CreatedByScheduledJobs identifies the job that was created @@ -180,7 +181,8 @@ func (s *jobScheduler) processSchedule( schedule.ScheduleID(), schedule.ScheduleLabel(), schedule.ScheduledRunTime(), schedule.NextRun()) - if err := executor.ExecuteJob(ctx, s.JobExecutionConfig, s.env, schedule, txn); err != nil { + execCtx := logtags.AddTag(ctx, "schedule", schedule.ScheduleID()) + if err := executor.ExecuteJob(execCtx, s.JobExecutionConfig, s.env, schedule, txn); err != nil { return errors.Wrapf(err, "executing schedule %d", schedule.ScheduleID()) }