Package io.grpc.internal
Class MetricRecorderImpl
java.lang.Object
io.grpc.internal.MetricRecorderImpl
- All Implemented Interfaces:
MetricRecorder
Provides a central point for gRPC components to record metric values. Metrics can be exported to
monitoring systems by configuring one or more
MetricSinks.
This class encapsulates the interaction with metric sinks, including updating them with
the latest set of MetricInstruments provided by the MetricInstrumentRegistry.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classRecorder for instrument values produced by a batch callback.Nested classes/interfaces inherited from interface io.grpc.MetricRecorder
MetricRecorder.BatchCallback, MetricRecorder.BatchRecorder, MetricRecorder.Registration -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<MetricSink> private final MetricInstrumentRegistry -
Constructor Summary
ConstructorsConstructorDescriptionMetricRecorderImpl(List<MetricSink> metricSinks, MetricInstrumentRegistry registry) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDoubleCounter(DoubleCounterMetricInstrument metricInstrument, double value, List<String> requiredLabelValues, List<String> optionalLabelValues) Records a double counter value.voidaddLongCounter(LongCounterMetricInstrument metricInstrument, long value, List<String> requiredLabelValues, List<String> optionalLabelValues) Records a long counter value.voidrecordDoubleHistogram(DoubleHistogramMetricInstrument metricInstrument, double value, List<String> requiredLabelValues, List<String> optionalLabelValues) Records a double histogram value.voidrecordLongHistogram(LongHistogramMetricInstrument metricInstrument, long value, List<String> requiredLabelValues, List<String> optionalLabelValues) Records a long histogram value.registerBatchCallback(MetricRecorder.BatchCallback callback, CallbackMetricInstrument... metricInstruments) Registers a callback to produce metric values for only the listed instruments.
-
Field Details
-
metricSinks
-
registry
-
-
Constructor Details
-
MetricRecorderImpl
MetricRecorderImpl(List<MetricSink> metricSinks, MetricInstrumentRegistry registry)
-
-
Method Details
-
addDoubleCounter
public void addDoubleCounter(DoubleCounterMetricInstrument metricInstrument, double value, List<String> requiredLabelValues, List<String> optionalLabelValues) Records a double counter value.- Specified by:
addDoubleCounterin interfaceMetricRecorder- Parameters:
metricInstrument- theDoubleCounterMetricInstrumentto record.value- the value to record.requiredLabelValues- the required label values for the metric.optionalLabelValues- the optional label values for the metric.
-
addLongCounter
public void addLongCounter(LongCounterMetricInstrument metricInstrument, long value, List<String> requiredLabelValues, List<String> optionalLabelValues) Records a long counter value.- Specified by:
addLongCounterin interfaceMetricRecorder- Parameters:
metricInstrument- theLongCounterMetricInstrumentto record.value- the value to record.requiredLabelValues- the required label values for the metric.optionalLabelValues- the optional label values for the metric.
-
recordDoubleHistogram
public void recordDoubleHistogram(DoubleHistogramMetricInstrument metricInstrument, double value, List<String> requiredLabelValues, List<String> optionalLabelValues) Records a double histogram value.- Specified by:
recordDoubleHistogramin interfaceMetricRecorder- Parameters:
metricInstrument- theDoubleHistogramMetricInstrumentto record.value- the value to record.requiredLabelValues- the required label values for the metric.optionalLabelValues- the optional label values for the metric.
-
recordLongHistogram
public void recordLongHistogram(LongHistogramMetricInstrument metricInstrument, long value, List<String> requiredLabelValues, List<String> optionalLabelValues) Records a long histogram value.- Specified by:
recordLongHistogramin interfaceMetricRecorder- Parameters:
metricInstrument- theLongHistogramMetricInstrumentto record.value- the value to record.requiredLabelValues- the required label values for the metric.optionalLabelValues- the optional label values for the metric.
-
registerBatchCallback
public MetricRecorder.Registration registerBatchCallback(MetricRecorder.BatchCallback callback, CallbackMetricInstrument... metricInstruments) Description copied from interface:MetricRecorderRegisters a callback to produce metric values for only the listed instruments. The returned registration must be closed when no longer needed, which will remove the callback.- Specified by:
registerBatchCallbackin interfaceMetricRecorder- Parameters:
callback- The callback to call to record.metricInstruments- The metric instruments the callback will record against.
-