|
16 | 16 |
|
17 | 17 | package io.grpc; |
18 | 18 |
|
19 | | -import java.util.ArrayList; |
20 | 19 | import java.util.Arrays; |
21 | 20 | import java.util.Collections; |
22 | 21 | import java.util.List; |
23 | 22 |
|
24 | 23 | /** |
25 | 24 | * TCP Metrics defined to be shared across transport implementations. |
| 25 | + * These metrics and their definitions are specified in |
| 26 | + * <a href= |
| 27 | + * "https://github.com/grpc/proposal/blob/master/A80-tcp-metrics.md">gRFC |
| 28 | + * A80</a>. |
26 | 29 | */ |
27 | 30 | @Internal |
28 | 31 | public final class InternalTcpMetrics { |
29 | 32 |
|
30 | | - private InternalTcpMetrics() {} |
| 33 | + private InternalTcpMetrics() { |
| 34 | + } |
31 | 35 |
|
32 | 36 | private static final List<String> OPTIONAL_LABELS = Arrays.asList( |
33 | 37 | "network.local.address", |
34 | 38 | "network.local.port", |
35 | 39 | "network.peer.address", |
36 | 40 | "network.peer.port"); |
37 | 41 |
|
38 | | - public static final DoubleHistogramMetricInstrument MIN_RTT_INSTRUMENT = |
| 42 | + public static final DoubleHistogramMetricInstrument MIN_RTT_INSTRUMENT = |
39 | 43 | MetricInstrumentRegistry.getDefaultRegistry() |
40 | 44 | .registerDoubleHistogram( |
41 | | - "grpc.tcp.min_rtt", |
42 | | - "Minimum round-trip time of a TCP connection", |
43 | | - "s", |
44 | | - getMinRttBuckets(), |
45 | | - Collections.emptyList(), |
46 | | - OPTIONAL_LABELS, |
47 | | - false); |
| 45 | + "grpc.tcp.min_rtt", |
| 46 | + "Minimum round-trip time of a TCP connection", |
| 47 | + "s", |
| 48 | + Collections.emptyList(), |
| 49 | + Collections.emptyList(), |
| 50 | + OPTIONAL_LABELS, |
| 51 | + false); |
48 | 52 |
|
49 | | - public static final LongCounterMetricInstrument CONNECTIONS_CREATED_INSTRUMENT = |
| 53 | + public static final LongCounterMetricInstrument CONNECTIONS_CREATED_INSTRUMENT = |
50 | 54 | MetricInstrumentRegistry |
51 | | - .getDefaultRegistry() |
52 | | - .registerLongCounter( |
53 | | - "grpc.tcp.connections_created", |
54 | | - "The total number of TCP connections established.", |
55 | | - "{connection}", |
56 | | - Collections.emptyList(), |
57 | | - OPTIONAL_LABELS, |
58 | | - false); |
| 55 | + .getDefaultRegistry() |
| 56 | + .registerLongCounter( |
| 57 | + "grpc.tcp.connections_created", |
| 58 | + "The total number of TCP connections established.", |
| 59 | + "{connection}", |
| 60 | + Collections.emptyList(), |
| 61 | + OPTIONAL_LABELS, |
| 62 | + false); |
59 | 63 |
|
60 | | - public static final LongUpDownCounterMetricInstrument CONNECTION_COUNT_INSTRUMENT = |
| 64 | + public static final LongUpDownCounterMetricInstrument CONNECTION_COUNT_INSTRUMENT = |
61 | 65 | MetricInstrumentRegistry |
62 | | - .getDefaultRegistry() |
63 | | - .registerLongUpDownCounter( |
64 | | - "grpc.tcp.connection_count", |
65 | | - "The current number of active TCP connections.", |
66 | | - "{connection}", |
67 | | - Collections.emptyList(), |
68 | | - OPTIONAL_LABELS, |
69 | | - false |
70 | | - ); |
| 66 | + .getDefaultRegistry() |
| 67 | + .registerLongUpDownCounter( |
| 68 | + "grpc.tcp.connection_count", |
| 69 | + "The current number of active TCP connections.", |
| 70 | + "{connection}", |
| 71 | + Collections.emptyList(), |
| 72 | + OPTIONAL_LABELS, |
| 73 | + false); |
71 | 74 |
|
72 | | - public static final LongCounterMetricInstrument PACKETS_RETRANSMITTED_INSTRUMENT = |
| 75 | + public static final LongCounterMetricInstrument PACKETS_RETRANSMITTED_INSTRUMENT = |
73 | 76 | MetricInstrumentRegistry |
74 | | - .getDefaultRegistry() |
75 | | - .registerLongCounter( |
76 | | - "grpc.tcp.packets_retransmitted", |
77 | | - "The total number of packets retransmitted for all TCP connections.", |
78 | | - "{packet}", |
79 | | - Collections.emptyList(), |
80 | | - OPTIONAL_LABELS, |
81 | | - false |
82 | | - ); |
| 77 | + .getDefaultRegistry() |
| 78 | + .registerLongCounter( |
| 79 | + "grpc.tcp.packets_retransmitted", |
| 80 | + "The total number of packets retransmitted for all TCP connections.", |
| 81 | + "{packet}", |
| 82 | + Collections.emptyList(), |
| 83 | + OPTIONAL_LABELS, |
| 84 | + false); |
83 | 85 |
|
84 | | - public static final LongCounterMetricInstrument RECURRING_RETRANSMITS_INSTRUMENT = |
| 86 | + public static final LongCounterMetricInstrument RECURRING_RETRANSMITS_INSTRUMENT = |
85 | 87 | MetricInstrumentRegistry |
86 | | - .getDefaultRegistry() |
87 | | - .registerLongCounter( |
88 | | - "grpc.tcp.recurring_retransmits", |
89 | | - "The total number of times the retransmit timer popped for all TCP" |
90 | | - + " connections.", |
91 | | - "{timeout}", |
92 | | - Collections.emptyList(), |
93 | | - OPTIONAL_LABELS, |
94 | | - false |
95 | | - ); |
| 88 | + .getDefaultRegistry() |
| 89 | + .registerLongCounter( |
| 90 | + "grpc.tcp.recurring_retransmits", |
| 91 | + "The total number of times the retransmit timer " |
| 92 | + + "popped for all TCP connections.", |
| 93 | + "{timeout}", |
| 94 | + Collections.emptyList(), |
| 95 | + OPTIONAL_LABELS, |
| 96 | + false); |
96 | 97 |
|
97 | | - private static List<Double> getMinRttBuckets() { |
98 | | - List<Double> buckets = new ArrayList<>(100); |
99 | | - for (int i = 1; i <= 100; i++) { |
100 | | - buckets.add(1e-6 * Math.pow(2.0, i * 0.24)); |
101 | | - } |
102 | | - return Collections.unmodifiableList(buckets); |
103 | | - } |
104 | 98 | } |
0 commit comments