Skip to content

Commit

Permalink
[Dataflow Streaming] Add workToken to thread name for easier debugging (
Browse files Browse the repository at this point in the history
apache#30786)

Co-authored-by: Arun Pandian <[email protected]>
  • Loading branch information
arunpandianp and arunpandianp authored Mar 29, 2024
1 parent f7319a6 commit 08253ea
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.beam.runners.dataflow.worker.streaming.Work;
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.util.concurrent.Monitor;
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.util.concurrent.Monitor.Guard;

Expand Down Expand Up @@ -185,10 +186,17 @@ private void executeLockHeld(Runnable work, long workBytes) {
try {
executor.execute(
() -> {
String threadName = Thread.currentThread().getName();
try {
if (work instanceof Work) {
String workToken =
String.format("%016x", ((Work) work).getWorkItem().getWorkToken());
Thread.currentThread().setName(threadName + ":" + workToken);
}
work.run();
} finally {
decrementCounters(workBytes);
Thread.currentThread().setName(threadName);
}
});
} catch (RuntimeException e) {
Expand Down

0 comments on commit 08253ea

Please sign in to comment.