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 moreMetricSinks.This class encapsulates the interaction with metric sinks, including updating them with the latest set of
MetricInstruments provided by theMetricInstrumentRegistry.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classMetricRecorderImpl.BatchRecorderImplRecorder 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>metricSinksprivate MetricInstrumentRegistryregistry
-
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 voidaddDoubleCounter(DoubleCounterMetricInstrument metricInstrument, double value, java.util.List<java.lang.String> requiredLabelValues, java.util.List<java.lang.String> optionalLabelValues)Records a double counter value.voidaddLongCounter(LongCounterMetricInstrument metricInstrument, long value, java.util.List<java.lang.String> requiredLabelValues, java.util.List<java.lang.String> optionalLabelValues)Records a long counter value.voidrecordDoubleHistogram(DoubleHistogramMetricInstrument metricInstrument, double value, java.util.List<java.lang.String> requiredLabelValues, java.util.List<java.lang.String> optionalLabelValues)Records a double histogram value.voidrecordLongHistogram(LongHistogramMetricInstrument metricInstrument, long value, java.util.List<java.lang.String> requiredLabelValues, java.util.List<java.lang.String> optionalLabelValues)Records a long histogram value.MetricRecorder.RegistrationregisterBatchCallback(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:
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, java.util.List<java.lang.String> requiredLabelValues, java.util.List<java.lang.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, java.util.List<java.lang.String> requiredLabelValues, java.util.List<java.lang.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, java.util.List<java.lang.String> requiredLabelValues, java.util.List<java.lang.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.
-
-