Class AbstractTaggedMetricRegistry
- All Implemented Interfaces:
TaggedMetricRegistry, TaggedMetricSet
- Direct Known Subclasses:
DefaultTaggedMetricRegistry, SlidingWindowTaggedMetricRegistry
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractTaggedMetricRegistry(Supplier<com.codahale.metrics.Reservoir> reservoirSupplier) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddMetrics(String safeTagName, 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.final com.codahale.metrics.Countercounter(MetricName metricName) Returns existing or new counter metric for the specified metric name.final com.codahale.metrics.Countercounter(MetricName metricName, Supplier<com.codahale.metrics.Counter> counterSupplier) protected @NonNull Supplier<com.codahale.metrics.Counter> Supplies counter instances for this registry.protected final @NonNull com.codahale.metrics.ReservoirSupplies reservoir instances for this registry.final voidforEachMetric(BiConsumer<MetricName, com.codahale.metrics.Metric> consumer) final <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.final <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.final Map<MetricName, com.codahale.metrics.Metric> Returns a map of metrics.protected final <T extends com.codahale.metrics.Metric>
TgetOrAdd(MetricName metricName, Class<T> metricClass, Supplier<T> metricSupplier) final com.codahale.metrics.Histogramhistogram(MetricName metricName) Returns existing or new histogram metric for the specified metric name.final com.codahale.metrics.Histogramhistogram(MetricName metricName, Supplier<com.codahale.metrics.Histogram> histogramSupplier) protected @NonNull Supplier<com.codahale.metrics.Histogram> Supplies histogram instances for this registry.final com.codahale.metrics.Metermeter(MetricName metricName) Returns existing or new meter metric for the specified metric name.final com.codahale.metrics.Metermeter(MetricName metricName, Supplier<com.codahale.metrics.Meter> meterSupplier) protected @NonNull Supplier<com.codahale.metrics.Meter> Supplies meter instances for this registry.final voidregisterWithReplacement(MetricName metricName, com.codahale.metrics.Gauge<?> gauge) Registers and returns the specified gauge, replacing any existing gauge with the specified metric name.final Optional<com.codahale.metrics.Metric> remove(MetricName metricName) Removes the tagged metric with the specified metric name.final Optional<TaggedMetricSet> removeMetrics(String safeTagName, String safeTagValue) Removes a TaggedMetricsSet added via addMetrics from this metrics set.final booleanremoveMetrics(String safeTagName, String safeTagValue, TaggedMetricSet metrics) Removes a TaggedMetricsSet added via addMetrics from this metrics set, if currently registered to this metric set.final com.codahale.metrics.Timertimer(MetricName metricName) Returns existing or new timer metric for the specified metric name.final com.codahale.metrics.Timertimer(MetricName metricName, Supplier<com.codahale.metrics.Timer> timerSupplier) protected @NonNull Supplier<com.codahale.metrics.Timer> Supplies timer instances for this registry.
-
Constructor Details
-
AbstractTaggedMetricRegistry
-
-
Method Details
-
counterSupplier
Supplies counter instances for this registry.- Returns:
- counter supplier
-
histogramSupplier
Supplies histogram instances for this registry.- Returns:
- histogram supplier
-
meterSupplier
Supplies meter instances for this registry.- Returns:
- meter supplier
-
timerSupplier
Supplies timer instances for this registry.- Returns:
- timer supplier
-
createReservoir
protected final @NonNull com.codahale.metrics.Reservoir createReservoir()Supplies reservoir instances for this registry.- Returns:
- reservoir supplier
-
counter
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, Supplier<com.codahale.metrics.Counter> counterSupplier) - Specified by:
counterin interfaceTaggedMetricRegistry
-
gauge
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
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, Supplier<com.codahale.metrics.Histogram> histogramSupplier) - Specified by:
histogramin interfaceTaggedMetricRegistry
-
meter
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, Supplier<com.codahale.metrics.Meter> meterSupplier) - Specified by:
meterin interfaceTaggedMetricRegistry
-
timer
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, Supplier<com.codahale.metrics.Timer> timerSupplier) - Specified by:
timerin interfaceTaggedMetricRegistry
-
getMetrics
Description copied from interface:TaggedMetricSetReturns a map of metrics.- Specified by:
getMetricsin interfaceTaggedMetricSet- Returns:
- map of metrics
-
forEachMetric
- Specified by:
forEachMetricin interfaceTaggedMetricSet
-
remove
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
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
Description copied from interface:TaggedMetricRegistryRemoves a TaggedMetricsSet added via addMetrics from this metrics set.- Specified by:
removeMetricsin interfaceTaggedMetricRegistry
-
removeMetrics
public final boolean removeMetrics(String safeTagName, 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(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, Class<T> metricClass, Supplier<T> metricSupplier)
-