in core/src/main/java/com/spotify/metrics/jvm/ThreadStatesMetricSet.java [68:108]
public Map<MetricId, Metric> getMetrics() {
final Map<MetricId, Metric> gauges = new HashMap<MetricId, Metric>();
final MetricId threadState =
MetricId.build().tagged("what", "jvm-thread-state", "unit", "thread");
for (final Thread.State state : Thread.State.values()) {
gauges.put(threadState.tagged("thread_state", state.toString()), new Gauge<Object>() {
@Override
public Object getValue() {
return getThreadCount(state);
}
});
}
gauges.put(threadState.tagged("thread_state", "deadlocked"), new Gauge<Integer>() {
@Override
public Integer getValue() {
return deadlockDetector.getDeadlockedThreads().size();
}
});
final MetricId threadType =
MetricId.build().tagged("what", "jvm-thread-type", "unit", "thread");
gauges.put(threadType.tagged("thread_type", "non-deamon"), new Gauge<Integer>() {
@Override
public Integer getValue() {
return threads.getThreadCount() - threads.getDaemonThreadCount();
}
});
gauges.put(threadType.tagged("thread_type", "daemon"), new Gauge<Integer>() {
@Override
public Integer getValue() {
return threads.getDaemonThreadCount();
}
});
return Collections.unmodifiableMap(gauges);
}