...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package v2store
16
17 import "github.com/prometheus/client_golang/prometheus"
18
19
20
21
22
23
24 var (
25 readCounter = prometheus.NewCounterVec(
26 prometheus.CounterOpts{
27 Namespace: "etcd_debugging",
28 Subsystem: "store",
29 Name: "reads_total",
30 Help: "Total number of reads action by (get/getRecursive), local to this member.",
31 }, []string{"action"})
32
33 writeCounter = prometheus.NewCounterVec(
34 prometheus.CounterOpts{
35 Namespace: "etcd_debugging",
36 Subsystem: "store",
37 Name: "writes_total",
38 Help: "Total number of writes (e.g. set/compareAndDelete) seen by this member.",
39 }, []string{"action"})
40
41 readFailedCounter = prometheus.NewCounterVec(
42 prometheus.CounterOpts{
43 Namespace: "etcd_debugging",
44 Subsystem: "store",
45 Name: "reads_failed_total",
46 Help: "Failed read actions by (get/getRecursive), local to this member.",
47 }, []string{"action"})
48
49 writeFailedCounter = prometheus.NewCounterVec(
50 prometheus.CounterOpts{
51 Namespace: "etcd_debugging",
52 Subsystem: "store",
53 Name: "writes_failed_total",
54 Help: "Failed write actions (e.g. set/compareAndDelete), seen by this member.",
55 }, []string{"action"})
56
57 expireCounter = prometheus.NewCounter(
58 prometheus.CounterOpts{
59 Namespace: "etcd_debugging",
60 Subsystem: "store",
61 Name: "expires_total",
62 Help: "Total number of expired keys.",
63 })
64
65 watchRequests = prometheus.NewCounter(
66 prometheus.CounterOpts{
67 Namespace: "etcd_debugging",
68 Subsystem: "store",
69 Name: "watch_requests_total",
70 Help: "Total number of incoming watch requests (new or reestablished).",
71 })
72
73 watcherCount = prometheus.NewGauge(
74 prometheus.GaugeOpts{
75 Namespace: "etcd_debugging",
76 Subsystem: "store",
77 Name: "watchers",
78 Help: "Count of currently active watchers.",
79 })
80 )
81
82 const (
83 GetRecursive = "getRecursive"
84 )
85
86 func init() {
87 if prometheus.Register(readCounter) != nil {
88
89
90 return
91 }
92 prometheus.MustRegister(writeCounter)
93 prometheus.MustRegister(expireCounter)
94 prometheus.MustRegister(watchRequests)
95 prometheus.MustRegister(watcherCount)
96 }
97
98 func reportReadSuccess(readAction string) {
99 readCounter.WithLabelValues(readAction).Inc()
100 }
101
102 func reportReadFailure(readAction string) {
103 readCounter.WithLabelValues(readAction).Inc()
104 readFailedCounter.WithLabelValues(readAction).Inc()
105 }
106
107 func reportWriteSuccess(writeAction string) {
108 writeCounter.WithLabelValues(writeAction).Inc()
109 }
110
111 func reportWriteFailure(writeAction string) {
112 writeCounter.WithLabelValues(writeAction).Inc()
113 writeFailedCounter.WithLabelValues(writeAction).Inc()
114 }
115
116 func reportExpiredKey() {
117 expireCounter.Inc()
118 }
119
120 func reportWatchRequest() {
121 watchRequests.Inc()
122 }
123
124 func reportWatcherAdded() {
125 watcherCount.Inc()
126 }
127
128 func reportWatcherRemoved() {
129 watcherCount.Dec()
130 }
131
View as plain text