-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmetrica.go
81 lines (76 loc) · 1.69 KB
/
metrica.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
package main
type Metrica struct {
Name string
Units string
DataKey string
DataSource *MetricsDataSource
}
func (metrica *Metrica) GetName() string {
return metrica.Name
}
func (metrica *Metrica) GetUnits() string {
return metrica.Units
}
func (metrica *Metrica) GetValue() (float64, error) {
return metrica.DataSource.CheckAndGetLastData(metrica.DataKey)
}
type IncrementalMetrica struct {
Metrica
}
func (metrica *IncrementalMetrica) GetValue() (float64, error) {
return metrica.DataSource.CheckAndGetData(metrica.DataKey)
}
var plainMetrics = []*Metrica{
&Metrica{
DataKey: "avg_query_wall",
Name: "avg/Avg Query Wall Time",
Units: "milisecond",
},
}
var incrementalMetrics = []*Metrica{
&Metrica{
DataKey: "queries",
Name: "general/Queries",
Units: "Queries/second",
},
&Metrica{
DataKey: "connections",
Name: "general/Connections",
Units: "connections/second",
},
&Metrica{
DataKey: "maxed_out",
Name: "error/Maxed out connections",
Units: "connections/second",
},
&Metrica{
DataKey: "command_search",
Name: "commands/Command search",
Units: "command/second",
},
&Metrica{
DataKey: "command_excerpt",
Name: "commands/Command excerpt",
Units: "command/second",
},
&Metrica{
DataKey: "command_update",
Name: "commands/Command update",
Units: "command/second",
},
&Metrica{
DataKey: "command_keywords",
Name: "commands/Command keywords",
Units: "command/second",
},
&Metrica{
DataKey: "command_persist",
Name: "commands/Command persist",
Units: "command/second",
},
&Metrica{
DataKey: "command_flushattrs",
Name: "commands/Command flushattrs",
Units: "command/second",
},
}