Package io.grpc

Class MetricInstrumentRegistry


  • @Internal
    public final class MetricInstrumentRegistry
    extends java.lang.Object
    A registry for globally registered metric instruments.
    • Field Detail

      • INITIAL_INSTRUMENT_CAPACITY

        static final int INITIAL_INSTRUMENT_CAPACITY
        See Also:
        Constant Field Values
      • lock

        private final java.lang.Object lock
      • registeredMetricNames

        private final java.util.Set<java.lang.String> registeredMetricNames
      • nextAvailableMetricIndex

        private int nextAvailableMetricIndex
    • Constructor Detail

      • MetricInstrumentRegistry

        MetricInstrumentRegistry()
    • 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 metric
        description - a description of the metric
        unit - the unit of measurement for the metric
        requiredLabelKeys - a list of required label keys
        optionalLabelKeys - a list of optional label keys
        enableByDefault - 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 metric
        description - a description of the metric
        unit - the unit of measurement for the metric
        requiredLabelKeys - a list of required label keys
        optionalLabelKeys - a list of optional label keys
        enableByDefault - 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 metric
        description - a description of the metric
        unit - the unit of measurement for the metric
        bucketBoundaries - recommended set of explicit bucket boundaries for the histogram
        requiredLabelKeys - a list of required label keys
        optionalLabelKeys - a list of optional label keys
        enableByDefault - 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 metric
        description - a description of the metric
        unit - the unit of measurement for the metric
        bucketBoundaries - recommended set of explicit bucket boundaries for the histogram
        requiredLabelKeys - a list of required label keys
        optionalLabelKeys - a list of optional label keys
        enableByDefault - 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 metric
        description - a description of the metric
        unit - the unit of measurement for the metric
        requiredLabelKeys - a list of required label keys
        optionalLabelKeys - a list of optional label keys
        enableByDefault - 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()