MetricRegistryService

public interface MetricRegistryService

Represents a registry that creates and/or retrieves a variety of metric types and allows registered metrics to be enabled or disabled.

Methods

counter

Counter counter(String name)

Get the counter associated with the given name.

Parameters:
  • name – the name of the counter
Returns:

the counter associated with the given name

histogram

Histogram histogram(String name)

Get the histogram associated with the given name.

Parameters:
  • name – the name of the histogram
Returns:

the histogram associated with the given name

isRegistered

boolean isRegistered(String name)

Returns whether a metric is registered or not by the given metric name.

Parameters:
  • name – the name of the metric
Returns:

true if registered, false otherwise

meter

Meter meter(String name)

Get the meter associated with the given name.

Parameters:
  • name – the name of the meter
Returns:

the meter associated with the given name

registerGauge

<T> Gauge<T> registerGauge(String name, Gauge<T> gauge)

Register an implementation of the gauge interface.

Parameters:
  • name – the name of the gauge
  • gauge – the implementation of the gauge interface
  • <T> – the type of the gauge’s return value
Returns:

the registered gauge

registerRatioGauge

<T extends Number> Gauge<Double> registerRatioGauge(String name, Supplier<T> numerator, Supplier<T> denominator)

Register a ratio gauge.

Parameters:
  • name – the name of the gauge
  • numerator – a function returning a number represents the value of the numerator
  • denominator – a function returning a number that represents the value of the denominator
  • <T> – a type of number
Returns:

the registered gauge

setEnabled

void setEnabled(boolean enabled)

Sets all registered metrics to enabled or disabled depending on the value of the enabled parameter.

Parameters:
  • enabled – If true, sets all metrics to enabled; sets all metrics to disabled otherwise.

timer

Timer timer(String name)

Get the timer associated with the given name.

Parameters:
  • name – the name of the meter
Returns:

the meter associated with the given name