This repository has been archived by the owner on Dec 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 199
/
RpcMeasureConstants.java
586 lines (524 loc) · 18.4 KB
/
RpcMeasureConstants.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
/*
* Copyright 2017, OpenCensus Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.opencensus.contrib.grpc.metrics;
import io.opencensus.stats.Measure;
import io.opencensus.stats.Measure.MeasureDouble;
import io.opencensus.stats.Measure.MeasureLong;
import io.opencensus.tags.TagKey;
/**
* Constants for collecting rpc stats.
*
* @since 0.8
*/
public final class RpcMeasureConstants {
/**
* Tag key that represents a gRPC canonical status. Refer to
* https://github.com/grpc/grpc/blob/master/doc/statuscodes.md.
*
* @since 0.8
* @deprecated in favor of {@link #GRPC_CLIENT_STATUS} and {@link #GRPC_SERVER_STATUS}.
*/
@Deprecated public static final TagKey RPC_STATUS = TagKey.create("canonical_status");
/**
* Tag key that represents a gRPC method.
*
* @since 0.8
* @deprecated in favor of {@link #GRPC_CLIENT_METHOD} and {@link #GRPC_SERVER_METHOD}.
*/
@Deprecated public static final TagKey RPC_METHOD = TagKey.create("method");
/**
* Tag key that represents a client gRPC canonical status. Refer to
* https://github.com/grpc/grpc/blob/master/doc/statuscodes.md.
*
* <p>{@link #GRPC_CLIENT_STATUS} is set when an outgoing request finishes and is only available
* around metrics recorded at the end of the outgoing request.
*
* @since 0.13
*/
public static final TagKey GRPC_CLIENT_STATUS = TagKey.create("grpc_client_status");
/**
* Tag key that represents a server gRPC canonical status. Refer to
* https://github.com/grpc/grpc/blob/master/doc/statuscodes.md.
*
* <p>{@link #GRPC_SERVER_STATUS} is set when an incoming request finishes and is only available
* around metrics recorded at the end of the incoming request.
*
* @since 0.13
*/
public static final TagKey GRPC_SERVER_STATUS = TagKey.create("grpc_server_status");
/**
* Tag key that represents a client gRPC method.
*
* <p>{@link #GRPC_CLIENT_METHOD} is set when an outgoing request starts and is available in all
* the recorded metrics.
*
* @since 0.13
*/
public static final TagKey GRPC_CLIENT_METHOD = TagKey.create("grpc_client_method");
/**
* Tag key that represents a server gRPC method.
*
* <p>{@link #GRPC_SERVER_METHOD} is set when an incoming request starts and is available in the
* context for the entire RPC call handling.
*
* @since 0.13
*/
public static final TagKey GRPC_SERVER_METHOD = TagKey.create("grpc_server_method");
// Constants used to define the following Measures.
/**
* Unit string for byte.
*
* @since 0.8
*/
private static final String BYTE = "By";
/**
* Unit string for count.
*
* @since 0.8
*/
private static final String COUNT = "1";
/**
* Unit string for millisecond.
*
* @since 0.8
*/
private static final String MILLISECOND = "ms";
// RPC client Measures.
/**
* {@link Measure} for total bytes sent across all request messages per RPC.
*
* @since 0.13
*/
public static final MeasureDouble GRPC_CLIENT_SENT_BYTES_PER_RPC =
Measure.MeasureDouble.create(
"grpc.io/client/sent_bytes_per_rpc",
"Total bytes sent across all request messages per RPC",
BYTE);
/**
* {@link Measure} for total bytes received across all response messages per RPC.
*
* @since 0.13
*/
public static final MeasureDouble GRPC_CLIENT_RECEIVED_BYTES_PER_RPC =
Measure.MeasureDouble.create(
"grpc.io/client/received_bytes_per_rpc",
"Total bytes received across all response messages per RPC",
BYTE);
/**
* {@link Measure} for total bytes sent per method, recorded real-time as bytes are sent.
*
* @since 0.18
*/
public static final MeasureDouble GRPC_CLIENT_SENT_BYTES_PER_METHOD =
Measure.MeasureDouble.create(
"grpc.io/client/sent_bytes_per_method",
"Total bytes sent per method, recorded real-time as bytes are sent.",
BYTE);
/**
* {@link Measure} for total bytes received per method, recorded real-time as bytes are received.
*
* @since 0.18
*/
public static final MeasureDouble GRPC_CLIENT_RECEIVED_BYTES_PER_METHOD =
Measure.MeasureDouble.create(
"grpc.io/client/received_bytes_per_method",
"Total bytes received per method, recorded real-time as bytes are received.",
BYTE);
/**
* {@link Measure} for total client sent messages.
*
* @since 0.18
*/
public static final MeasureLong GRPC_CLIENT_SENT_MESSAGES_PER_METHOD =
Measure.MeasureLong.create(
"grpc.io/client/sent_messages_per_method", "Total messages sent per method.", COUNT);
/**
* {@link Measure} for total client received messages.
*
* @since 0.18
*/
public static final MeasureLong GRPC_CLIENT_RECEIVED_MESSAGES_PER_METHOD =
Measure.MeasureLong.create(
"grpc.io/client/received_messages_per_method",
"Total messages received per method.",
COUNT);
/**
* {@link Measure} for gRPC client roundtrip latency in milliseconds.
*
* @since 0.13
*/
public static final MeasureDouble GRPC_CLIENT_ROUNDTRIP_LATENCY =
Measure.MeasureDouble.create(
"grpc.io/client/roundtrip_latency",
"Time between first byte of request sent to last byte of response received, "
+ "or terminal error.",
MILLISECOND);
/**
* {@link Measure} for number of messages sent in the RPC.
*
* @since 0.13
*/
public static final MeasureLong GRPC_CLIENT_SENT_MESSAGES_PER_RPC =
Measure.MeasureLong.create(
"grpc.io/client/sent_messages_per_rpc", "Number of messages sent in the RPC", COUNT);
/**
* {@link Measure} for number of response messages received per RPC.
*
* @since 0.13
*/
public static final MeasureLong GRPC_CLIENT_RECEIVED_MESSAGES_PER_RPC =
Measure.MeasureLong.create(
"grpc.io/client/received_messages_per_rpc",
"Number of response messages received per RPC",
COUNT);
/**
* {@link Measure} for gRPC server latency in milliseconds.
*
* @since 0.13
*/
public static final MeasureDouble GRPC_CLIENT_SERVER_LATENCY =
Measure.MeasureDouble.create(
"grpc.io/client/server_latency", "Server latency in msecs", MILLISECOND);
/**
* {@link Measure} for total number of client RPCs ever opened, including those that have not
* completed.
*
* @since 0.14
*/
public static final MeasureLong GRPC_CLIENT_STARTED_RPCS =
Measure.MeasureLong.create(
"grpc.io/client/started_rpcs", "Number of started client RPCs.", COUNT);
/**
* {@link Measure} for total number of retry or hedging attempts excluding transparent retries
* made during the client call.
*
* @since 0.31.0
*/
public static final MeasureLong GRPC_CLIENT_RETRIES_PER_CALL =
Measure.MeasureLong.create(
"grpc.io/client/retries_per_call", "Number of retries per call.", COUNT);
/**
* {@link Measure} for total number of transparent retries made during the client call.
*
* @since 0.28
*/
public static final MeasureLong GRPC_CLIENT_TRANSPARENT_RETRIES_PER_CALL =
Measure.MeasureLong.create(
"grpc.io/client/transparent_retries_per_call",
"Number of transparent retries per call.",
COUNT);
/**
* {@link Measure} for total time of delay while there is no active attempt during the client
* call.
*
* @since 0.28
*/
public static final MeasureLong GRPC_CLIENT_RETRY_DELAY_PER_CALL =
Measure.MeasureLong.create(
"grpc.io/client/retry_delay_per_call", "Retry delay per call.", MILLISECOND);
/**
* {@link Measure} for gRPC client error counts.
*
* @since 0.8
* @deprecated because error counts can be computed on your metrics backend by totalling the
* different per-status values.
*/
@Deprecated
public static final MeasureLong RPC_CLIENT_ERROR_COUNT =
Measure.MeasureLong.create("grpc.io/client/error_count", "RPC Errors", COUNT);
/**
* {@link Measure} for gRPC client request bytes.
*
* @since 0.8
* @deprecated in favor of {@link #GRPC_CLIENT_SENT_BYTES_PER_RPC}.
*/
@Deprecated
public static final MeasureDouble RPC_CLIENT_REQUEST_BYTES = GRPC_CLIENT_SENT_BYTES_PER_RPC;
/**
* {@link Measure} for gRPC client response bytes.
*
* @since 0.8
* @deprecated in favor of {@link #GRPC_CLIENT_RECEIVED_BYTES_PER_RPC}.
*/
@Deprecated
public static final MeasureDouble RPC_CLIENT_RESPONSE_BYTES = GRPC_CLIENT_RECEIVED_BYTES_PER_RPC;
/**
* {@link Measure} for gRPC client roundtrip latency in milliseconds.
*
* @since 0.8
* @deprecated in favor of {@link #GRPC_CLIENT_ROUNDTRIP_LATENCY}.
*/
@Deprecated
public static final MeasureDouble RPC_CLIENT_ROUNDTRIP_LATENCY = GRPC_CLIENT_ROUNDTRIP_LATENCY;
/**
* {@link Measure} for gRPC client server elapsed time in milliseconds.
*
* @since 0.8
* @deprecated in favor of {@link #GRPC_CLIENT_SERVER_LATENCY}.
*/
@Deprecated
public static final MeasureDouble RPC_CLIENT_SERVER_ELAPSED_TIME = GRPC_CLIENT_SERVER_LATENCY;
/**
* {@link Measure} for gRPC client uncompressed request bytes.
*
* @since 0.8
* @deprecated in favor of {@link #GRPC_CLIENT_SENT_BYTES_PER_RPC}.
*/
@Deprecated
public static final MeasureDouble RPC_CLIENT_UNCOMPRESSED_REQUEST_BYTES =
Measure.MeasureDouble.create(
"grpc.io/client/uncompressed_request_bytes", "Uncompressed Request bytes", BYTE);
/**
* {@link Measure} for gRPC client uncompressed response bytes.
*
* @since 0.8
* @deprecated in favor of {@link #GRPC_CLIENT_RECEIVED_BYTES_PER_RPC}.
*/
@Deprecated
public static final MeasureDouble RPC_CLIENT_UNCOMPRESSED_RESPONSE_BYTES =
Measure.MeasureDouble.create(
"grpc.io/client/uncompressed_response_bytes", "Uncompressed Response bytes", BYTE);
/**
* {@link Measure} for number of started client RPCs.
*
* @since 0.8
* @deprecated in favor of {@link #GRPC_CLIENT_STARTED_RPCS}.
*/
@Deprecated public static final MeasureLong RPC_CLIENT_STARTED_COUNT = GRPC_CLIENT_STARTED_RPCS;
/**
* {@link Measure} for number of finished client RPCs.
*
* @since 0.8
* @deprecated since finished count can be inferred with a {@code Count} aggregation on {@link
* #GRPC_CLIENT_SERVER_LATENCY}.
*/
@Deprecated
public static final MeasureLong RPC_CLIENT_FINISHED_COUNT =
Measure.MeasureLong.create(
"grpc.io/client/finished_count", "Number of client RPCs (streams) finished", COUNT);
/**
* {@link Measure} for client RPC request message counts.
*
* @since 0.8
* @deprecated in favor of {@link #GRPC_CLIENT_SENT_MESSAGES_PER_RPC}.
*/
@Deprecated
public static final MeasureLong RPC_CLIENT_REQUEST_COUNT = GRPC_CLIENT_SENT_MESSAGES_PER_RPC;
/**
* {@link Measure} for client RPC response message counts.
*
* @deprecated in favor of {@link #GRPC_CLIENT_RECEIVED_MESSAGES_PER_RPC}.
* @since 0.8
*/
@Deprecated
public static final MeasureLong RPC_CLIENT_RESPONSE_COUNT = GRPC_CLIENT_RECEIVED_MESSAGES_PER_RPC;
// RPC server Measures.
/**
* {@link Measure} for total bytes sent across all response messages per RPC.
*
* @since 0.13
*/
public static final MeasureDouble GRPC_SERVER_SENT_BYTES_PER_RPC =
Measure.MeasureDouble.create(
"grpc.io/server/sent_bytes_per_rpc",
"Total bytes sent across all response messages per RPC",
BYTE);
/**
* {@link Measure} for total bytes received across all messages per RPC.
*
* @since 0.13
*/
public static final MeasureDouble GRPC_SERVER_RECEIVED_BYTES_PER_RPC =
Measure.MeasureDouble.create(
"grpc.io/server/received_bytes_per_rpc",
"Total bytes received across all messages per RPC",
BYTE);
/**
* {@link Measure} for total bytes sent per method, recorded real-time as bytes are sent.
*
* @since 0.18
*/
public static final MeasureDouble GRPC_SERVER_SENT_BYTES_PER_METHOD =
Measure.MeasureDouble.create(
"grpc.io/server/sent_bytes_per_method",
"Total bytes sent per method, recorded real-time as bytes are sent.",
BYTE);
/**
* {@link Measure} for total bytes received per method, recorded real-time as bytes are received.
*
* @since 0.18
*/
public static final MeasureDouble GRPC_SERVER_RECEIVED_BYTES_PER_METHOD =
Measure.MeasureDouble.create(
"grpc.io/server/received_bytes_per_method",
"Total bytes received per method, recorded real-time as bytes are received.",
BYTE);
/**
* {@link Measure} for total server sent messages.
*
* @since 0.18
*/
public static final MeasureLong GRPC_SERVER_SENT_MESSAGES_PER_METHOD =
Measure.MeasureLong.create(
"grpc.io/server/sent_messages_per_method", "Total messages sent per method.", COUNT);
/**
* {@link Measure} for total server received messages.
*
* @since 0.18
*/
public static final MeasureLong GRPC_SERVER_RECEIVED_MESSAGES_PER_METHOD =
Measure.MeasureLong.create(
"grpc.io/server/received_messages_per_method",
"Total messages received per method.",
COUNT);
/**
* {@link Measure} for number of messages sent in each RPC.
*
* @since 0.13
*/
public static final MeasureLong GRPC_SERVER_SENT_MESSAGES_PER_RPC =
Measure.MeasureLong.create(
"grpc.io/server/sent_messages_per_rpc", "Number of messages sent in each RPC", COUNT);
/**
* {@link Measure} for number of messages received in each RPC.
*
* @since 0.13
*/
public static final MeasureLong GRPC_SERVER_RECEIVED_MESSAGES_PER_RPC =
Measure.MeasureLong.create(
"grpc.io/server/received_messages_per_rpc",
"Number of messages received in each RPC",
COUNT);
/**
* {@link Measure} for gRPC server latency in milliseconds.
*
* @since 0.13
*/
public static final MeasureDouble GRPC_SERVER_SERVER_LATENCY =
Measure.MeasureDouble.create(
"grpc.io/server/server_latency",
"Time between first byte of request received to last byte of response sent, "
+ "or terminal error.",
MILLISECOND);
/**
* {@link Measure} for total number of server RPCs ever opened, including those that have not
* completed.
*
* @since 0.14
*/
public static final MeasureLong GRPC_SERVER_STARTED_RPCS =
Measure.MeasureLong.create(
"grpc.io/server/started_rpcs", "Number of started server RPCs.", COUNT);
/**
* {@link Measure} for gRPC server error counts.
*
* @since 0.8
* @deprecated because error counts can be computed on your metrics backend by totalling the
* different per-status values.
*/
@Deprecated
public static final MeasureLong RPC_SERVER_ERROR_COUNT =
Measure.MeasureLong.create("grpc.io/server/error_count", "RPC Errors", COUNT);
/**
* {@link Measure} for gRPC server request bytes.
*
* @since 0.8
* @deprecated in favor of {@link #GRPC_SERVER_RECEIVED_BYTES_PER_RPC}.
*/
@Deprecated
public static final MeasureDouble RPC_SERVER_REQUEST_BYTES = GRPC_SERVER_RECEIVED_BYTES_PER_RPC;
/**
* {@link Measure} for gRPC server response bytes.
*
* @since 0.8
* @deprecated in favor of {@link #GRPC_SERVER_SENT_BYTES_PER_RPC}.
*/
@Deprecated
public static final MeasureDouble RPC_SERVER_RESPONSE_BYTES = GRPC_SERVER_SENT_BYTES_PER_RPC;
/**
* {@link Measure} for gRPC server elapsed time in milliseconds.
*
* @since 0.8
* @deprecated in favor of {@link #GRPC_SERVER_SERVER_LATENCY}.
*/
@Deprecated
public static final MeasureDouble RPC_SERVER_SERVER_ELAPSED_TIME =
Measure.MeasureDouble.create(
"grpc.io/server/server_elapsed_time", "Server elapsed time in msecs", MILLISECOND);
/**
* {@link Measure} for gRPC server latency in milliseconds.
*
* @since 0.8
* @deprecated in favor of {@link #GRPC_SERVER_SERVER_LATENCY}.
*/
@Deprecated
public static final MeasureDouble RPC_SERVER_SERVER_LATENCY = GRPC_SERVER_SERVER_LATENCY;
/**
* {@link Measure} for gRPC server uncompressed request bytes.
*
* @since 0.8
* @deprecated in favor of {@link #GRPC_SERVER_RECEIVED_BYTES_PER_RPC}.
*/
@Deprecated
public static final MeasureDouble RPC_SERVER_UNCOMPRESSED_REQUEST_BYTES =
Measure.MeasureDouble.create(
"grpc.io/server/uncompressed_request_bytes", "Uncompressed Request bytes", BYTE);
/**
* {@link Measure} for gRPC server uncompressed response bytes.
*
* @since 0.8
* @deprecated in favor of {@link #GRPC_SERVER_SENT_BYTES_PER_RPC}.
*/
@Deprecated
public static final MeasureDouble RPC_SERVER_UNCOMPRESSED_RESPONSE_BYTES =
Measure.MeasureDouble.create(
"grpc.io/server/uncompressed_response_bytes", "Uncompressed Response bytes", BYTE);
/**
* {@link Measure} for number of started server RPCs.
*
* @since 0.8
* @deprecated in favor of {@link #GRPC_SERVER_STARTED_RPCS}.
*/
@Deprecated public static final MeasureLong RPC_SERVER_STARTED_COUNT = GRPC_SERVER_STARTED_RPCS;
/**
* {@link Measure} for number of finished server RPCs.
*
* @since 0.8
* @deprecated since finished count can be inferred with a {@code Count} aggregation on {@link
* #GRPC_SERVER_SERVER_LATENCY}.
*/
@Deprecated
public static final MeasureLong RPC_SERVER_FINISHED_COUNT =
Measure.MeasureLong.create(
"grpc.io/server/finished_count", "Number of server RPCs (streams) finished", COUNT);
/**
* {@link Measure} for server RPC request message counts.
*
* @since 0.8
* @deprecated in favor of {@link #GRPC_SERVER_RECEIVED_MESSAGES_PER_RPC}.
*/
@Deprecated
public static final MeasureLong RPC_SERVER_REQUEST_COUNT = GRPC_SERVER_RECEIVED_MESSAGES_PER_RPC;
/**
* {@link Measure} for server RPC response message counts.
*
* @since 0.8
* @deprecated in favor of {@link #GRPC_SERVER_SENT_MESSAGES_PER_RPC}.
*/
@Deprecated
public static final MeasureLong RPC_SERVER_RESPONSE_COUNT = GRPC_SERVER_SENT_MESSAGES_PER_RPC;
private RpcMeasureConstants() {}
}