• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

grpc / grpc-java / #19975

08 Sep 2025 09:55PM UTC coverage: 88.547% (+0.01%) from 88.535%
#19975

push

github

web-flow
otel: subchannel metrics A94 (#12202)

Implements [A94](https://github.com/grpc/proposal/pull/485/files) except for the exact reason for disconnect_error

34806 of 39308 relevant lines covered (88.55%)

0.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

57.14
/../api/src/main/java/io/grpc/MetricSink.java
1
/*
2
 * Copyright 2024 The gRPC Authors
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package io.grpc;
18

19
import java.util.List;
20
import java.util.Map;
21
import java.util.Set;
22

23
/**
24
 * An internal interface representing a receiver or aggregator of gRPC metrics data.
25
 */
26
@Internal
27
public interface MetricSink {
28

29
  /**
30
   * Returns a set of names for the metrics that are currently enabled or disabled.
31
   *
32
   * @return A set of enabled metric names.
33
   */
34
  Map<String, Boolean> getEnabledMetrics();
35

36
  /**
37
   * Returns a set of optional label names for metrics that the sink actually wants.
38
   *
39
   * @return A set of optional label names.
40
   */
41
  Set<String> getOptionalLabels();
42

43
  /**
44
   * Returns size of metric measures used to record metric values. These measures are created
45
   * based on registered metrics (via MetricInstrumentRegistry) and are ordered according to their
46
   * registration sequence.
47
   *
48
   * @return Size of metric measures.
49
   */
50
  int getMeasuresSize();
51

52
  /**
53
   * Adds a value for a double-precision counter associated with specified metric instrument.
54
   *
55
   * @param metricInstrument The counter metric instrument identifies metric measure to add.
56
   * @param value The value to record.
57
   * @param requiredLabelValues A list of required label values for the metric.
58
   * @param optionalLabelValues A list of additional, optional label values for the metric.
59
   */
60
  default void addDoubleCounter(DoubleCounterMetricInstrument metricInstrument, double value,
61
      List<String> requiredLabelValues, List<String> optionalLabelValues) {
62
  }
×
63

64
  /**
65
   * Adds a value for a long valued counter metric associated with specified metric instrument.
66
   *
67
   * @param metricInstrument The counter metric instrument identifies metric measure to add.
68
   * @param value The value to record. MUST be non-negative.
69
   * @param requiredLabelValues A list of required label values for the metric.
70
   * @param optionalLabelValues A list of additional, optional label values for the metric.
71
   */
72
  default void addLongCounter(LongCounterMetricInstrument metricInstrument, long value,
73
                              List<String> requiredLabelValues, List<String> optionalLabelValues) {
74
  }
1✔
75

76
  /**
77
   * Adds a value for a long valued up down counter metric associated with specified metric
78
   * instrument.
79
   *
80
   * @param metricInstrument    The counter metric instrument identifies metric measure to add.
81
   * @param value               The value to record. May be positive, negative or zero.
82
   * @param requiredLabelValues A list of required label values for the metric.
83
   * @param optionalLabelValues A list of additional, optional label values for the metric.
84
   */
85
  default void addLongUpDownCounter(LongUpDownCounterMetricInstrument metricInstrument, long value,
86
                                    List<String> requiredLabelValues,
87
                                    List<String> optionalLabelValues) {
88
  }
1✔
89

90
  /**
91
   * Records a value for a double-precision histogram metric associated with specified metric
92
   * instrument.
93
   *
94
   * @param metricInstrument The histogram metric instrument identifies metric measure to record.
95
   * @param value The value to record.
96
   * @param requiredLabelValues A list of required label values for the metric.
97
   * @param optionalLabelValues A list of additional, optional label values for the metric.
98
   */
99
  default void recordDoubleHistogram(DoubleHistogramMetricInstrument metricInstrument, double value,
100
      List<String> requiredLabelValues, List<String> optionalLabelValues) {
101
  }
1✔
102

103
  /**
104
   * Records a value for a long valued histogram metric associated with specified metric
105
   * instrument.
106
   *
107
   * @param metricInstrument The histogram metric instrument identifies metric measure to record.
108
   * @param value The value to record.
109
   * @param requiredLabelValues A list of required label values for the metric.
110
   * @param optionalLabelValues A list of additional, optional label values for the metric.
111
   */
112
  default void recordLongHistogram(LongHistogramMetricInstrument metricInstrument, long value,
113
      List<String> requiredLabelValues, List<String> optionalLabelValues) {
114
  }
×
115

116
  /**
117
   * Record a long gauge value.
118
   *
119
   * @param value The value to record.
120
   * @param requiredLabelValues A list of required label values for the metric.
121
   * @param optionalLabelValues A list of additional, optional label values for the metric.
122
   */
123
  default void recordLongGauge(LongGaugeMetricInstrument metricInstrument, long value,
124
      List<String> requiredLabelValues, List<String> optionalLabelValues){
125
  }
×
126

127
  /**
128
   * Registers a callback to produce metric values for only the listed instruments. The returned
129
   * registration must be closed when no longer needed, which will remove the callback.
130
   *
131
   * @param callback The callback to call to record.
132
   * @param metricInstruments The metric instruments the callback will record against.
133
   */
134
  default Registration registerBatchCallback(Runnable callback,
135
      CallbackMetricInstrument... metricInstruments) {
136
    return () -> { };
1✔
137
  }
138

139
  interface Registration extends MetricRecorder.Registration {}
140

141
  void updateMeasures(List<MetricInstrument> instruments);
142
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc