Interface TaggedMetricRegistry

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void addMetrics​(java.lang.String safeTagName, java.lang.String safeTagValue, TaggedMetricSet metrics)
      Adds a set of metrics to this TaggedMetricRegistry's metric set, which are to be uniquely identified by the tags provided.
      com.codahale.metrics.Counter counter​(MetricName metricName)
      Returns existing or new counter metric for the specified metric name.
      com.codahale.metrics.Counter counter​(MetricName metricName, java.util.function.Supplier<com.codahale.metrics.Counter> counterSupplier)  
      default <T> java.util.Optional<com.codahale.metrics.Gauge<T>> gauge​(MetricName metricName)
      Returns existing gauge metric for the specified metric name or empty if none has been registered.
      <T> com.codahale.metrics.Gauge<T> gauge​(MetricName metricName, com.codahale.metrics.Gauge<T> gauge)
      Returns existing or new gauge metric for the specified metric name.
      com.codahale.metrics.Histogram histogram​(MetricName metricName)
      Returns existing or new histogram metric for the specified metric name.
      com.codahale.metrics.Histogram histogram​(MetricName metricName, java.util.function.Supplier<com.codahale.metrics.Histogram> histogramSupplier)  
      com.codahale.metrics.Meter meter​(MetricName metricName)
      Returns existing or new meter metric for the specified metric name.
      com.codahale.metrics.Meter meter​(MetricName metricName, java.util.function.Supplier<com.codahale.metrics.Meter> meterSupplier)  
      default void registerWithReplacement​(MetricName metricName, com.codahale.metrics.Gauge<?> gauge)
      Registers and returns the specified gauge, replacing any existing gauge with the specified metric name.
      java.util.Optional<com.codahale.metrics.Metric> remove​(MetricName metricName)
      Removes the tagged metric with the specified metric name.
      java.util.Optional<TaggedMetricSet> removeMetrics​(java.lang.String safeTagName, java.lang.String safeTagValue)
      Removes a TaggedMetricsSet added via addMetrics from this metrics set.
      boolean removeMetrics​(java.lang.String safeTagName, java.lang.String safeTagValue, TaggedMetricSet metrics)
      Removes a TaggedMetricsSet added via addMetrics from this metrics set, if currently registered to this metric set.
      com.codahale.metrics.Timer timer​(MetricName metricName)
      Returns existing or new timer metric for the specified metric name.
      com.codahale.metrics.Timer timer​(MetricName metricName, java.util.function.Supplier<com.codahale.metrics.Timer> timerSupplier)  
    • Method Detail

      • timer

        com.codahale.metrics.Timer timer​(MetricName metricName)
        Returns existing or new timer metric for the specified metric name.
        Parameters:
        metricName - metric name
        Returns:
        timer metric
      • timer

        com.codahale.metrics.Timer timer​(MetricName metricName,
                                         java.util.function.Supplier<com.codahale.metrics.Timer> timerSupplier)
      • meter

        com.codahale.metrics.Meter meter​(MetricName metricName)
        Returns existing or new meter metric for the specified metric name.
        Parameters:
        metricName - metric name
        Returns:
        meter metric
      • meter

        com.codahale.metrics.Meter meter​(MetricName metricName,
                                         java.util.function.Supplier<com.codahale.metrics.Meter> meterSupplier)
      • histogram

        com.codahale.metrics.Histogram histogram​(MetricName metricName)
        Returns existing or new histogram metric for the specified metric name.
        Parameters:
        metricName - metric name
        Returns:
        histogram metric
      • histogram

        com.codahale.metrics.Histogram histogram​(MetricName metricName,
                                                 java.util.function.Supplier<com.codahale.metrics.Histogram> histogramSupplier)
      • gauge

        default <T> java.util.Optional<com.codahale.metrics.Gauge<T>> gauge​(MetricName metricName)
        Returns existing gauge metric for the specified metric name or empty if none has been registered.
        Parameters:
        metricName - metric name
        Returns:
        gauge metric or empty if none exists for this name
      • gauge

        <T> com.codahale.metrics.Gauge<T> gauge​(MetricName metricName,
                                                com.codahale.metrics.Gauge<T> gauge)
        Returns existing or new gauge metric for the specified metric name.
        Parameters:
        metricName - metric name
        gauge - gauge
        Returns:
        gauge metric

        In most cases, one typically wants registerWithReplacement(MetricName, Gauge) as gauges may retain references to large backing data structures (e.g. queue or cache), and if a gauge is being registered with the same name, one is likely replacing that previous data structure and the registry should not retain references to the previous version. If lookup of an existing gauge is desired, one should use gauge(MetricName).

      • registerWithReplacement

        default void registerWithReplacement​(MetricName metricName,
                                             com.codahale.metrics.Gauge<?> gauge)
        Registers and returns the specified gauge, replacing any existing gauge with the specified metric name.
        Parameters:
        metricName - metric name
        gauge - gauge
      • counter

        com.codahale.metrics.Counter counter​(MetricName metricName)
        Returns existing or new counter metric for the specified metric name.
        Parameters:
        metricName - metric name
        Returns:
        counter metric
      • counter

        com.codahale.metrics.Counter counter​(MetricName metricName,
                                             java.util.function.Supplier<com.codahale.metrics.Counter> counterSupplier)
      • remove

        java.util.Optional<com.codahale.metrics.Metric> remove​(MetricName metricName)
        Removes the tagged metric with the specified metric name.
        Parameters:
        metricName - metric name
        Returns:
        the removed metric
      • addMetrics

        void addMetrics​(java.lang.String safeTagName,
                        java.lang.String safeTagValue,
                        TaggedMetricSet metrics)
        Adds a set of metrics to this TaggedMetricRegistry's metric set, which are to be uniquely identified by the tags provided.

        So, if I have a metric registry with a single metric called 'foo', and I add it with tag (bar, baz), this registry will now contain 'foo', tagged with (bar, baz).

        If a metric exists with duplicate tags, then calling TaggedMetricSet.getMetrics() will be impossible.

        Parameters:
        safeTagName - a tag key which should be added to all metrics in the metrics set
        safeTagValue - a tag value which should be added to all metrics in the metrics set
        metrics - the metrics which should be added
      • removeMetrics

        java.util.Optional<TaggedMetricSet> removeMetrics​(java.lang.String safeTagName,
                                                          java.lang.String safeTagValue)
        Removes a TaggedMetricsSet added via addMetrics from this metrics set.
      • removeMetrics

        boolean removeMetrics​(java.lang.String safeTagName,
                              java.lang.String safeTagValue,
                              TaggedMetricSet metrics)
        Removes a TaggedMetricsSet added via addMetrics from this metrics set, if currently registered to this metric set.

        The value is removed only when Object.equals(java.lang.Object) for the values returns true, therefore you should generally provide the same instance as a previous call to addMetrics.

        Returns:
        true if value was removed