Skip to content

Commit 5b56d70

Browse files
authored
Rework the metric_descriptor type (#36)
Rework the metric_descriptor to separate the description of the shape of the metric from the attributes used to produce values for the metric at run time; the mapping from attribute to label value is described in the aspect's config in the mixer at //pkg/aspect/config/metrics.proto
1 parent 189c72d commit 5b56d70

File tree

3 files changed

+80
-19
lines changed

3 files changed

+80
-19
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@
2727
*.exe
2828
*.out
2929
*.app
30+
31+
.idea/
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2017 Google Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package istio.mixer.v1.config.descriptor;
18+
19+
import "mixer/v1/config/descriptor/value_type.proto";
20+
21+
// A `LabelDescriptor` describes the schema of a label (or dimension) used in other descriptors.
22+
message LabelDescriptor {
23+
// The name of this descriptor, referenced from other descriptors.
24+
string name = 1;
25+
26+
// An optional human-readable description of the attribute's purpose.
27+
string description = 2;
28+
29+
// The type of data carried by this label
30+
ValueType value_type = 3;
31+
}

mixer/v1/config/descriptor/metric_descriptor.proto

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,50 @@ syntax = "proto3";
1616

1717
package istio.mixer.v1.config.descriptor;
1818

19+
import "mixer/v1/config/descriptor/label_descriptor.proto";
20+
import "mixer/v1/config/descriptor/value_type.proto";
21+
1922
// Defines a metric type and its schema.
2023
//
21-
// A given metric is dimensioned by a set of attributes. A given metric holds a
22-
// unique value for potentially any combination of these attributes.
24+
// A metric is dimensioned by a set of labels whose values are derived at runtime from attributes.
25+
// A given metric holds a unique value for potentially any combination of these dimensions.
26+
//
27+
// The following is an example descriptor for a metric capturing the number of RPCs served, dimensioned
28+
// by the method being called and response code returned by the server:
29+
//
30+
// metric_descriptor:
31+
// name: "response_code"
32+
// kind: COUNTER
33+
// value: I64
34+
// labels:
35+
// name: api_method
36+
// value_type: STRING
37+
// labels:
38+
// name: response_code
39+
// value_type: INT64
40+
//
41+
// To actually report metrics at run time a mapping from attributes to a metric's labels must be provided.
42+
// This is provided in the service's config; using our above descriptor we might describe the metric as:
43+
//
44+
// metric:
45+
// descriptor: "response_code" # must match metric_descriptor.name
46+
// value: $requestCount # Istio expression syntax for the attribute named "request_count"
47+
// labels:
48+
// # either the attribute named 'apiMethod' or the literal string 'unknown'; must eval to a string
49+
// api_method: $apiMethod | "unknown"
50+
// # either the attribute named 'responseCode' or the literal int64 500; must eval to an int64
51+
// response_code: $responseCode | 500
52+
//
2353
message MetricDescriptor {
24-
// The name of this descriptor.
54+
// The name of this descriptor. This is used to refer to this descriptor in other contexts.
2555
string name = 1;
2656

27-
// The name of the attribute that supplies the value for metrics
28-
// of this type.
29-
string value_attribute = 2;
30-
31-
// The set of attributes that are necessary to describe a specific value cell
32-
// for a metric of this type.
33-
repeated string attributes = 3;
34-
35-
// Whether the metric records instantaneous values, changes to a value, etc.
36-
MetricKind metric_kind = 4;
37-
38-
// An optional description of the metric, which should be used as the
39-
// documentation of the metric.
40-
string description = 5;
41-
4257
// An optional concise name for the metric, which can be displayed in user interfaces.
4358
// Use sentence case without an ending period, for example "Request count".
44-
string display_name = 6;
59+
string display_name = 2;
60+
61+
// An optional description of the metric, which should be used as the documentation for the metric.
62+
string description = 3;
4563

4664
// The kind of measurement. It describes how the data is recorded.
4765
enum MetricKind {
@@ -55,4 +73,14 @@ message MetricDescriptor {
5573
// For example, the number of API requests.
5674
COUNTER = 2;
5775
}
76+
// Whether the metric records instantaneous values, changes to a value, etc.
77+
MetricKind kind = 4;
78+
79+
// The type of data this metric records.
80+
ValueType value = 5;
81+
82+
// Labels that dimension the data recorded by this metric. The metric definition allows the user to
83+
// map attribute expressions to actual values for these labels at run time; the result of the evaluation
84+
// must be of the type described by the kind for each label.
85+
repeated LabelDescriptor labels = 6;
5886
}

0 commit comments

Comments
 (0)