forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
observability.go
152 lines (127 loc) · 5.4 KB
/
observability.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package observability // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor/internal/observability"
import (
"context"
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
)
// TODO: re-think if processor should register it's own telemetry views or if some other
// mechanism should be used by the collector to discover views from all components
func init() {
_ = view.Register(
viewPodsUpdated,
viewPodsAdded,
viewPodsDeleted,
viewIPLookupMiss,
viewPodTableSize,
viewNamespacesAdded,
viewNamespacesUpdated,
viewNamespacesDeleted,
)
}
var (
mPodsUpdated = stats.Int64("processor.k8sattributes.pods.updated", "Number of pod update events received", "1")
mPodsAdded = stats.Int64("processor.k8sattributes.pods.added", "Number of pod add events received", "1")
mPodsDeleted = stats.Int64("processor.k8sattributes.pods.deleted", "Number of pod delete events received", "1")
mPodTableSize = stats.Int64("processor.k8sattributes.pods.table_size", "Size of table containing pod info", "1")
mIPLookupMiss = stats.Int64("processor.k8sattributes.ip_lookup_misses", "Number of times pod by IP lookup failed.", "1")
mNamespacesUpdated = stats.Int64("processor.k8sattributes.namespaces.updated", "Number of namespace update events received", "1")
mNamespacesAdded = stats.Int64("processor.k8sattributes.namespaces.added", "Number of namespace add events received", "1")
mNamespacesDeleted = stats.Int64("processor.k8sattributes.namespaces.deleted", "Number of namespace delete events received", "1")
mReplicaSetsUpdated = stats.Int64("processor.k8sattributes.replicasets.updated", "Number of ReplicaSet update events received", "1")
mReplicaSetsAdded = stats.Int64("processor.k8sattributes.replicasets.added", "Number of ReplicaSet add events received", "1")
mReplicaSetsDeleted = stats.Int64("processor.k8sattributes.replicasets.deleted", "Number of ReplicaSet delete events received", "1")
)
var viewPodsUpdated = &view.View{
Name: mPodsUpdated.Name(),
Description: mPodsUpdated.Description(),
Measure: mPodsUpdated,
Aggregation: view.Sum(),
}
var viewPodsAdded = &view.View{
Name: mPodsAdded.Name(),
Description: mPodsAdded.Description(),
Measure: mPodsAdded,
Aggregation: view.Sum(),
}
var viewPodsDeleted = &view.View{
Name: mPodsDeleted.Name(),
Description: mPodsDeleted.Description(),
Measure: mPodsDeleted,
Aggregation: view.Sum(),
}
var viewIPLookupMiss = &view.View{
Name: mIPLookupMiss.Name(),
Description: mIPLookupMiss.Description(),
Measure: mIPLookupMiss,
Aggregation: view.Sum(),
}
var viewPodTableSize = &view.View{
Name: mPodTableSize.Name(),
Description: mPodTableSize.Description(),
Measure: mPodTableSize,
Aggregation: view.LastValue(),
}
var viewNamespacesUpdated = &view.View{
Name: mNamespacesUpdated.Name(),
Description: mNamespacesUpdated.Description(),
Measure: mNamespacesUpdated,
Aggregation: view.Sum(),
}
var viewNamespacesAdded = &view.View{
Name: mNamespacesAdded.Name(),
Description: mNamespacesAdded.Description(),
Measure: mNamespacesAdded,
Aggregation: view.Sum(),
}
var viewNamespacesDeleted = &view.View{
Name: mNamespacesDeleted.Name(),
Description: mNamespacesDeleted.Description(),
Measure: mNamespacesDeleted,
Aggregation: view.Sum(),
}
// RecordPodUpdated increments the metric that records pod update events received.
func RecordPodUpdated() {
stats.Record(context.Background(), mPodsUpdated.M(int64(1)))
}
// RecordPodAdded increments the metric that records pod add events receiver.
func RecordPodAdded() {
stats.Record(context.Background(), mPodsAdded.M(int64(1)))
}
// RecordPodDeleted increments the metric that records pod events deleted.
func RecordPodDeleted() {
stats.Record(context.Background(), mPodsDeleted.M(int64(1)))
}
// RecordIPLookupMiss increments the metric that records Pod lookup by IP misses.
func RecordIPLookupMiss() {
stats.Record(context.Background(), mIPLookupMiss.M(int64(1)))
}
// RecordPodTableSize store size of pod table field in WatchClient
func RecordPodTableSize(podTableSize int64) {
stats.Record(context.Background(), mPodTableSize.M(podTableSize))
}
// RecordNamespaceUpdated increments the metric that records namespace update events received.
func RecordNamespaceUpdated() {
stats.Record(context.Background(), mNamespacesUpdated.M(int64(1)))
}
// RecordNamespaceAdded increments the metric that records namespace add events receiver.
func RecordNamespaceAdded() {
stats.Record(context.Background(), mNamespacesAdded.M(int64(1)))
}
// RecordNamespaceDeleted increments the metric that records namespace events deleted.
func RecordNamespaceDeleted() {
stats.Record(context.Background(), mNamespacesDeleted.M(int64(1)))
}
// RecordReplicaSetUpdated increments the metric that records ReplicaSet update events received.
func RecordReplicaSetUpdated() {
stats.Record(context.Background(), mReplicaSetsUpdated.M(int64(1)))
}
// RecordReplicaSetAdded increments the metric that records ReplicaSet add events receiver.
func RecordReplicaSetAdded() {
stats.Record(context.Background(), mReplicaSetsAdded.M(int64(1)))
}
// RecordReplicaSetDeleted increments the metric that records ReplicaSet events deleted.
func RecordReplicaSetDeleted() {
stats.Record(context.Background(), mReplicaSetsDeleted.M(int64(1)))
}