Search code examples
javadropwizardgraphitegauge

Dropwizard gauge frequency


I am using dropwizard gauge functionality in my code as following :

    private AtomicInteger heapUsageAfterCollectionThresholdExceeded;

       new Gauge<Integer>() {
        @Override
        public Integer getValue() {
            return heapUsageThresholdExceeded.get();
        }

Now this starts pushing the value of heapUsageThresholdExceeded to graphite. I was expecting to see integer values in graphite. But in graphite I see the value reported as a decimal point value (0.15). I have following questions:

  1. Why is a integer gauge reported as a decimal value ?
  2. How often does drop wizard measure/push the metric for a registered gauge ?

ref : https://metrics.dropwizard.io/3.1.0/apidocs/com/codahale/metrics/Gauge.html


Solution

  • To answer your second question, it depends on the frequency at which metrics are reported. The default frequency is 1 minute

    You can specify the frequency in your configuration file. Eg -

    metrics:
      reporters:
        - type: graphite
          host: localhost
          port: 2003
          prefix: example
          frequency: 1m