All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.dropwizard.metrics5.DeltaCounter Maven / Gradle / Ivy

There is a newer version: 2023-22.3
Show newest version
package io.dropwizard.metrics5;

import com.google.common.annotations.VisibleForTesting;

import com.wavefront.common.MetricConstants;

/**
 * A counter for Wavefront delta metrics.
 *
 * Differs from a counter in that it is reset in the WavefrontReporter every time the value is reported.
 *
 * @author Vikram Raman ([email protected])
 */
public class DeltaCounter extends Counter {

  @VisibleForTesting
  public static synchronized DeltaCounter get(MetricRegistry registry, String metricName) {

    if (registry == null || metricName == null || metricName.isEmpty()) {
      throw new IllegalArgumentException("Invalid arguments");
    }

    if (!(metricName.startsWith(MetricConstants.DELTA_PREFIX) || metricName.startsWith(MetricConstants.DELTA_PREFIX_2))) {
      metricName = MetricConstants.DELTA_PREFIX + metricName;
    }
    DeltaCounter counter = new DeltaCounter();
    registry.register(metricName, counter);
    return counter;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy