forked from freehere107/go-workers
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmetrics.go
38 lines (30 loc) · 1016 Bytes
/
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
package workers
import (
"net/http"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
const MetricsNamespace string = "go_worker"
var (
TaskEnqueueMetric = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: MetricsNamespace,
Name: "task_enqueue",
Help: "number of task enqueue, grouped by queue name",
}, []string{"name"})
TaskDequeueMetric = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: MetricsNamespace,
Name: "task_dequeue",
Help: "number of task dequeue, grouped by queue name",
}, []string{"name"})
TaskProcessedMetric = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: MetricsNamespace,
Name: "task_processed",
Help: "Total number of tasks processed.",
}, []string{"name", "error"})
)
func init() {
prometheus.MustRegister(TaskEnqueueMetric, TaskDequeueMetric, TaskProcessedMetric)
}
func MetricsHandler() http.Handler {
return promhttp.Handler()
}