forked from milvus-io/milvus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcgo_metrics.go
86 lines (78 loc) · 2.1 KB
/
cgo_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
74
75
76
77
78
79
80
81
82
83
84
85
86
package metrics
import (
"sync"
"time"
"github.com/prometheus/client_golang/prometheus"
)
var (
subsystemCGO = "cgo"
cgoLabelName = "name"
once sync.Once
bucketsForCGOCall = []float64{
10 * time.Nanosecond.Seconds(),
100 * time.Nanosecond.Seconds(),
250 * time.Nanosecond.Seconds(),
500 * time.Nanosecond.Seconds(),
time.Microsecond.Seconds(),
10 * time.Microsecond.Seconds(),
20 * time.Microsecond.Seconds(),
50 * time.Microsecond.Seconds(),
100 * time.Microsecond.Seconds(),
250 * time.Microsecond.Seconds(),
500 * time.Microsecond.Seconds(),
time.Millisecond.Seconds(),
2 * time.Millisecond.Seconds(),
10 * time.Millisecond.Seconds(),
}
ActiveFutureTotal = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: milvusNamespace,
Subsystem: subsystemCGO,
Name: "active_future_total",
Help: "Total number of active futures.",
}, []string{
nodeIDLabelName,
},
)
RunningCgoCallTotal = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: milvusNamespace,
Subsystem: subsystemCGO,
Name: "running_cgo_call_total",
Help: "Total number of running cgo calls.",
}, []string{
nodeIDLabelName,
})
CGODuration = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: milvusNamespace,
Subsystem: subsystemCGO,
Name: "cgo_duration_seconds",
Help: "Histogram of cgo call duration in seconds.",
Buckets: bucketsForCGOCall,
}, []string{
nodeIDLabelName,
cgoLabelName,
},
)
CGOQueueDuration = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: milvusNamespace,
Subsystem: subsystemCGO,
Name: "cgo_queue_duration_seconds",
Help: "Duration of cgo call in queue.",
Buckets: bucketsForCGOCall,
}, []string{
nodeIDLabelName,
},
)
)
// RegisterCGOMetrics registers the cgo metrics.
func RegisterCGOMetrics(registry *prometheus.Registry) {
once.Do(func() {
registry.MustRegister(ActiveFutureTotal)
registry.MustRegister(RunningCgoCallTotal)
registry.MustRegister(CGODuration)
registry.MustRegister(CGOQueueDuration)
})
}