From 93b66d0dfa8a4bfd312976cc8687041d9ec19b76 Mon Sep 17 00:00:00 2001 From: Arthur Bellal Date: Wed, 12 Dec 2018 19:44:34 +0100 Subject: [PATCH] rename to monotonic_count, remove cannonicalRate logic --- .../org/datadog/jmxfetch/reporter/Reporter.java | 6 +++--- .../datadog/jmxfetch/reporter/StatsdReporter.java | 2 +- src/test/java/org/datadog/jmxfetch/TestApp.java | 14 -------------- src/test/resources/jmx_count.yaml | 2 +- 4 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/datadog/jmxfetch/reporter/Reporter.java b/src/main/java/org/datadog/jmxfetch/reporter/Reporter.java index ddddbcbcb..01c70a525 100644 --- a/src/main/java/org/datadog/jmxfetch/reporter/Reporter.java +++ b/src/main/java/org/datadog/jmxfetch/reporter/Reporter.java @@ -84,7 +84,7 @@ public void sendMetrics(LinkedList> metrics, String inst // StatsD doesn't support rate metrics so we need to have our own aggregator to compute rates if ("gauge".equals(metricType) || "histogram".equals(metricType)) { sendMetricPoint(metricType, metricName, currentValue, tags); - } else if ("count".equals(metricType)) { + } else if ("monotonic_count".equals(metricType)) { String key = generateId(metric); if (!instanceCountersAggregator.containsKey(key)) { instanceCountersAggregator.put(key, currentValue.longValue()); @@ -100,8 +100,8 @@ public void sendMetrics(LinkedList> metrics, String inst instanceCountersAggregator.put(key, currentValue.longValue()); - if (delta < 0 && canonicalRate) { - LOGGER.info("Counter " + metricName + " has been reset and canonical rate is enabled - not submitting."); + if (delta < 0) { + LOGGER.info("Counter " + metricName + " has been reset - not submitting."); continue; } sendMetricPoint(metricType, metricName, delta, tags); diff --git a/src/main/java/org/datadog/jmxfetch/reporter/StatsdReporter.java b/src/main/java/org/datadog/jmxfetch/reporter/StatsdReporter.java index 44e4db82a..203d088a9 100644 --- a/src/main/java/org/datadog/jmxfetch/reporter/StatsdReporter.java +++ b/src/main/java/org/datadog/jmxfetch/reporter/StatsdReporter.java @@ -31,7 +31,7 @@ protected void sendMetricPoint(String metricType, String metricName, double valu this.statsDClient.stop(); init(); } - if (metricType.equals("count")) { + if (metricType.equals("monotonic_count")) { statsDClient.count(metricName, (long) value, tags); } else if (metricType.equals("histogram")) { statsDClient.histogram(metricName, value, tags); diff --git a/src/test/java/org/datadog/jmxfetch/TestApp.java b/src/test/java/org/datadog/jmxfetch/TestApp.java index 3ce1386c5..171f1df20 100644 --- a/src/test/java/org/datadog/jmxfetch/TestApp.java +++ b/src/test/java/org/datadog/jmxfetch/TestApp.java @@ -741,20 +741,6 @@ public void testAppCount() throws Exception { assertEquals(14, metrics.size()); assertMetric("test.counter", 5, Collections.emptyList(), 3); - // For the 4th collection we decrement the count by 8 so we should get a -8 delta - testApp.decrementCounter(8); - run(); - metrics = getMetrics(); - assertEquals(14, metrics.size()); - assertMetric("test.counter", -8, Collections.emptyList(), 3); - - // For the 5th collection we increment the count by 3 so we should get a +3 delta - testApp.incrementCounter(3); - run(); - metrics = getMetrics(); - assertEquals(14, metrics.size()); - assertMetric("test.counter", 3, Collections.emptyList(), 3); - assertCoverage(); } diff --git a/src/test/resources/jmx_count.yaml b/src/test/resources/jmx_count.yaml index c68c1a060..cc6736f8d 100644 --- a/src/test/resources/jmx_count.yaml +++ b/src/test/resources/jmx_count.yaml @@ -9,5 +9,5 @@ instances: domain: org.datadog.jmxfetch.test attribute: ShouldBeCounter: - metric_type: count + metric_type: monotonic_count alias: test.counter \ No newline at end of file