Interface MetricsService

  • All Known Implementing Classes:
    MetricsManager

    public interface MetricsService
    Metrics Service to collect metrics.
    • Method Detail

      • registerComponent

        MetricsComponent registerComponent​(String name)
        Registers a component.
        Parameters:
        name - name of the Component to register
        Returns:
        MetricsComponent object that can be used to create Metrics.
      • getMetricRegistry

        com.codahale.metrics.MetricRegistry getMetricRegistry()
        Fetches existing metric registry.
        Returns:
        metric registry
      • createCounter

        com.codahale.metrics.Counter createCounter​(MetricsComponent component,
                                                   MetricsFeature feature,
                                                   String metricName)
        Creates a Counter metric.
        Parameters:
        component - component the Counter is defined in
        feature - feature the Counter is defined in
        metricName - local name of the metric
        Returns:
        the created Counter Meteric
      • createHistogram

        com.codahale.metrics.Histogram createHistogram​(MetricsComponent component,
                                                       MetricsFeature feature,
                                                       String metricName)
        Creates a Histogram metric.
        Parameters:
        component - component the Histogram is defined in
        feature - feature the Histogram is defined in
        metricName - local name of the metric
        Returns:
        the created Histogram Metric
      • createTimer

        com.codahale.metrics.Timer createTimer​(MetricsComponent component,
                                               MetricsFeature feature,
                                               String metricName)
        Creates a Timer metric.
        Parameters:
        component - component the Timer is defined in
        feature - feature the Timer is defined in
        metricName - local name of the metric
        Returns:
        the created Timer Metric
      • createMeter

        com.codahale.metrics.Meter createMeter​(MetricsComponent component,
                                               MetricsFeature feature,
                                               String metricName)
        Creates a Meter metric.
        Parameters:
        component - component the Meter is defined in
        feature - feature the Meter is defined in
        metricName - local name of the metric
        Returns:
        the created Meter Metric
      • registerMetric

        <T extends com.codahale.metrics.Metric> T registerMetric​(MetricsComponent component,
                                                                 MetricsFeature feature,
                                                                 String metricName,
                                                                 T metric)
        Registers an already created Metric. This is used for situation where a caller needs to allocate its own Metric, but still register it with the system.
        Type Parameters:
        T - Metric type
        Parameters:
        component - component the Metric is defined in
        feature - feature the Metric is defined in
        metricName - local name of the metric
        metric - Metric to register
        Returns:
        the registered Metric
      • registerReporter

        void registerReporter​(MetricsReporter reporter)
        Registers a reporter to receive any changes on metric registry.
        Parameters:
        reporter - metric reporter
      • unregisterReporter

        void unregisterReporter​(MetricsReporter reporter)
        Unregisters the given metric reporter.
        Parameters:
        reporter - metric reporter
      • notifyReporters

        void notifyReporters()
        Notifies the changes on metric registry to all registered reporters.
      • removeMetric

        boolean removeMetric​(MetricsComponent component,
                             MetricsFeature feature,
                             String metricName)
        Removes the metric with the given name.
        Parameters:
        component - component the Metric is defined in
        feature - feature the Metric is defined in
        metricName - local name of the metric
        Returns:
        true if the metric existed and was removed, otherwise false
      • getTimers

        Map<String,​com.codahale.metrics.Timer> getTimers​(com.codahale.metrics.MetricFilter filter)
        Fetches the existing Timers.
        Parameters:
        filter - filter to use to select Timers
        Returns:
        a map of the Timers that match the filter, with the key as the name String to the Timer.
      • getGauges

        Map<String,​com.codahale.metrics.Gauge> getGauges​(com.codahale.metrics.MetricFilter filter)
        Fetches the existing Gauges.
        Parameters:
        filter - filter to use to select Gauges
        Returns:
        a map of the Gauges that match the filter, with the key as the name String to the Gauge.
      • getCounters

        Map<String,​com.codahale.metrics.Counter> getCounters​(com.codahale.metrics.MetricFilter filter)
        Fetches the existing Counters.
        Parameters:
        filter - filter to use to select Counters
        Returns:
        a map of the Counters that match the filter, with the key as the name String to the Counter.
      • getMeters

        Map<String,​com.codahale.metrics.Meter> getMeters​(com.codahale.metrics.MetricFilter filter)
        Fetches the existing Meters.
        Parameters:
        filter - filter to use to select Meters
        Returns:
        a map of the Meters that match the filter, with the key as the name String to the Meter.
      • getHistograms

        Map<String,​com.codahale.metrics.Histogram> getHistograms​(com.codahale.metrics.MetricFilter filter)
        Fetches the existing Histograms.
        Parameters:
        filter - filter to use to select Histograms
        Returns:
        a map of the Histograms that match the filter, with the key as the name String to the Histogram.
      • getMetrics

        Map<String,​com.codahale.metrics.Metric> getMetrics()
        Fetches the existing metrics.
        Returns:
        a map of the Metrics, with the key as the name String to the Histogram.
      • removeMatching

        void removeMatching​(com.codahale.metrics.MetricFilter filter)
        Removes all Metrics that match a given filter.
        Parameters:
        filter - filter to use to select the Metrics to remove.