Add more runtime metrics like information about heap, class loading and threads to the metrics infrastructure
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,6 +32,7 @@ import static org.junit.Assert.assertTrue;
|
||||
* Tests for {@link VanillaPublicMetrics}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Christian Dupuis
|
||||
*/
|
||||
public class VanillaPublicMetricsTests {
|
||||
|
||||
@@ -48,4 +49,32 @@ public class VanillaPublicMetricsTests {
|
||||
assertTrue(results.containsKey("mem.free"));
|
||||
assertThat(results.get("a").getValue().doubleValue(), equalTo(0.5));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSystemMetrics() throws Exception {
|
||||
InMemoryMetricRepository repository = new InMemoryMetricRepository();
|
||||
repository.set(new Metric<Double>("a", 0.5, new Date()));
|
||||
VanillaPublicMetrics publicMetrics = new VanillaPublicMetrics(repository);
|
||||
Map<String, Metric<?>> results = new HashMap<String, Metric<?>>();
|
||||
for (Metric<?> metric : publicMetrics.metrics()) {
|
||||
results.put(metric.getName(), metric);
|
||||
}
|
||||
assertTrue(results.containsKey("mem"));
|
||||
assertTrue(results.containsKey("mem.free"));
|
||||
assertTrue(results.containsKey("processors"));
|
||||
assertTrue(results.containsKey("uptime"));
|
||||
|
||||
assertTrue(results.containsKey("heap.committed"));
|
||||
assertTrue(results.containsKey("heap.init"));
|
||||
assertTrue(results.containsKey("heap.used"));
|
||||
assertTrue(results.containsKey("heap"));
|
||||
|
||||
assertTrue(results.containsKey("threads.peak"));
|
||||
assertTrue(results.containsKey("threads.deamon"));
|
||||
assertTrue(results.containsKey("threads"));
|
||||
|
||||
assertTrue(results.containsKey("classes.loaded"));
|
||||
assertTrue(results.containsKey("classes.unloaded"));
|
||||
assertTrue(results.containsKey("classes"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user