-
Notifications
You must be signed in to change notification settings - Fork 93
/
metrics.go
39 lines (34 loc) · 1.12 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
package module
import (
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
)
var (
mRefreshProgress = stats.Float64("indexslashing/refresh-progress", "Refresh progress", "By")
mRefreshDuration = stats.Int64("indexslashing/full-refresh-duration", "Duration of full-refresh", "s")
mUpdatedHeight = stats.Int64("indexslashing/updated-height", "Last updated height", "By")
vRefreshProgress = &view.View{
Name: "indexslashing/refresh-progress",
Measure: mRefreshProgress,
Description: "Refresh progress",
Aggregation: view.LastValue(),
}
vRefreshDuration = &view.View{
Name: "indexslashing/refresh-duration",
Measure: mRefreshDuration,
Description: "Refresh duration",
Aggregation: view.LastValue(),
}
vLastUpdatedHeight = &view.View{
Name: "indexslashing/updated-height",
Measure: mUpdatedHeight,
Description: "Last updated height",
Aggregation: view.LastValue(),
}
views = []*view.View{vRefreshDuration, vLastUpdatedHeight, vRefreshProgress}
)
func initMetrics() {
if err := view.Register(views...); err != nil {
log.Fatalf("Failed to register views: %v", err)
}
}