aboutsummaryrefslogtreecommitdiff
path: root/pw_metric/pw_metric_proto/metric_service.proto
blob: 354e2599470352981f7585a225a1249ffc0064fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright 2020 The Pigweed Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
syntax = "proto3";

package pw.metric.proto;

// A metric, described by the name (path + name), and the value.
//
// This flattened representation, while more complicated than the obvious tree
// structure alternative, enables streaming metrics from the device in low
// memory or low compute situations.
message Metric {
  // The token path from the root. The last token is the metric name, and
  // previous tokens are the parent group names. This could be converted from
  // the tokens into a string; for example the token path {0xfaff, 0xabcd}:
  //
  //  - The group is 0xfaff (root, parent)
  //  - The metric is 0xabcd
  //
  // Given the token database, this might be converted into:
  //
  //   /i2c_bus_1/failed_transactions
  //
  // Note: This uses a repeated fixed32 instead of a "Oneof" with the string
  // path to reduce the encoded size. Using a repeated Oneof name { str,
  // fixed32 } would cost approximately 6N bytes for N path elements, vs 2 + 4N
  // bytes in the packed case.
  repeated fixed32 token_path = 1;

  // The string path from the root. Similar to token path, but with strings.
  // Note: This is currently unsupported.
  repeated string string_path = 2;

  // The metric value. This field should be omitted when used as a query.
  oneof value {
    float as_float = 3;
    uint32 as_int = 4;
  };
}

message MetricRequest {
  // Metrics or the groups matched to the given paths are returned.  The intent
  // is to support matching semantics, with at least subsetting to e.g. collect
  // all the metrics in a group and its children. We may also implement
  // wildcard matchers.
  //
  // Value fields in the metrics will be ignored, since this is a query.
  //
  // Note: This is currently unsupported.
  repeated Metric metrics = 1;
}

message MetricResponse {
  repeated Metric metrics = 1;
}

service MetricService {
  // Returns metrics or groups matching the requested paths.
  rpc Get(MetricRequest) returns (stream MetricResponse) {}
}