-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
Copy pathmetrics.go
73 lines (68 loc) · 2.31 KB
/
metrics.go
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
72
73
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package loadbalancingexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/loadbalancingexporter"
import (
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
"go.opencensus.io/tag"
)
var (
mNumResolutions = stats.Int64("loadbalancer_num_resolutions", "Number of times the resolver triggered a new resolutions", stats.UnitDimensionless)
mNumBackends = stats.Int64("loadbalancer_num_backends", "Current number of backends in use", stats.UnitDimensionless)
mBackendLatency = stats.Int64("loadbalancer_backend_latency", "Response latency in ms for the backends", stats.UnitMilliseconds)
endpointTagKey = tag.MustNewKey("endpoint")
successTrueMutator = tag.Upsert(tag.MustNewKey("success"), "true")
successFalseMutator = tag.Upsert(tag.MustNewKey("success"), "false")
)
// metricViews return the metrics views according to given telemetry level.
func metricViews() []*view.View {
return []*view.View{
{
Name: mNumResolutions.Name(),
Measure: mNumResolutions,
Description: mNumResolutions.Description(),
Aggregation: view.Count(),
TagKeys: []tag.Key{
tag.MustNewKey("resolver"),
tag.MustNewKey("success"),
},
},
{
Name: mNumBackends.Name(),
Measure: mNumBackends,
Description: mNumBackends.Description(),
Aggregation: view.LastValue(),
TagKeys: []tag.Key{
tag.MustNewKey("resolver"),
},
},
{
Name: "loadbalancer_num_backend_updates", // counts the number of times the measure was changed
Measure: mNumBackends,
Description: "Number of times the list of backends was updated",
Aggregation: view.Count(),
TagKeys: []tag.Key{
tag.MustNewKey("resolver"),
},
},
{
Name: mBackendLatency.Name(),
Measure: mBackendLatency,
Description: mBackendLatency.Description(),
TagKeys: []tag.Key{
tag.MustNewKey("endpoint"),
},
Aggregation: view.Distribution(0, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000),
},
{
Name: "loadbalancer_backend_outcome",
Measure: mBackendLatency,
Description: "Number of success/failures for each endpoint",
TagKeys: []tag.Key{
tag.MustNewKey("endpoint"),
tag.MustNewKey("success"),
},
Aggregation: view.Count(),
},
}
}