Skip to content

Commit

Permalink
Fetch more JVM (Non)Heap variables by default
Browse files Browse the repository at this point in the history
  • Loading branch information
yannmh committed Feb 11, 2015
1 parent e68a97a commit bd8915c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
18 changes: 18 additions & 0 deletions src/main/resources/jmx-2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,27 @@ include:
HeapMemoryUsage.used:
alias: jvm.heap_memory
metric_type: gauge
HeapMemoryUsage.committed:
alias: jvm.heap_memory_committed
metric_type: gauge
HeapMemoryUsage.init:
alias: jvm.heap_memory_init
metric_type: gauge
HeapMemoryUsage.max:
alias: jvm.heap_memory_max
metric_type: gauge
NonHeapMemoryUsage.used:
alias: jvm.non_heap_memory
metric_type: gauge
NonHeapMemoryUsage.committed:
alias: jvm.non_heap_memory_committed
metric_type: gauge
NonHeapMemoryUsage.init:
alias: jvm.non_heap_memory_init
metric_type: gauge
NonHeapMemoryUsage.max:
alias: jvm.non_heap_memory_max
metric_type: gauge
ThreadCount:
alias: jvm.thread_count
metric_type: gauge
Expand Down
15 changes: 11 additions & 4 deletions src/test/java/org/datadog/jmxfetch/TestApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void testApp() throws Exception {
app.doIteration();
LinkedList<HashMap<String, Object>> metrics = ((ConsoleReporter) appConfig.getReporter()).getMetrics();

assertEquals(19, metrics.size()); // 19 = 7 metrics from java.lang + the 5 gauges we are explicitly collecting + the 7 gauges that is implicitly collected, see jmx.yaml in the test/resources folder
assertEquals(25, metrics.size()); // 25 = 13 metrics from java.lang + the 5 gauges we are explicitly collecting + the 7 gauges that is implicitly collected, see jmx.yaml in the test/resources folder

// We test for the presence and the value of the metrics we want to collect
boolean metric100Present = false;
Expand Down Expand Up @@ -82,7 +82,7 @@ public void testApp() throws Exception {
assertEquals(8, tags.length);
assertEquals(new Double(100.0), value);
metric100Present = true;

assertTrue(Arrays.asList(tags).contains("foo"));
assertTrue(Arrays.asList(tags).contains("gorch"));
assertTrue(Arrays.asList(tags).contains("bar:baz"));
Expand Down Expand Up @@ -159,7 +159,7 @@ public void testApp() throws Exception {
// We run a second collection. The counter should now be present
app.doIteration();
metrics = ((ConsoleReporter) appConfig.getReporter()).getMetrics();
assertEquals(21, metrics.size()); // 21 = 7 metrics from java.lang + the 5 gauges we are explicitly collecting + 7 gauges implicitly collected + 2 counter, see jmx.yaml in the test/resources folder
assertEquals(27, metrics.size()); // 27 = 13 metrics from java.lang + the 5 gauges we are explicitly collecting + 7 gauges implicitly collected + 2 counter, see jmx.yaml in the test/resources folder

// We test for the same metrics but this time, the counter should be here
metric100Present = false;
Expand Down Expand Up @@ -280,7 +280,7 @@ public void testApp() throws Exception {

app.doIteration();
metrics = ((ConsoleReporter) appConfig.getReporter()).getMetrics();
assertEquals(metrics.size(), 21); // 21 = 7 metrics from java.lang + the 5 gauges we are explicitly collecting + 7 gauges implicitly collected + 2 counter, see jmx.yaml in the test/resources folder
assertEquals(metrics.size(), 27); // 27 = 13 metrics from java.lang + the 5 gauges we are explicitly collecting + 7 gauges implicitly collected + 2 counter, see jmx.yaml in the test/resources folder

metric100Present = false;
metric1000Present = false;
Expand All @@ -300,7 +300,14 @@ public void testApp() throws Exception {
jvm_metrics.put("jvm.gc.cms.count", 2);
jvm_metrics.put("jvm.gc.parnew.time", 2);
jvm_metrics.put("jvm.heap_memory", 1);
jvm_metrics.put("jvm.heap_memory_committed", 1);
jvm_metrics.put("jvm.heap_memory_init", 1);
jvm_metrics.put("jvm.heap_memory_max", 1);
jvm_metrics.put("jvm.non_heap_memory", 1);
jvm_metrics.put("jvm.non_heap_memory_committed", 1);
jvm_metrics.put("jvm.non_heap_memory_init", 1);
jvm_metrics.put("jvm.non_heap_memory_max", 1);

jvm_metrics.put("jvm.thread_count", 1);

for (HashMap<String, Object> m : metrics) {
Expand Down

0 comments on commit bd8915c

Please sign in to comment.