Skip to content

Commit

Permalink
jobs: add tracing spans to update and load job
Browse files Browse the repository at this point in the history
Here we start child tracing spans during update and load job
operations. These seems like the two most interesting operations from
the pespective of resumers.

Release note: None
  • Loading branch information
stevendanna committed Jun 27, 2022
1 parent c09d7fc commit 192f40c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/jobs/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/protoutil"
"github.com/cockroachdb/cockroach/pkg/util/syncutil"
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
"github.com/cockroachdb/cockroach/pkg/util/tracing"
"github.com/cockroachdb/errors"
"github.com/cockroachdb/redact"
"github.com/gogo/protobuf/jsonpb"
Expand Down Expand Up @@ -798,6 +799,9 @@ func HasJobNotFoundError(err error) bool {
}

func (j *Job) load(ctx context.Context, txn *kv.Txn) error {
ctx, sp := tracing.ChildSpan(ctx, "load-job")
defer sp.Finish()

var payload *jobspb.Payload
var progress *jobspb.Progress
var createdBy *CreatedByInfo
Expand Down
6 changes: 5 additions & 1 deletion pkg/jobs/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/protoutil"
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
"github.com/cockroachdb/cockroach/pkg/util/tracing"
"github.com/cockroachdb/errors"
)

Expand Down Expand Up @@ -140,6 +141,9 @@ func (j *Job) Update(ctx context.Context, txn *kv.Txn, updateFn UpdateFn) error
}

func (j *Job) update(ctx context.Context, txn *kv.Txn, useReadLock bool, updateFn UpdateFn) error {
ctx, sp := tracing.ChildSpan(ctx, "update-job")
defer sp.Finish()

var payload *jobspb.Payload
var progress *jobspb.Progress
var status Status
Expand All @@ -150,7 +154,7 @@ func (j *Job) update(ctx context.Context, txn *kv.Txn, useReadLock bool, updateF
var err error
var row tree.Datums
row, err = j.registry.ex.QueryRowEx(
ctx, "log-job", txn,
ctx, "select-job", txn,
sessiondata.InternalExecutorOverride{User: username.RootUserName()},
getSelectStmtForJobUpdate(j.session != nil, useReadLock), j.ID(),
)
Expand Down

0 comments on commit 192f40c

Please sign in to comment.