Skip to content

Commit 3180503

Browse files
authored
Set a name to threads created by Scheduler Threadfactory (#1307)
Use prefix "prometheus-metrics-scheduler-" plus counter. Used in conjunction with https://issues.apache.org/jira/browse/KAFKA-18982 --------- Signed-off-by: Edoardo Comar <[email protected]>
1 parent 7572b1f commit 3180503

File tree

1 file changed

+7
-1
lines changed
  • prometheus-metrics-core/src/main/java/io/prometheus/metrics/core/util

1 file changed

+7
-1
lines changed

prometheus-metrics-core/src/main/java/io/prometheus/metrics/core/util/Scheduler.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@
1414
public class Scheduler {
1515

1616
private static class DaemonThreadFactory implements ThreadFactory {
17+
private static int threadNum;
18+
19+
private static synchronized int nextThreadNum() {
20+
return threadNum++;
21+
}
22+
1723
@Override
1824
public Thread newThread(Runnable runnable) {
19-
Thread thread = new Thread(runnable);
25+
Thread thread = new Thread(runnable, "prometheus-metrics-scheduler-" + nextThreadNum());
2026
thread.setDaemon(true);
2127
return thread;
2228
}

0 commit comments

Comments
 (0)