Interface TaggedMetricRegistry

All Superinterfaces:
TaggedMetricSet
All Known Implementing Classes:
AbstractTaggedMetricRegistry, DefaultTaggedMetricRegistry, SlidingWindowTaggedMetricRegistry

public interface TaggedMetricRegistry extends TaggedMetricSet
Similar to MetricRegistry but allows tagging of Metrics.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addMetrics(@Safe String safeTagName, @Safe 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, Supplier<com.codahale.metrics.Counter> counterSupplier)
     
    default <T> 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, 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, 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.
    Optional<com.codahale.metrics.Metric>
    remove(MetricName metricName)
    Removes the tagged metric with the specified metric name.
    removeMetrics(@Safe String safeTagName, @Safe String safeTagValue)
    Removes a TaggedMetricsSet added via addMetrics from this metrics set.
    boolean
    removeMetrics(@Safe String safeTagName, @Safe 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, Supplier<com.codahale.metrics.Timer> timerSupplier)
     

    Methods inherited from interface TaggedMetricSet

    forEachMetric, getMetrics
  • Method Details

    • 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, 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, 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, Supplier<com.codahale.metrics.Histogram> histogramSupplier)
    • gauge

      default <T> 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
      ImplNote:
      Implementations should override this method with a more efficient mechanism.
    • 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, Supplier<com.codahale.metrics.Counter> counterSupplier)
    • remove

      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(@Safe @Safe String safeTagName, @Safe @Safe 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

      Optional<TaggedMetricSet> removeMetrics(@Safe @Safe String safeTagName, @Safe @Safe String safeTagValue)
      Removes a TaggedMetricsSet added via addMetrics from this metrics set.
    • removeMetrics

      boolean removeMetrics(@Safe @Safe String safeTagName, @Safe @Safe 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(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