diff --git a/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java b/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java index b1eab176103c58..296f1a898feacf 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java +++ b/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java @@ -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()); } diff --git a/src/main/protobuf/spawn.proto b/src/main/protobuf/spawn.proto index 039a5613d8e60c..1507add65f480a 100644 --- a/src/main/protobuf/spawn.proto +++ b/src/main/protobuf/spawn.proto @@ -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; } diff --git a/src/test/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategyTest.java b/src/test/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategyTest.java index ea322f656e48cc..ef7ca4043a63dd 100644 --- a/src/test/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategyTest.java +++ b/src/test/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategyTest.java @@ -366,6 +366,7 @@ public void testLogSpawn() throws Exception { .setMnemonic("MyMnemonic") .setRunner("runner") .setWalltime(Duration.getDefaultInstance()) + .setTargetLabel("//dummy:label") .build(); verify(messageOutput).write(expectedSpawnLog); } @@ -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"); } }