Package io.grpc.internal
Class MetricRecorderImpl
- java.lang.Object
-
- io.grpc.internal.MetricRecorderImpl
-
- All Implemented Interfaces:
MetricRecorder
final class MetricRecorderImpl extends java.lang.Object implements MetricRecorder
Provides a central point for gRPC components to record metric values. Metrics can be exported to monitoring systems by configuring one or moreMetricSink
s.This class encapsulates the interaction with metric sinks, including updating them with the latest set of
MetricInstrument
s provided by theMetricInstrumentRegistry
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
MetricRecorderImpl.BatchRecorderImpl
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
Fields Modifier and Type Field Description private java.util.List<MetricSink>
metricSinks
private MetricInstrumentRegistry
registry
-
Constructor Summary
Constructors Constructor Description MetricRecorderImpl(java.util.List<MetricSink> metricSinks, MetricInstrumentRegistry registry)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDoubleCounter(DoubleCounterMetricInstrument metricInstrument, double value, java.util.List<java.lang.String> requiredLabelValues, java.util.List<java.lang.String> optionalLabelValues)
Records a double counter value.void
addLongCounter(LongCounterMetricInstrument metricInstrument, long value, java.util.List<java.lang.String> requiredLabelValues, java.util.List<java.lang.String> optionalLabelValues)
Records a long counter value.void
recordDoubleHistogram(DoubleHistogramMetricInstrument metricInstrument, double value, java.util.List<java.lang.String> requiredLabelValues, java.util.List<java.lang.String> optionalLabelValues)
Records a double histogram value.void
recordLongHistogram(LongHistogramMetricInstrument metricInstrument, long value, java.util.List<java.lang.String> requiredLabelValues, java.util.List<java.lang.String> optionalLabelValues)
Records a long histogram value.MetricRecorder.Registration
registerBatchCallback(MetricRecorder.BatchCallback callback, CallbackMetricInstrument... metricInstruments)
Registers a callback to produce metric values for only the listed instruments.
-
-
-
Field Detail
-
metricSinks
private final java.util.List<MetricSink> metricSinks
-
registry
private final MetricInstrumentRegistry registry
-
-
Constructor Detail
-
MetricRecorderImpl
MetricRecorderImpl(java.util.List<MetricSink> metricSinks, MetricInstrumentRegistry registry)
-
-
Method Detail
-
addDoubleCounter
public void addDoubleCounter(DoubleCounterMetricInstrument metricInstrument, double value, java.util.List<java.lang.String> requiredLabelValues, java.util.List<java.lang.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, java.util.List<java.lang.String> requiredLabelValues, java.util.List<java.lang.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, java.util.List<java.lang.String> requiredLabelValues, java.util.List<java.lang.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, java.util.List<java.lang.String> requiredLabelValues, java.util.List<java.lang.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.
-
-