Java Code Examples for com.codahale.metrics.Counting#getCount()

The following examples show how to use com.codahale.metrics.Counting#getCount() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CloudWatchReporter.java    From codahale-aggregated-metrics-cloudwatch-reporter with MIT License 6 votes vote down vote up
private void processCounter(final String metricName, final Counting counter, final List<MetricDatum> metricData) {
    long currentCount = counter.getCount();
    Long lastCount = lastPolledCounts.get(counter);
    lastPolledCounts.put(counter, currentCount);

    if (lastCount == null) {
        lastCount = 0L;
    }

    final long reportValue;
    if (builder.withReportRawCountValue) {
        reportValue = currentCount;
    } else {
        // Only submit metrics that have changed - let's save some money!
        reportValue = currentCount - lastCount;
    }

    stageMetricDatum(true, metricName, reportValue, StandardUnit.COUNT, DIMENSION_COUNT, metricData);
}
 
Example 2
Source File: CloudWatchReporter.java    From metrics-cloudwatch with Apache License 2.0 5 votes vote down vote up
private long diffLast(Counting metric) {
    long count = metric.getCount();

    Long lastCount = lastPolledCounts.get(metric);
    lastPolledCounts.put(metric, count);

    if (lastCount == null) {
        lastCount = 0L;
    }
    return count - lastCount;
}