14
14
* limitations under the License.
15
15
*/
16
16
17
- import { AggregationType , globalStats , MeasureUnit , View } from '@opencensus/core' ;
18
- import { DEFAULT_BYTES_DISTRIBUTION , DEFAULT_MESSAGE_COUNT_DISTRIBUTION , DEFAULT_MILLI_SECONDS_DISTRIBUTION } from './stats-common' ;
17
+ import { AggregationType , globalStats , Measure , MeasureUnit , View } from '@opencensus/core' ;
19
18
20
- /**
21
- * { @link Measure } for number of messages sent in the RPC.
22
- *
23
- */
24
- const GRPC_CLIENT_SENT_MESSAGES_PER_RPC = globalStats . createMeasureInt64 (
25
- 'grpc.io/client/sent_messages_per_rpc' , MeasureUnit . UNIT ,
26
- 'Number of messages sent in the RPC (always 1 for non-streaming RPCs).' ) ;
19
+ import { DEFAULT_BYTES_DISTRIBUTION , DEFAULT_MESSAGE_COUNT_DISTRIBUTION , DEFAULT_MILLI_SECONDS_DISTRIBUTION } from './common-distributions' ;
20
+
21
+ /** { @link Measure } for number of messages sent in the RPC. */
22
+ export const GRPC_CLIENT_SENT_MESSAGES_PER_RPC : Measure =
23
+ globalStats . createMeasureInt64 (
24
+ 'grpc.io/client/sent_messages_per_rpc' , MeasureUnit . UNIT ,
25
+ 'Number of messages sent in the RPC (always 1 for non-streaming RPCs).' ) ;
27
26
28
27
/**
29
28
* {@link Measure } for total bytes sent across all request messages per RPC.
30
- *
31
29
*/
32
- const GRPC_CLIENT_SENT_BYTES_PER_RPC = globalStats . createMeasureInt64 (
33
- 'grpc.io/client/sent_bytes_per_rpc' , MeasureUnit . BYTE ,
34
- 'Total bytes sent across all request messages per RPC.' ) ;
30
+ export const GRPC_CLIENT_SENT_BYTES_PER_RPC : Measure =
31
+ globalStats . createMeasureInt64 (
32
+ 'grpc.io/client/sent_bytes_per_rpc' , MeasureUnit . BYTE ,
33
+ 'Total bytes sent across all request messages per RPC.' ) ;
35
34
36
- /**
37
- * {@link Measure } for number of response messages received per RPC.
38
- *
39
- */
40
- const GRPC_CLIENT_RECEIVED_MESSAGES_PER_RPC = globalStats . createMeasureInt64 (
41
- 'grpc.io/client/received_messages_per_rpc' , MeasureUnit . UNIT ,
42
- 'Number of response messages received per RPC (always 1 for non-streaming RPCs).' ) ;
35
+ /** {@link Measure } for number of response messages received per RPC. */
36
+ export const GRPC_CLIENT_RECEIVED_MESSAGES_PER_RPC : Measure =
37
+ globalStats . createMeasureInt64 (
38
+ 'grpc.io/client/received_messages_per_rpc' , MeasureUnit . UNIT ,
39
+ 'Number of response messages received per RPC (always 1 for non-streaming RPCs).' ) ;
43
40
44
41
/**
45
42
* {@link Measure } for total bytes received across all response messages per RPC
46
- *
47
43
*/
48
- const GRPC_CLIENT_RECEIVED_BYTES_PER_RPC = globalStats . createMeasureInt64 (
49
- 'grpc.io/client/received_bytes_per_rpc' , MeasureUnit . BYTE ,
50
- 'Total bytes received across all response messages per RPC.' ) ;
44
+ export const GRPC_CLIENT_RECEIVED_BYTES_PER_RPC : Measure =
45
+ globalStats . createMeasureInt64 (
46
+ 'grpc.io/client/received_bytes_per_rpc' , MeasureUnit . BYTE ,
47
+ 'Total bytes received across all response messages per RPC.' ) ;
51
48
52
- /**
53
- * {@link Measure } for gRPC client roundtrip latency in milliseconds.
54
- *
55
- */
56
- const GRPC_CLIENT_ROUNDTRIP_LATENCY = globalStats . createMeasureDouble (
49
+ /** {@link Measure } for gRPC client roundtrip latency in milliseconds. */
50
+ export const GRPC_CLIENT_ROUNDTRIP_LATENCY : Measure = globalStats . createMeasureDouble (
57
51
'grpc.io/client/roundtrip_latency' , MeasureUnit . MS ,
58
52
'Time between first byte of request sent to last byte of response received, or terminal error.' ) ;
59
53
60
- /**
61
- * {@link Measure } for gRPC server latency in milliseconds.
62
- *
63
- */
64
- const GRPC_CLIENT_SERVER_LATENCY = globalStats . createMeasureDouble (
54
+ /** {@link Measure } for gRPC server latency in milliseconds. */
55
+ export const GRPC_CLIENT_SERVER_LATENCY : Measure = globalStats . createMeasureDouble (
65
56
'grpc.io/client/server_latency' , MeasureUnit . MS ,
66
57
'Propagated from the server and should have the same value as "grpc.io/server/latency' ) ;
67
58
68
59
/**
69
60
* Tag key that represents a client gRPC method.
70
61
*
71
- * <p> {@link #GRPC_CLIENT_METHOD} is set when an outgoing request starts and is
62
+ * {@link #GRPC_CLIENT_METHOD} is set when an outgoing request starts and is
72
63
* available in all the recorded metrics.
73
- *
74
64
*/
75
- const GRPC_CLIENT_METHOD = {
65
+ export const GRPC_CLIENT_METHOD = {
76
66
name : 'grpc_client_method'
77
67
} ;
78
68
@@ -82,35 +72,41 @@ const GRPC_CLIENT_METHOD = {
82
72
*
83
73
* <p>{@link #GRPC_CLIENT_STATUS} is set when an outgoing request finishes and
84
74
* is only available around metrics recorded at the end of the outgoing request.
85
- *
86
75
*/
87
- const GRPC_CLIENT_STATUS = {
76
+ export const GRPC_CLIENT_STATUS = {
88
77
name : 'grpc_client_status'
89
78
} ;
90
79
91
- /**
92
- * {@link View } for client sent bytes per RPC.
93
- *
94
- */
95
- const GRPC_CLIENT_SENT_BYTES_PER_RPC_VIEW = globalStats . createView (
96
- 'grpc.io/client/sent_bytes_per_rpc' , GRPC_CLIENT_SENT_BYTES_PER_RPC ,
97
- AggregationType . DISTRIBUTION , [ GRPC_CLIENT_METHOD ] ,
98
- 'Distribution of bytes sent per RPC, by method.' ,
99
- DEFAULT_BYTES_DISTRIBUTION ) ;
100
- /**
101
- * {@link View } for client received bytes per RPC.
102
- *
103
- */
80
+ /** {@link View } for client received messages per RPC. */
81
+ const GRPC_CLIENT_RECEIVED_MESSAGES_PER_RPC_VIEW = globalStats . createView (
82
+ 'grpc.io/client/received_messages_per_rpc' ,
83
+ GRPC_CLIENT_RECEIVED_MESSAGES_PER_RPC , AggregationType . DISTRIBUTION ,
84
+ [ GRPC_CLIENT_METHOD ] ,
85
+ 'Distribution of received messages count per RPC, by method.' ,
86
+ DEFAULT_MESSAGE_COUNT_DISTRIBUTION ) ;
87
+
88
+ /** {@link View } for client received bytes per RPC. */
104
89
const GRPC_CLIENT_RECEIVED_BYTES_PER_RPC_VIEW = globalStats . createView (
105
90
'grpc.io/client/received_bytes_per_rpc' , GRPC_CLIENT_RECEIVED_BYTES_PER_RPC ,
106
91
AggregationType . DISTRIBUTION , [ GRPC_CLIENT_METHOD ] ,
107
92
'Distribution of bytes received per RPC, by method.' ,
108
93
DEFAULT_BYTES_DISTRIBUTION ) ;
109
94
110
- /**
111
- * {@link View } for client roundtrip latency in milliseconds.
112
- *
113
- */
95
+ /** {@link View } for client sent messages per RPC. */
96
+ const GRPC_CLIENT_SENT_MESSAGES_PER_RPC_VIEW = globalStats . createView (
97
+ 'grpc.io/client/sent_messages_per_rpc' , GRPC_CLIENT_SENT_MESSAGES_PER_RPC ,
98
+ AggregationType . DISTRIBUTION , [ GRPC_CLIENT_METHOD ] ,
99
+ 'Distribution of sent messages count per RPC, by method.' ,
100
+ DEFAULT_MESSAGE_COUNT_DISTRIBUTION ) ;
101
+
102
+ /** {@link View } for client sent bytes per RPC. */
103
+ const GRPC_CLIENT_SENT_BYTES_PER_RPC_VIEW = globalStats . createView (
104
+ 'grpc.io/client/sent_bytes_per_rpc' , GRPC_CLIENT_SENT_BYTES_PER_RPC ,
105
+ AggregationType . DISTRIBUTION , [ GRPC_CLIENT_METHOD ] ,
106
+ 'Distribution of bytes sent per RPC, by method.' ,
107
+ DEFAULT_BYTES_DISTRIBUTION ) ;
108
+
109
+ /** {@link View } for client roundtrip latency in milliseconds. */
114
110
const GRPC_CLIENT_ROUNDTRIP_LATENCY_VIEW = globalStats . createView (
115
111
'grpc.io/client/roundtrip_latency' , GRPC_CLIENT_ROUNDTRIP_LATENCY ,
116
112
AggregationType . DISTRIBUTION , [ GRPC_CLIENT_METHOD ] ,
@@ -120,51 +116,19 @@ const GRPC_CLIENT_ROUNDTRIP_LATENCY_VIEW = globalStats.createView(
120
116
/**
121
117
* {@link View } for completed client RPCs.
122
118
*
123
- * <p> This {@code View} uses measure {@code GRPC_CLIENT_ROUNDTRIP_LATENCY},
119
+ * This {@code View } uses measure {@code GRPC_CLIENT_ROUNDTRIP_LATENCY },
124
120
* since completed RPCs can be inferred over any measure recorded once per RPC
125
121
* (since it's just a count aggregation over the measure). It would be
126
122
* unnecessary to use a separate "count" measure.
127
- *
128
123
*/
129
124
const GRPC_CLIENT_COMPLETED_RPC_VIEW = globalStats . createView (
130
125
'grpc.io/client/completed_rpcs' , GRPC_CLIENT_ROUNDTRIP_LATENCY ,
131
126
AggregationType . COUNT , [ GRPC_CLIENT_METHOD , GRPC_CLIENT_STATUS ] ,
132
- 'Count of RPCs by method and status.' , DEFAULT_MILLI_SECONDS_DISTRIBUTION ) ;
133
-
134
- /**
135
- * {@link View } for client sent messages per RPC.
136
- *
137
- */
138
- const GRPC_CLIENT_SENT_MESSAGES_PER_RPC_VIEW = globalStats . createView (
139
- 'grpc.io/client/sent_messages_per_rpc' , GRPC_CLIENT_SENT_MESSAGES_PER_RPC ,
140
- AggregationType . DISTRIBUTION , [ GRPC_CLIENT_METHOD ] ,
141
- 'Distribution of sent messages count per RPC, by method.' ,
142
- DEFAULT_MESSAGE_COUNT_DISTRIBUTION ) ;
143
-
144
- /**
145
- * {@link View } for client received messages per RPC.
146
- *
147
- */
148
- const GRPC_CLIENT_RECEIVED_MESSAGES_PER_RPC_VIEW = globalStats . createView (
149
- 'grpc.io/client/received_messages_per_rpc' ,
150
- GRPC_CLIENT_RECEIVED_MESSAGES_PER_RPC , AggregationType . DISTRIBUTION ,
151
- [ GRPC_CLIENT_METHOD ] ,
152
- 'Distribution of received messages count per RPC, by method.' ,
153
- DEFAULT_MESSAGE_COUNT_DISTRIBUTION ) ;
154
-
155
- /**
156
- * {@link View } for client server latency in milliseconds.
157
- *
158
- */
159
- const GRPC_CLIENT_SERVER_LATENCY_VIEW = globalStats . createView (
160
- 'grpc.io/client/server_latency' , GRPC_CLIENT_SERVER_LATENCY ,
161
- AggregationType . DISTRIBUTION , [ GRPC_CLIENT_METHOD ] ,
162
- 'Distribution of server latency as viewed by client, by method.' ,
163
- DEFAULT_MILLI_SECONDS_DISTRIBUTION ) ;
127
+ 'Count of RPCs by method and status.' , DEFAULT_MESSAGE_COUNT_DISTRIBUTION ) ;
164
128
165
129
export const GRPC_BASIC_CLIENT_VIEWS : View [ ] = [
166
- GRPC_CLIENT_SENT_BYTES_PER_RPC_VIEW , GRPC_CLIENT_RECEIVED_BYTES_PER_RPC_VIEW ,
167
- GRPC_CLIENT_ROUNDTRIP_LATENCY_VIEW , GRPC_CLIENT_COMPLETED_RPC_VIEW ,
168
- GRPC_CLIENT_SENT_MESSAGES_PER_RPC_VIEW ,
169
- GRPC_CLIENT_RECEIVED_MESSAGES_PER_RPC_VIEW , GRPC_CLIENT_SERVER_LATENCY_VIEW
130
+ GRPC_CLIENT_RECEIVED_MESSAGES_PER_RPC_VIEW ,
131
+ GRPC_CLIENT_RECEIVED_BYTES_PER_RPC_VIEW ,
132
+ GRPC_CLIENT_SENT_MESSAGES_PER_RPC_VIEW , GRPC_CLIENT_SENT_BYTES_PER_RPC_VIEW ,
133
+ GRPC_CLIENT_ROUNDTRIP_LATENCY_VIEW , GRPC_CLIENT_COMPLETED_RPC_VIEW
170
134
] ;
0 commit comments