Class MetricsFactory

java.lang.Object
io.dropwizard.metrics.common.MetricsFactory

public class MetricsFactory extends Object
A factory for configuring the metrics sub-system for the environment.

Configures an optional list of reporters with a default frequency.

Configuration Parameters:

Name Default Description
frequency 1 minute The frequency to report metrics. Overridable per-reporter.
reporters No reporters. A list of reporters to report metrics.
reportOnStop false To report metrics one last time when stopping Dropwizard.
  • Constructor Details

    • MetricsFactory

      public MetricsFactory()
  • Method Details

    • getReporters

      public List<ReporterFactory> getReporters()
    • setReporters

      public void setReporters(List<ReporterFactory> reporters)
    • getFrequency

      public io.dropwizard.util.Duration getFrequency()
    • setFrequency

      public void setFrequency(io.dropwizard.util.Duration frequency)
    • isReportOnStop

      public boolean isReportOnStop()
      Since:
      2.0
    • setReportOnStop

      public void setReportOnStop(boolean reportOnStop)
      Since:
      2.0
    • configure

      public void configure(io.dropwizard.lifecycle.setup.LifecycleEnvironment environment, com.codahale.metrics.MetricRegistry registry)
      Configures the given lifecycle with the reporters configured for the given registry.

      The reporters are tied in to the given lifecycle, such that their frequency for reporting metrics begins when the lifecycle starts, and stops when the lifecycle stops.

      Parameters:
      environment - the lifecycle to manage the reporters.
      registry - the metric registry to report metrics from.
    • toString

      public String toString()
      Overrides:
      toString in class Object