blob: f9aa4bb99451838b32ab452a4b250c170a4c533b [file] [log] [blame]
Alistair Veitch4aaba752016-06-02 17:11:46 -07001/*
2 * Copyright 2016, Google Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 */
32
Alistair Veitchf183ece2016-07-26 13:46:16 -070033#include "src/core/ext/census/base_resources.h"
Alistair Veitch0cf4def2016-06-07 08:59:30 -070034
Alistair Veitch4aaba752016-06-02 17:11:46 -070035#include <stdio.h>
36#include <string.h>
37
38#include <grpc/census.h>
39#include <grpc/support/log.h>
40
Alistair Veitchf183ece2016-07-26 13:46:16 -070041#include "src/core/ext/census/resource.h"
Alistair Veitch4aaba752016-06-02 17:11:46 -070042
43// Add base RPC resource definitions for use by RPC runtime.
44//
45// TODO(aveitch): All of these are currently hardwired definitions encoded in
46// the code in this file. These should be converted to use an external
47// configuration mechanism, in which these resources are defined in a text
48// file, which is compiled to .pb format and read by still-to-be-written
49// configuration functions.
50
Alistair Veitch4aaba752016-06-02 17:11:46 -070051// Define all base resources. This should be called by census initialization.
52void define_base_resources() {
Alistair Veitch0cf4def2016-06-07 08:59:30 -070053 google_census_Resource_BasicUnit numerator =
54 google_census_Resource_BasicUnit_SECS;
55 resource r = {"client_rpc_latency", // name
56 "Client RPC latency in seconds", // description
57 0, // prefix
58 1, // n_numerators
59 &numerator, // numerators
60 0, // n_denominators
61 NULL}; // denominators
62 define_resource(&r);
63 r = (resource){"server_rpc_latency", // name
64 "Server RPC latency in seconds", // description
65 0, // prefix
66 1, // n_numerators
67 &numerator, // numerators
68 0, // n_denominators
69 NULL}; // denominators
70 define_resource(&r);
Alistair Veitch4aaba752016-06-02 17:11:46 -070071}