-
Notifications
You must be signed in to change notification settings - Fork 1
/
tracer_prometheus.go
40 lines (32 loc) · 988 Bytes
/
tracer_prometheus.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
package promise4g
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
var (
promisesCreated = promauto.NewCounter(prometheus.CounterOpts{
Name: "promises_created_total",
Help: "The total number of promises created",
})
promiseExecutionTime = promauto.NewHistogram(prometheus.HistogramOpts{
Name: "promise_execution_time_seconds",
Help: "The execution time of promises in seconds",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 10), // From 1ms to ~1s
})
concurrentPromises = promauto.NewGauge(prometheus.GaugeOpts{
Name: "concurrent_promises",
Help: "The number of promises currently executing",
})
)
func incrementPromisesCreated() {
promisesCreated.Inc()
}
func observePromiseExecutionTime(seconds float64) {
promiseExecutionTime.Observe(seconds)
}
func incrementConcurrentPromises() {
concurrentPromises.Inc()
}
func decrementConcurrentPromises() {
concurrentPromises.Dec()
}