Class AbstractTaggedMetricRegistry
- java.lang.Object
-
- com.palantir.tritium.metrics.registry.AbstractTaggedMetricRegistry
-
- All Implemented Interfaces:
TaggedMetricRegistry,TaggedMetricSet
- Direct Known Subclasses:
DefaultTaggedMetricRegistry,SlidingWindowTaggedMetricRegistry
public abstract class AbstractTaggedMetricRegistry extends java.lang.Object implements TaggedMetricRegistry
-
-
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 voidaddMetrics(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.Countercounter(MetricName metricName)Returns existing or new counter metric for the specified metric name.com.codahale.metrics.Countercounter(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.ReservoircreateReservoir()Supplies reservoir instances for this registry.voidforEachMetric(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>
TgetOrAdd(MetricName metricName, java.lang.Class<T> metricClass, java.util.function.Supplier<T> metricSupplier)com.codahale.metrics.Histogramhistogram(MetricName metricName)Returns existing or new histogram metric for the specified metric name.com.codahale.metrics.Histogramhistogram(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.Metermeter(MetricName metricName)Returns existing or new meter metric for the specified metric name.com.codahale.metrics.Metermeter(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.voidregisterWithReplacement(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.booleanremoveMetrics(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.Timertimer(MetricName metricName)Returns existing or new timer metric for the specified metric name.com.codahale.metrics.Timertimer(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.
-
-
-
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:TaggedMetricRegistryReturns existing or new counter metric for the specified metric name.- Specified by:
counterin interfaceTaggedMetricRegistry- 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:
counterin interfaceTaggedMetricRegistry
-
gauge
public final <T> java.util.Optional<com.codahale.metrics.Gauge<T>> gauge(MetricName metricName)
Description copied from interface:TaggedMetricRegistryReturns existing gauge metric for the specified metric name or empty if none has been registered.- Specified by:
gaugein interfaceTaggedMetricRegistry- 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:TaggedMetricRegistryReturns existing or new gauge metric for the specified metric name.- Specified by:
gaugein interfaceTaggedMetricRegistry- Parameters:
metricName- metric namegauge- 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 useTaggedMetricRegistry.gauge(MetricName).
-
registerWithReplacement
public final void registerWithReplacement(MetricName metricName, com.codahale.metrics.Gauge<?> gauge)
Description copied from interface:TaggedMetricRegistryRegisters and returns the specified gauge, replacing any existing gauge with the specified metric name.- Specified by:
registerWithReplacementin interfaceTaggedMetricRegistry- Parameters:
metricName- metric namegauge- gauge
-
histogram
public final com.codahale.metrics.Histogram histogram(MetricName metricName)
Description copied from interface:TaggedMetricRegistryReturns existing or new histogram metric for the specified metric name.- Specified by:
histogramin interfaceTaggedMetricRegistry- 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:
histogramin interfaceTaggedMetricRegistry
-
meter
public final com.codahale.metrics.Meter meter(MetricName metricName)
Description copied from interface:TaggedMetricRegistryReturns existing or new meter metric for the specified metric name.- Specified by:
meterin interfaceTaggedMetricRegistry- 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:
meterin interfaceTaggedMetricRegistry
-
timer
public final com.codahale.metrics.Timer timer(MetricName metricName)
Description copied from interface:TaggedMetricRegistryReturns existing or new timer metric for the specified metric name.- Specified by:
timerin interfaceTaggedMetricRegistry- 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:
timerin interfaceTaggedMetricRegistry
-
getMetrics
public final java.util.Map<MetricName,com.codahale.metrics.Metric> getMetrics()
Description copied from interface:TaggedMetricSetReturns a map of metrics.- Specified by:
getMetricsin interfaceTaggedMetricSet- Returns:
- map of metrics
-
forEachMetric
public final void forEachMetric(java.util.function.BiConsumer<MetricName,com.codahale.metrics.Metric> consumer)
- Specified by:
forEachMetricin interfaceTaggedMetricSet
-
remove
public final java.util.Optional<com.codahale.metrics.Metric> remove(MetricName metricName)
Description copied from interface:TaggedMetricRegistryRemoves the tagged metric with the specified metric name.- Specified by:
removein interfaceTaggedMetricRegistry- 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:TaggedMetricRegistryAdds 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:
addMetricsin interfaceTaggedMetricRegistry- Parameters:
safeTagName- a tag key which should be added to all metrics in the metrics setsafeTagValue- a tag value which should be added to all metrics in the metrics setother- the metrics which should be added
-
removeMetrics
public final java.util.Optional<TaggedMetricSet> removeMetrics(java.lang.String safeTagName, java.lang.String safeTagValue)
Description copied from interface:TaggedMetricRegistryRemoves a TaggedMetricsSet added via addMetrics from this metrics set.- Specified by:
removeMetricsin interfaceTaggedMetricRegistry
-
removeMetrics
public final boolean removeMetrics(java.lang.String safeTagName, java.lang.String safeTagValue, TaggedMetricSet metrics)Description copied from interface:TaggedMetricRegistryRemoves 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:
removeMetricsin interfaceTaggedMetricRegistry- 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)
-
-