Core: include timestamp and params in hot threads
Include the timestamp and params (interval, busiestThreads, ignoreIdleThreads), when hot threads were collected. Closes #9773
This commit is contained in:
parent
7dad162377
commit
4859ce5d79
|
@ -21,6 +21,8 @@ package org.elasticsearch.monitor.jvm;
|
||||||
|
|
||||||
import org.apache.lucene.util.CollectionUtil;
|
import org.apache.lucene.util.CollectionUtil;
|
||||||
import org.elasticsearch.ElasticsearchIllegalArgumentException;
|
import org.elasticsearch.ElasticsearchIllegalArgumentException;
|
||||||
|
import org.elasticsearch.common.joda.FormatDateTimeFormatter;
|
||||||
|
import org.elasticsearch.common.joda.Joda;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
|
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
|
@ -35,6 +37,8 @@ public class HotThreads {
|
||||||
|
|
||||||
private static final Object mutex = new Object();
|
private static final Object mutex = new Object();
|
||||||
|
|
||||||
|
private static final FormatDateTimeFormatter DATE_TIME_FORMATTER = Joda.forPattern("dateOptionalTime");
|
||||||
|
|
||||||
private int busiestThreads = 3;
|
private int busiestThreads = 3;
|
||||||
private TimeValue interval = new TimeValue(500, TimeUnit.MILLISECONDS);
|
private TimeValue interval = new TimeValue(500, TimeUnit.MILLISECONDS);
|
||||||
private TimeValue threadElementsSnapshotDelay = new TimeValue(10);
|
private TimeValue threadElementsSnapshotDelay = new TimeValue(10);
|
||||||
|
@ -122,6 +126,17 @@ public class HotThreads {
|
||||||
|
|
||||||
private String innerDetect() throws Exception {
|
private String innerDetect() throws Exception {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
sb.append("Hot threads at ");
|
||||||
|
sb.append(DATE_TIME_FORMATTER.printer().print(System.currentTimeMillis()));
|
||||||
|
sb.append(", interval=");
|
||||||
|
sb.append(interval);
|
||||||
|
sb.append(", busiestThreads=");
|
||||||
|
sb.append(busiestThreads);
|
||||||
|
sb.append(", ignoreIdleThreads=");
|
||||||
|
sb.append(ignoreIdleThreads);
|
||||||
|
sb.append(":\n");
|
||||||
|
|
||||||
ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
|
ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
|
||||||
boolean enabledCpu = false;
|
boolean enabledCpu = false;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -163,4 +163,17 @@ public class HotThreadsTest extends ElasticsearchIntegrationTest {
|
||||||
// The filtered stacks should be smaller than unfiltered ones:
|
// The filtered stacks should be smaller than unfiltered ones:
|
||||||
assertThat(totSizeIgnoreIdle, lessThan(totSizeAll));
|
assertThat(totSizeIgnoreIdle, lessThan(totSizeAll));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testTimestampAndParams() throws ExecutionException, InterruptedException {
|
||||||
|
|
||||||
|
NodesHotThreadsResponse response = client().admin().cluster().prepareNodesHotThreads().execute().get();
|
||||||
|
|
||||||
|
for (NodeHotThreads node : response.getNodesMap().values()) {
|
||||||
|
String result = node.getHotThreads();
|
||||||
|
assertTrue(result.indexOf("Hot threads at") != -1);
|
||||||
|
assertTrue(result.indexOf("interval=500ms") != -1);
|
||||||
|
assertTrue(result.indexOf("busiestThreads=3") != -1);
|
||||||
|
assertTrue(result.indexOf("ignoreIdleThreads=true") != -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue