gRPC  0.6.0
 All Classes Namespaces Functions Variables Enumerations Properties Pages
census_rpc_stats.h
1 /*
2  *
3  * Copyright 2015, Google Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following disclaimer
14  * in the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of Google Inc. nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
34 #ifndef GRPC_INTERNAL_CORE_STATISTICS_CENSUS_RPC_STATS_H
35 #define GRPC_INTERNAL_CORE_STATISTICS_CENSUS_RPC_STATS_H
36 
37 #include "src/core/statistics/census_interface.h"
38 #include <grpc/support/port_platform.h>
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
45  gpr_uint64 cnt;
46  gpr_uint64 rpc_error_cnt;
47  gpr_uint64 app_error_cnt;
48  double elapsed_time_ms;
49  double api_request_bytes;
50  double wire_request_bytes;
51  double api_response_bytes;
52  double wire_response_bytes;
53 };
54 
55 /* Creates an empty rpc stats object on heap. */
56 census_rpc_stats* census_rpc_stats_create_empty(void);
57 
59  const char* method;
60  census_rpc_stats minute_stats; /* cumulative stats in the past minute */
61  census_rpc_stats hour_stats; /* cumulative stats in the past hour */
62  census_rpc_stats total_stats; /* cumulative stats from last gc */
64 
66  int num_entries;
69 
70 /* Initializes an aggregated rpc stats object to an empty state. */
71 void census_aggregated_rpc_stats_set_empty(census_aggregated_rpc_stats* data);
72 
73 /* Records client side stats of a rpc. */
74 void census_record_rpc_client_stats(census_op_id op_id,
75  const census_rpc_stats* stats);
76 
77 /* Records server side stats of a rpc. */
78 void census_record_rpc_server_stats(census_op_id op_id,
79  const census_rpc_stats* stats);
80 
81 /* The following two functions are intended for inprocess query of
82  per-service per-method stats from grpc implementations. */
83 
84 /* Populates *data_map with server side aggregated per-service per-method
85  stats.
86  DO NOT CALL from outside of grpc code. */
87 void census_get_server_stats(census_aggregated_rpc_stats* data_map);
88 
89 /* Populates *data_map with client side aggregated per-service per-method
90  stats.
91  DO NOT CALL from outside of grpc code. */
92 void census_get_client_stats(census_aggregated_rpc_stats* data_map);
93 
94 void census_stats_store_init(void);
95 void census_stats_store_shutdown(void);
96 
97 #ifdef __cplusplus
98 }
99 #endif
100 
101 #endif /* GRPC_INTERNAL_CORE_STATISTICS_CENSUS_RPC_STATS_H */
Definition: census_rpc_stats.h:58
Definition: census_interface.h:44
Definition: census_rpc_stats.h:44
Definition: census_rpc_stats.h:65