Class DefaultMetricCollector

java.lang.Object
net.spy.memcached.metrics.AbstractMetricCollector
net.spy.memcached.metrics.DefaultMetricCollector
All Implemented Interfaces:
MetricCollector

public final class DefaultMetricCollector extends AbstractMetricCollector
A MetricCollector that uses the Codahale Metrics library. The following system properies can be used to customize the behavior of the collector during runtime:
 - net.spy.metrics.reporter.type = console (console/jmx/csv/slf4j)
 - net.spy.metrics.reporter.interval = 30 (time interval to log)
 - net.spy.metrics.reporter.outdir = ~/mydir (output dir for csv reporter)
 
  • Field Details

    • DEFAULT_REPORTER_TYPE

      public static final String DEFAULT_REPORTER_TYPE
      Use the "console" reporter by default.
      See Also:
    • DEFAULT_REPORTER_INTERVAL

      public static final String DEFAULT_REPORTER_INTERVAL
      Log every 30 seconds to the console by default.
      See Also:
    • DEFAULT_REPORTER_OUTDIR

      public static final String DEFAULT_REPORTER_OUTDIR
      Define an empty directory for the CSV exporter by default.
      See Also:
    • registry

      private com.codahale.metrics.MetricRegistry registry
      Holds the registry where all metrics are stored.
    • counters

      private ConcurrentHashMap<String,com.codahale.metrics.Counter> counters
      Contains all registered Counters.
    • meters

      private ConcurrentHashMap<String,com.codahale.metrics.Meter> meters
      Contains all registered Meters.
    • histograms

      private ConcurrentHashMap<String,com.codahale.metrics.Histogram> histograms
      Contains all registered Histograms.
  • Constructor Details

    • DefaultMetricCollector

      public DefaultMetricCollector()
      Create a new DefaultMetricCollector. Note that when this constructor is called, the reporter is also automatically established.
  • Method Details

    • initReporter

      private void initReporter()
      Initialize the proper metrics Reporter.
    • addCounter

      public void addCounter(String name)
      Description copied from interface: MetricCollector
      Add a Counter to the collector.
      Parameters:
      name - the name of the counter.
    • removeCounter

      public void removeCounter(String name)
      Description copied from interface: MetricCollector
      Remove a Counter from the collector.
      Parameters:
      name - the name of the counter.
    • incrementCounter

      public void incrementCounter(String name, int amount)
      Description copied from interface: MetricCollector
      Increment a Counter by the given amount.
      Parameters:
      name - the name of the counter.
      amount - the amount to increase.
    • decrementCounter

      public void decrementCounter(String name, int amount)
      Description copied from interface: MetricCollector
      Decrement a Counter by the given amount.
      Parameters:
      name - the name of the counter.
      amount - the amount to decrease.
    • addMeter

      public void addMeter(String name)
      Description copied from interface: MetricCollector
      Add a Meter to the Collector.
      Parameters:
      name - the name of the counter.
    • removeMeter

      public void removeMeter(String name)
      Description copied from interface: MetricCollector
      Remove a Meter from the Collector.
      Parameters:
      name - the name of the counter.
    • markMeter

      public void markMeter(String name)
      Description copied from interface: MetricCollector
      Mark a checkpoint in the Meter.
      Parameters:
      name - the name of the counter.
    • addHistogram

      public void addHistogram(String name)
      Description copied from interface: MetricCollector
      Add a Histogram to the Collector.
      Parameters:
      name - the name of the counter.
    • removeHistogram

      public void removeHistogram(String name)
      Description copied from interface: MetricCollector
      Remove a Histogram from the Collector.
      Parameters:
      name - the name of the counter.
    • updateHistogram

      public void updateHistogram(String name, int amount)
      Description copied from interface: MetricCollector
      Update the Histogram with the given amount.
      Parameters:
      name - the name of the counter.
      amount - the amount to update.