Skip to content

Commit

Permalink
Add target label to SpawnExec in the execution log (#15435)
Browse files Browse the repository at this point in the history
The execution log is very handy for tracking fine grain build data for analysis, however there's no easy way to correlate the action data to a target, this change simply adds the owning target's label to the SpawnExec info to enable this correlation.

Closes #14818.

PiperOrigin-RevId: 439516075

Co-authored-by: Cristian Hancila <chancila@gmail.com>
  • Loading branch information
ckolli5 and chancila authored May 9, 2022
1 parent bc42b65 commit e239f58
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ public void logSpawn(
}
builder.setMnemonic(spawn.getMnemonic());
builder.setWalltime(Durations.fromNanos(result.getMetrics().executionWallTime().toNanos()));

if (spawn.getTargetLabel() != null) {
builder.setTargetLabel(spawn.getTargetLabel());
}

executionLog.write(builder.build());
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/protobuf/spawn.proto
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,8 @@ message SpawnExec {
// The wall time it took to execute the Spawn. This is only the time spent in
// the subprocess, not including the time doing setup and teardown.
google.protobuf.Duration walltime = 17;

// Canonical label of the target that emitted this spawn, may not always be
// set.
string target_label = 18;
}
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ public void testLogSpawn() throws Exception {
.setMnemonic("MyMnemonic")
.setRunner("runner")
.setWalltime(Duration.getDefaultInstance())
.setTargetLabel("//dummy:label")
.build();
verify(messageOutput).write(expectedSpawnLog);
}
Expand Down Expand Up @@ -491,6 +492,7 @@ private static SpawnExec.Builder defaultSpawnExecBuilder(String cmd) {
.setStatus("NON_ZERO_EXIT")
.setExitCode(23)
.setRemoteCacheable(true)
.setWalltime(Duration.getDefaultInstance());
.setWalltime(Duration.getDefaultInstance())
.setTargetLabel("//dummy:label");
}
}

0 comments on commit e239f58

Please sign in to comment.