Class AbstractTaggedMetricRegistry

    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractTaggedMetricRegistry​(java.util.function.Supplier<com.codahale.metrics.Reservoir> reservoirSupplier)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addMetrics​(java.lang.String safeTagName, java.lang.String safeTagValue, TaggedMetricSet other)
      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)  
      protected java.util.function.Supplier<com.codahale.metrics.Counter> counterSupplier()
      Supplies counter instances for this registry.
      protected com.codahale.metrics.Reservoir createReservoir()
      Supplies reservoir instances for this registry.
      void forEachMetric​(java.util.function.BiConsumer<MetricName,​com.codahale.metrics.Metric> consumer)  
      <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.
      java.util.Map<MetricName,​com.codahale.metrics.Metric> getMetrics()
      Returns a map of metrics.
      protected <T extends com.codahale.metrics.Metric>
      T
      getOrAdd​(MetricName metricName, java.lang.Class<T> metricClass, java.util.function.Supplier<T> metricSupplier)  
      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)  
      protected java.util.function.Supplier<com.codahale.metrics.Histogram> histogramSupplier()
      Supplies histogram instances for this registry.
      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)  
      protected java.util.function.Supplier<com.codahale.metrics.Meter> meterSupplier()
      Supplies meter instances for this registry.
      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)  
      protected java.util.function.Supplier<com.codahale.metrics.Timer> timerSupplier()
      Supplies timer instances for this registry.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractTaggedMetricRegistry

        public AbstractTaggedMetricRegistry​(java.util.function.Supplier<com.codahale.metrics.Reservoir> reservoirSupplier)
    • Method Detail

      • counterSupplier

        @Nonnull
        protected java.util.function.Supplier<com.codahale.metrics.Counter> counterSupplier()
        Supplies counter instances for this registry.
        Returns:
        counter supplier
      • histogramSupplier

        @Nonnull
        protected java.util.function.Supplier<com.codahale.metrics.Histogram> histogramSupplier()
        Supplies histogram instances for this registry.
        Returns:
        histogram supplier
      • meterSupplier

        @Nonnull
        protected java.util.function.Supplier<com.codahale.metrics.Meter> meterSupplier()
        Supplies meter instances for this registry.
        Returns:
        meter supplier
      • timerSupplier

        @Nonnull
        protected java.util.function.Supplier<com.codahale.metrics.Timer> timerSupplier()
        Supplies timer instances for this registry.
        Returns:
        timer supplier
      • createReservoir

        @Nonnull
        protected final com.codahale.metrics.Reservoir createReservoir()
        Supplies reservoir instances for this registry.
        Returns:
        reservoir supplier
      • counter

        public final com.codahale.metrics.Counter counter​(MetricName metricName)
        Description copied from interface: TaggedMetricRegistry
        Returns existing or new counter metric for the specified metric name.
        Specified by:
        counter in interface TaggedMetricRegistry
        Parameters:
        metricName - metric name
        Returns:
        counter metric
      • counter

        public final com.codahale.metrics.Counter counter​(MetricName metricName,
                                                          java.util.function.Supplier<com.codahale.metrics.Counter> counterSupplier)
        Specified by:
        counter in interface TaggedMetricRegistry
      • gauge

        public final <T> java.util.Optional<com.codahale.metrics.Gauge<T>> gauge​(MetricName metricName)
        Description copied from interface: TaggedMetricRegistry
        Returns existing gauge metric for the specified metric name or empty if none has been registered.
        Specified by:
        gauge in interface TaggedMetricRegistry
        Parameters:
        metricName - metric name
        Returns:
        gauge metric or empty if none exists for this name
      • gauge

        public final <T> com.codahale.metrics.Gauge<T> gauge​(MetricName metricName,
                                                             com.codahale.metrics.Gauge<T> gauge)
        Description copied from interface: TaggedMetricRegistry
        Returns existing or new gauge metric for the specified metric name.
        Specified by:
        gauge in interface TaggedMetricRegistry
        Parameters:
        metricName - metric name
        gauge - gauge
        Returns:
        gauge metric

        In most cases, one typically wants TaggedMetricRegistry.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 TaggedMetricRegistry.gauge(MetricName).

      • registerWithReplacement

        public final void registerWithReplacement​(MetricName metricName,
                                                  com.codahale.metrics.Gauge<?> gauge)
        Description copied from interface: TaggedMetricRegistry
        Registers and returns the specified gauge, replacing any existing gauge with the specified metric name.
        Specified by:
        registerWithReplacement in interface TaggedMetricRegistry
        Parameters:
        metricName - metric name
        gauge - gauge
      • histogram

        public final com.codahale.metrics.Histogram histogram​(MetricName metricName)
        Description copied from interface: TaggedMetricRegistry
        Returns existing or new histogram metric for the specified metric name.
        Specified by:
        histogram in interface TaggedMetricRegistry
        Parameters:
        metricName - metric name
        Returns:
        histogram metric
      • histogram

        public final com.codahale.metrics.Histogram histogram​(MetricName metricName,
                                                              java.util.function.Supplier<com.codahale.metrics.Histogram> histogramSupplier)
        Specified by:
        histogram in interface TaggedMetricRegistry
      • meter

        public final com.codahale.metrics.Meter meter​(MetricName metricName)
        Description copied from interface: TaggedMetricRegistry
        Returns existing or new meter metric for the specified metric name.
        Specified by:
        meter in interface TaggedMetricRegistry
        Parameters:
        metricName - metric name
        Returns:
        meter metric
      • meter

        public final com.codahale.metrics.Meter meter​(MetricName metricName,
                                                      java.util.function.Supplier<com.codahale.metrics.Meter> meterSupplier)
        Specified by:
        meter in interface TaggedMetricRegistry
      • timer

        public final com.codahale.metrics.Timer timer​(MetricName metricName)
        Description copied from interface: TaggedMetricRegistry
        Returns existing or new timer metric for the specified metric name.
        Specified by:
        timer in interface TaggedMetricRegistry
        Parameters:
        metricName - metric name
        Returns:
        timer metric
      • timer

        public final com.codahale.metrics.Timer timer​(MetricName metricName,
                                                      java.util.function.Supplier<com.codahale.metrics.Timer> timerSupplier)
        Specified by:
        timer in interface TaggedMetricRegistry
      • getMetrics

        public final java.util.Map<MetricName,​com.codahale.metrics.Metric> getMetrics()
        Description copied from interface: TaggedMetricSet
        Returns a map of metrics.
        Specified by:
        getMetrics in interface TaggedMetricSet
        Returns:
        map of metrics
      • forEachMetric

        public final void forEachMetric​(java.util.function.BiConsumer<MetricName,​com.codahale.metrics.Metric> consumer)
        Specified by:
        forEachMetric in interface TaggedMetricSet
      • remove

        public final java.util.Optional<com.codahale.metrics.Metric> remove​(MetricName metricName)
        Description copied from interface: TaggedMetricRegistry
        Removes the tagged metric with the specified metric name.
        Specified by:
        remove in interface TaggedMetricRegistry
        Parameters:
        metricName - metric name
        Returns:
        the removed metric
      • addMetrics

        public final void addMetrics​(java.lang.String safeTagName,
                                     java.lang.String safeTagValue,
                                     TaggedMetricSet other)
        Description copied from interface: TaggedMetricRegistry
        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.

        Specified by:
        addMetrics in interface TaggedMetricRegistry
        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
        other - the metrics which should be added
      • removeMetrics

        public final boolean removeMetrics​(java.lang.String safeTagName,
                                           java.lang.String safeTagValue,
                                           TaggedMetricSet metrics)
        Description copied from interface: TaggedMetricRegistry
        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.

        Specified by:
        removeMetrics in interface TaggedMetricRegistry
        Returns:
        true if value was removed
      • getOrAdd

        protected final <T extends com.codahale.metrics.Metric> T getOrAdd​(MetricName metricName,
                                                                           java.lang.Class<T> metricClass,
                                                                           java.util.function.Supplier<T> metricSupplier)