Alistair Veitch | 4aaba75 | 2016-06-02 17:11:46 -0700 | [diff] [blame] | 1 | /* |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 2 | * Copyright 2016 gRPC authors. |
Alistair Veitch | 4aaba75 | 2016-06-02 17:11:46 -0700 | [diff] [blame] | 3 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
Alistair Veitch | 4aaba75 | 2016-06-02 17:11:46 -0700 | [diff] [blame] | 7 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Alistair Veitch | 4aaba75 | 2016-06-02 17:11:46 -0700 | [diff] [blame] | 9 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
Alistair Veitch | 4aaba75 | 2016-06-02 17:11:46 -0700 | [diff] [blame] | 15 | * |
| 16 | */ |
| 17 | |
Alistair Veitch | f183ece | 2016-07-26 13:46:16 -0700 | [diff] [blame] | 18 | #include "src/core/ext/census/base_resources.h" |
Alistair Veitch | 0cf4def | 2016-06-07 08:59:30 -0700 | [diff] [blame] | 19 | |
Alistair Veitch | 4aaba75 | 2016-06-02 17:11:46 -0700 | [diff] [blame] | 20 | #include <stdio.h> |
| 21 | #include <string.h> |
| 22 | |
| 23 | #include <grpc/census.h> |
| 24 | #include <grpc/support/log.h> |
| 25 | |
Alistair Veitch | f183ece | 2016-07-26 13:46:16 -0700 | [diff] [blame] | 26 | #include "src/core/ext/census/resource.h" |
Alistair Veitch | 4aaba75 | 2016-06-02 17:11:46 -0700 | [diff] [blame] | 27 | |
| 28 | // Add base RPC resource definitions for use by RPC runtime. |
| 29 | // |
| 30 | // TODO(aveitch): All of these are currently hardwired definitions encoded in |
| 31 | // the code in this file. These should be converted to use an external |
| 32 | // configuration mechanism, in which these resources are defined in a text |
| 33 | // file, which is compiled to .pb format and read by still-to-be-written |
| 34 | // configuration functions. |
| 35 | |
Alistair Veitch | 4aaba75 | 2016-06-02 17:11:46 -0700 | [diff] [blame] | 36 | // Define all base resources. This should be called by census initialization. |
| 37 | void define_base_resources() { |
Alistair Veitch | 0cf4def | 2016-06-07 08:59:30 -0700 | [diff] [blame] | 38 | google_census_Resource_BasicUnit numerator = |
| 39 | google_census_Resource_BasicUnit_SECS; |
Yash Tibrewal | 9eb8672 | 2017-09-17 23:43:30 -0700 | [diff] [blame] | 40 | resource r = {(char *)"client_rpc_latency", // name |
| 41 | (char *)"Client RPC latency in seconds", // description |
| 42 | 0, // prefix |
| 43 | 1, // n_numerators |
| 44 | &numerator, // numerators |
| 45 | 0, // n_denominators |
| 46 | NULL}; // denominators |
Alistair Veitch | 0cf4def | 2016-06-07 08:59:30 -0700 | [diff] [blame] | 47 | define_resource(&r); |
Yash Tibrewal | d8b84a2 | 2017-09-25 13:38:03 -0700 | [diff] [blame] | 48 | r = {(char *)"server_rpc_latency", // name |
| 49 | (char *)"Server RPC latency in seconds", // description |
| 50 | 0, // prefix |
| 51 | 1, // n_numerators |
| 52 | &numerator, // numerators |
| 53 | 0, // n_denominators |
| 54 | NULL}; // denominators |
Alistair Veitch | 0cf4def | 2016-06-07 08:59:30 -0700 | [diff] [blame] | 55 | define_resource(&r); |
Alistair Veitch | 4aaba75 | 2016-06-02 17:11:46 -0700 | [diff] [blame] | 56 | } |