1414 * limitations under the License.
1515 */
1616
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' ;
1918
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).' ) ;
2726
2827/**
2928 * {@link Measure } for total bytes sent across all request messages per RPC.
30- *
3129 */
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.' ) ;
3534
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).' ) ;
4340
4441/**
4542 * {@link Measure } for total bytes received across all response messages per RPC
46- *
4743 */
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.' ) ;
5148
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 (
5751 'grpc.io/client/roundtrip_latency' , MeasureUnit . MS ,
5852 'Time between first byte of request sent to last byte of response received, or terminal error.' ) ;
5953
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 (
6556 'grpc.io/client/server_latency' , MeasureUnit . MS ,
6657 'Propagated from the server and should have the same value as "grpc.io/server/latency' ) ;
6758
6859/**
6960 * Tag key that represents a client gRPC method.
7061 *
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
7263 * available in all the recorded metrics.
73- *
7464 */
75- const GRPC_CLIENT_METHOD = {
65+ export const GRPC_CLIENT_METHOD = {
7666 name : 'grpc_client_method'
7767} ;
7868
@@ -82,35 +72,41 @@ const GRPC_CLIENT_METHOD = {
8272 *
8373 * <p>{@link #GRPC_CLIENT_STATUS} is set when an outgoing request finishes and
8474 * is only available around metrics recorded at the end of the outgoing request.
85- *
8675 */
87- const GRPC_CLIENT_STATUS = {
76+ export const GRPC_CLIENT_STATUS = {
8877 name : 'grpc_client_status'
8978} ;
9079
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. */
10489const GRPC_CLIENT_RECEIVED_BYTES_PER_RPC_VIEW = globalStats . createView (
10590 'grpc.io/client/received_bytes_per_rpc' , GRPC_CLIENT_RECEIVED_BYTES_PER_RPC ,
10691 AggregationType . DISTRIBUTION , [ GRPC_CLIENT_METHOD ] ,
10792 'Distribution of bytes received per RPC, by method.' ,
10893 DEFAULT_BYTES_DISTRIBUTION ) ;
10994
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. */
114110const GRPC_CLIENT_ROUNDTRIP_LATENCY_VIEW = globalStats . createView (
115111 'grpc.io/client/roundtrip_latency' , GRPC_CLIENT_ROUNDTRIP_LATENCY ,
116112 AggregationType . DISTRIBUTION , [ GRPC_CLIENT_METHOD ] ,
@@ -120,51 +116,19 @@ const GRPC_CLIENT_ROUNDTRIP_LATENCY_VIEW = globalStats.createView(
120116/**
121117 * {@link View } for completed client RPCs.
122118 *
123- * <p> This {@code View} uses measure {@code GRPC_CLIENT_ROUNDTRIP_LATENCY},
119+ * This {@code View } uses measure {@code GRPC_CLIENT_ROUNDTRIP_LATENCY },
124120 * since completed RPCs can be inferred over any measure recorded once per RPC
125121 * (since it's just a count aggregation over the measure). It would be
126122 * unnecessary to use a separate "count" measure.
127- *
128123 */
129124const GRPC_CLIENT_COMPLETED_RPC_VIEW = globalStats . createView (
130125 'grpc.io/client/completed_rpcs' , GRPC_CLIENT_ROUNDTRIP_LATENCY ,
131126 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 ) ;
164128
165129export 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
170134] ;
0 commit comments