Skip to content

Commit

Permalink
roachtest: prefix all logs with worker tags
Browse files Browse the repository at this point in the history
Previously, many of the runner logs didn't have the worker tags.
This was inadequate because we couldn't break up the logs by wX
tags to see what each worker is doing.
This PR prefixes the worker tags to logs that were missing them.

Epic: none
Fixes: cockroachdb#114045
Release note: None
  • Loading branch information
vidit-bhat committed May 13, 2024
1 parent 2f739e8 commit 336d8c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1927,7 +1927,7 @@ func (c *clusterImpl) Get(
return errors.Wrap(roachprod.Get(ctx, l, c.MakeNodes(opts...), src, dest), "cluster.Get")
}

// Put a string into the specified file on the remote(s).
// PutString into the specified file on the remote(s).
func (c *clusterImpl) PutString(
ctx context.Context, content, dest string, mode os.FileMode, nodes ...option.Option,
) error {
Expand Down
11 changes: 10 additions & 1 deletion pkg/cmd/roachtest/test_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,17 @@ func (r *testRunner) Run(
if err := r.stopper.RunAsyncTask(ctx, "worker", func(ctx context.Context) {
defer wg.Done()

name := fmt.Sprintf("w%d", i)
formattedPrefix := fmt.Sprintf("[%s] ", name)
childLogger, e := l.ChildLogger(name, logger.LogPrefix(formattedPrefix))
if e != nil {
l.Printf("unable to create logger %s: %s", name, e)
return
}
l = childLogger

err := r.runWorker(
ctx, fmt.Sprintf("w%d", i) /* name */, r.work, qp,
ctx, name, r.work, qp,
r.stopper.ShouldQuiesce(),
clusterFactory,
clustersOpt,
Expand Down

0 comments on commit 336d8c3

Please sign in to comment.