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
MetricSink
s.
This class encapsulates the interaction with metric sinks, including updating them with
the latest set of MetricInstrument
s provided by the MetricInstrumentRegistry
.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
Recorder 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 TypeMethodDescriptionvoid
addDoubleCounter
(DoubleCounterMetricInstrument metricInstrument, double value, List<String> requiredLabelValues, List<String> optionalLabelValues) Records a double counter value.void
addLongCounter
(LongCounterMetricInstrument metricInstrument, long value, List<String> requiredLabelValues, List<String> optionalLabelValues) Records a long counter value.void
recordDoubleHistogram
(DoubleHistogramMetricInstrument metricInstrument, double value, List<String> requiredLabelValues, List<String> optionalLabelValues) Records a double histogram value.void
recordLongHistogram
(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:
addDoubleCounter
in interfaceMetricRecorder
- Parameters:
metricInstrument
- theDoubleCounterMetricInstrument
to 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:
addLongCounter
in interfaceMetricRecorder
- Parameters:
metricInstrument
- theLongCounterMetricInstrument
to 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:
recordDoubleHistogram
in interfaceMetricRecorder
- Parameters:
metricInstrument
- theDoubleHistogramMetricInstrument
to 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:
recordLongHistogram
in interfaceMetricRecorder
- Parameters:
metricInstrument
- theLongHistogramMetricInstrument
to 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:MetricRecorder
Registers 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:
registerBatchCallback
in interfaceMetricRecorder
- Parameters:
callback
- The callback to call to record.metricInstruments
- The metric instruments the callback will record against.
-