1 // Copyright 2020 The Pigweed Authors
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
7 // https://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
18 // A metric, described by the name (path + name), and the value.
20 // This flattened representation, while more complicated than the obvious tree
21 // structure alternative, enables streaming metrics from the device in low
22 // memory or low compute situations.
24 // The token path from the root. The last token is the metric name, and
25 // previous tokens are the parent group names. This could be converted from
26 // the tokens into a string; for example the token path {0xfaff, 0xabcd}:
28 // - The group is 0xfaff (root, parent)
29 // - The metric is 0xabcd
31 // Given the token database, this might be converted into:
33 // /i2c_bus_1/failed_transactions
35 // Note: This uses a repeated fixed32 instead of a "Oneof" with the string
36 // path to reduce the encoded size. Using a repeated Oneof name { str,
37 // fixed32 } would cost approximately 6N bytes for N path elements, vs 2 + 4N
38 // bytes in the packed case.
39 repeated fixed32 token_path = 1;
41 // The string path from the root. Similar to token path, but with strings.
42 // Note: This is currently unsupported.
43 repeated string string_path = 2;
45 // The metric value. This field should be omitted when used as a query.
52 message MetricRequest {
53 // Metrics or the groups matched to the given paths are returned. The intent
54 // is to support matching semantics, with at least subsetting to e.g. collect
55 // all the metrics in a group and its children. We may also implement
58 // Value fields in the metrics will be ignored, since this is a query.
60 // Note: This is currently unsupported.
61 repeated Metric metrics = 1;
64 message MetricResponse {
65 repeated Metric metrics = 1;
68 service MetricService {
69 // Returns metrics or groups matching the requested paths.
70 rpc Get(MetricRequest) returns (stream MetricResponse) {}