Package io.grpc
Class MetricInstrumentRegistry
- java.lang.Object
-
- io.grpc.MetricInstrumentRegistry
-
@Internal public final class MetricInstrumentRegistry extends java.lang.Object
A registry for globally registered metric instruments.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static intINITIAL_INSTRUMENT_CAPACITYprivate static MetricInstrumentRegistryinstanceprivate java.lang.Objectlockprivate MetricInstrument[]metricInstrumentsprivate intnextAvailableMetricIndexprivate java.util.Set<java.lang.String>registeredMetricNames
-
Constructor Summary
Constructors Constructor Description MetricInstrumentRegistry()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MetricInstrumentRegistrygetDefaultRegistry()Returns the default metric instrument registry.java.util.List<MetricInstrument>getMetricInstruments()Returns a list of registered metric instruments.DoubleCounterMetricInstrumentregisterDoubleCounter(java.lang.String name, java.lang.String description, java.lang.String unit, java.util.List<java.lang.String> requiredLabelKeys, java.util.List<java.lang.String> optionalLabelKeys, boolean enableByDefault)Registers a new Double Counter metric instrument.DoubleHistogramMetricInstrumentregisterDoubleHistogram(java.lang.String name, java.lang.String description, java.lang.String unit, java.util.List<java.lang.Double> bucketBoundaries, java.util.List<java.lang.String> requiredLabelKeys, java.util.List<java.lang.String> optionalLabelKeys, boolean enableByDefault)Registers a new Double Histogram metric instrument.LongCounterMetricInstrumentregisterLongCounter(java.lang.String name, java.lang.String description, java.lang.String unit, java.util.List<java.lang.String> requiredLabelKeys, java.util.List<java.lang.String> optionalLabelKeys, boolean enableByDefault)Registers a new Long Counter metric instrument.LongGaugeMetricInstrumentregisterLongGauge(java.lang.String name, java.lang.String description, java.lang.String unit, java.util.List<java.lang.String> requiredLabelKeys, java.util.List<java.lang.String> optionalLabelKeys, boolean enableByDefault)Registers a new Long Gauge metric instrument.LongHistogramMetricInstrumentregisterLongHistogram(java.lang.String name, java.lang.String description, java.lang.String unit, java.util.List<java.lang.Long> bucketBoundaries, java.util.List<java.lang.String> requiredLabelKeys, java.util.List<java.lang.String> optionalLabelKeys, boolean enableByDefault)Registers a new Long Histogram metric instrument.private voidresizeMetricInstruments()
-
-
-
Field Detail
-
INITIAL_INSTRUMENT_CAPACITY
static final int INITIAL_INSTRUMENT_CAPACITY
- See Also:
- Constant Field Values
-
instance
private static MetricInstrumentRegistry instance
-
lock
private final java.lang.Object lock
-
registeredMetricNames
private final java.util.Set<java.lang.String> registeredMetricNames
-
metricInstruments
private MetricInstrument[] metricInstruments
-
nextAvailableMetricIndex
private int nextAvailableMetricIndex
-
-
Method Detail
-
getDefaultRegistry
public static MetricInstrumentRegistry getDefaultRegistry()
Returns the default metric instrument registry.
-
getMetricInstruments
public java.util.List<MetricInstrument> getMetricInstruments()
Returns a list of registered metric instruments.
-
registerDoubleCounter
public DoubleCounterMetricInstrument registerDoubleCounter(java.lang.String name, java.lang.String description, java.lang.String unit, java.util.List<java.lang.String> requiredLabelKeys, java.util.List<java.lang.String> optionalLabelKeys, boolean enableByDefault)
Registers a new Double Counter metric instrument.- Parameters:
name- the name of the metricdescription- a description of the metricunit- the unit of measurement for the metricrequiredLabelKeys- a list of required label keysoptionalLabelKeys- a list of optional label keysenableByDefault- whether the metric should be enabled by default- Returns:
- the newly created DoubleCounterMetricInstrument
- Throws:
java.lang.IllegalStateException- if a metric with the same name already exists
-
registerLongCounter
public LongCounterMetricInstrument registerLongCounter(java.lang.String name, java.lang.String description, java.lang.String unit, java.util.List<java.lang.String> requiredLabelKeys, java.util.List<java.lang.String> optionalLabelKeys, boolean enableByDefault)
Registers a new Long Counter metric instrument.- Parameters:
name- the name of the metricdescription- a description of the metricunit- the unit of measurement for the metricrequiredLabelKeys- a list of required label keysoptionalLabelKeys- a list of optional label keysenableByDefault- whether the metric should be enabled by default- Returns:
- the newly created LongCounterMetricInstrument
- Throws:
java.lang.IllegalStateException- if a metric with the same name already exists
-
registerDoubleHistogram
public DoubleHistogramMetricInstrument registerDoubleHistogram(java.lang.String name, java.lang.String description, java.lang.String unit, java.util.List<java.lang.Double> bucketBoundaries, java.util.List<java.lang.String> requiredLabelKeys, java.util.List<java.lang.String> optionalLabelKeys, boolean enableByDefault)
Registers a new Double Histogram metric instrument.- Parameters:
name- the name of the metricdescription- a description of the metricunit- the unit of measurement for the metricbucketBoundaries- recommended set of explicit bucket boundaries for the histogramrequiredLabelKeys- a list of required label keysoptionalLabelKeys- a list of optional label keysenableByDefault- whether the metric should be enabled by default- Returns:
- the newly created DoubleHistogramMetricInstrument
- Throws:
java.lang.IllegalStateException- if a metric with the same name already exists
-
registerLongHistogram
public LongHistogramMetricInstrument registerLongHistogram(java.lang.String name, java.lang.String description, java.lang.String unit, java.util.List<java.lang.Long> bucketBoundaries, java.util.List<java.lang.String> requiredLabelKeys, java.util.List<java.lang.String> optionalLabelKeys, boolean enableByDefault)
Registers a new Long Histogram metric instrument.- Parameters:
name- the name of the metricdescription- a description of the metricunit- the unit of measurement for the metricbucketBoundaries- recommended set of explicit bucket boundaries for the histogramrequiredLabelKeys- a list of required label keysoptionalLabelKeys- a list of optional label keysenableByDefault- whether the metric should be enabled by default- Returns:
- the newly created LongHistogramMetricInstrument
- Throws:
java.lang.IllegalStateException- if a metric with the same name already exists
-
registerLongGauge
public LongGaugeMetricInstrument registerLongGauge(java.lang.String name, java.lang.String description, java.lang.String unit, java.util.List<java.lang.String> requiredLabelKeys, java.util.List<java.lang.String> optionalLabelKeys, boolean enableByDefault)
Registers a new Long Gauge metric instrument.- Parameters:
name- the name of the metricdescription- a description of the metricunit- the unit of measurement for the metricrequiredLabelKeys- a list of required label keysoptionalLabelKeys- a list of optional label keysenableByDefault- whether the metric should be enabled by default- Returns:
- the newly created LongGaugeMetricInstrument
- Throws:
java.lang.IllegalStateException- if a metric with the same name already exists
-
resizeMetricInstruments
private void resizeMetricInstruments()
-
-