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

grpc / grpc-java / #19177

26 Apr 2024 08:47PM UTC coverage: 88.288% (+0.2%) from 88.068%
#19177

push

github

web-flow
Add MetricRecorder implementation (#11128)

* added MetricRecorderImpl and unit tests for MetricInstrumentRegistry

* updated MetricInstrumentRegistry to use array instead of ArrayList

* renamed record<>Counter APIs to add<>Counter. Added check for mismatched label values

* added lock for instruments array

31381 of 35544 relevant lines covered (88.29%)

0.88 hits per line

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

0.0
/../api/src/main/java/io/grpc/MetricRecorder.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

21
/**
22
 * An interface used for recording gRPC metrics. Implementations of this interface are responsible
23
 * for collecting and potentially reporting metrics from various gRPC components.
24
 */
25
@Internal
26
public interface MetricRecorder {
27
  /**
28
   * Adds a value for a double-precision counter metric instrument.
29
   *
30
   * @param metricInstrument The counter metric instrument to add the value against.
31
   * @param value The value to add.
32
   * @param requiredLabelValues A list of required label values for the metric.
33
   * @param optionalLabelValues A list of additional, optional label values for the metric.
34
   */
35
  default void addDoubleCounter(DoubleCounterMetricInstrument metricInstrument, double value,
36
      List<String> requiredLabelValues, List<String> optionalLabelValues) {}
×
37

38
  /**
39
   * Adds a value for a long valued counter metric instrument.
40
   *
41
   * @param metricInstrument The counter metric instrument to add the value against.
42
   * @param value The value to add.
43
   * @param requiredLabelValues A list of required label values for the metric.
44
   * @param optionalLabelValues A list of additional, optional label values for the metric.
45
   */
46
  default void addLongCounter(LongCounterMetricInstrument metricInstrument, long value,
47
      List<String> requiredLabelValues, List<String> optionalLabelValues) {}
×
48

49
  /**
50
   * Records a value for a double-precision histogram metric instrument.
51
   *
52
   * @param metricInstrument The histogram metric instrument to record the value against.
53
   * @param value The value to record.
54
   * @param requiredLabelValues A list of required label values for the metric.
55
   * @param optionalLabelValues A list of additional, optional label values for the metric.
56
   */
57
  default void recordDoubleHistogram(DoubleHistogramMetricInstrument metricInstrument, double value,
58
      List<String> requiredLabelValues, List<String> optionalLabelValues) {}
×
59

60
  /**
61
   * Records a value for a long valued histogram metric instrument.
62
   *
63
   * @param metricInstrument The histogram metric instrument to record the value against.
64
   * @param value The value to record.
65
   * @param requiredLabelValues A list of required label values for the metric.
66
   * @param optionalLabelValues A list of additional, optional label values for the metric.
67
   */
68
  default void recordLongHistogram(LongHistogramMetricInstrument metricInstrument, long value,
69
      List<String> requiredLabelValues, List<String> optionalLabelValues) {}
×
70
}
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