Skip to content

Commit

Permalink
introduce new type for monotonic counts
Browse files Browse the repository at this point in the history
  • Loading branch information
arbll committed Dec 12, 2018
1 parent b5365bd commit 273aedd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/main/java/org/datadog/jmxfetch/reporter/Reporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void sendMetrics(LinkedList<HashMap<String, Object>> 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 ("count".equals(metricType) || "monotonic_count".equals(metricName)) {
String key = generateId(metric);
if (!instanceCountersAggregator.containsKey(key)) {
instanceCountersAggregator.put(key, currentValue.longValue());
Expand All @@ -100,10 +100,12 @@ public void sendMetrics(LinkedList<HashMap<String, Object>> metrics, String inst

instanceCountersAggregator.put(key, currentValue.longValue());

if (delta < 0 && canonicalRate) {
boolean monotonic = "monotonic_count".equals(metricType);
if (delta < 0 && monotonic) {
LOGGER.info("Counter " + metricName + " has been reset and canonical rate is enabled - not submitting.");
continue;
}

sendMetricPoint(metricType, metricName, delta, tags);

} else { // The metric should be 'counter'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected void sendMetricPoint(String metricType, String metricName, double valu
this.statsDClient.stop();
init();
}
if (metricType.equals("count")) {
if (metricType.equals("count") || metricType.equals("monotonic_count")) {
statsDClient.count(metricName, (long) value, tags);
} else if (metricType.equals("histogram")) {
statsDClient.histogram(metricName, value, tags);
Expand Down

0 comments on commit 273aedd

Please sign in to comment.