mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-01 09:52:23 -06:00
It didn't really make sense in multi-node setups because items could be started and finished on different nodes.
78 lines
2.3 KiB
Go
78 lines
2.3 KiB
Go
package metrics
|
|
|
|
import (
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
|
)
|
|
|
|
var (
|
|
// Namespace defines the namespace for the defines metrics.
|
|
Namespace = "opencloud"
|
|
|
|
// Subsystem defines the subsystem for the defines metrics.
|
|
Subsystem = "postprocessing"
|
|
|
|
buildInfo = promauto.NewGaugeVec(prometheus.GaugeOpts{
|
|
Namespace: Namespace,
|
|
Subsystem: Subsystem,
|
|
Name: "build_info",
|
|
Help: "Build information",
|
|
}, []string{"version"})
|
|
eventsOutstandingAcks = promauto.NewGauge(prometheus.GaugeOpts{
|
|
Namespace: Namespace,
|
|
Subsystem: Subsystem,
|
|
Name: "events_outstanding_acks",
|
|
Help: "Number of outstanding acks for events",
|
|
})
|
|
eventsUnprocessed = promauto.NewGauge(prometheus.GaugeOpts{
|
|
Namespace: Namespace,
|
|
Subsystem: Subsystem,
|
|
Name: "events_unprocessed",
|
|
Help: "Number of unprocessed events",
|
|
})
|
|
eventsRedelivered = promauto.NewGauge(prometheus.GaugeOpts{
|
|
Namespace: Namespace,
|
|
Subsystem: Subsystem,
|
|
Name: "events_redelivered",
|
|
Help: "Number of redelivered events",
|
|
})
|
|
finished = promauto.NewCounterVec(prometheus.CounterOpts{
|
|
Namespace: Namespace,
|
|
Subsystem: Subsystem,
|
|
Name: "finished",
|
|
Help: "Number of finished postprocessing events",
|
|
}, []string{"status"})
|
|
duration = promauto.NewHistogramVec(prometheus.HistogramOpts{
|
|
Namespace: Namespace,
|
|
Subsystem: Subsystem,
|
|
Name: "duration_seconds",
|
|
Help: "Duration of postprocessing operations in seconds",
|
|
Buckets: []float64{0.1, 0.5, 1, 2.5, 5, 10, 30, 60, 120, 300, 600, 1200},
|
|
}, []string{"status"})
|
|
)
|
|
|
|
// Metrics defines the available metrics of this service.
|
|
type Metrics struct {
|
|
// Counter *prometheus.CounterVec
|
|
BuildInfo *prometheus.GaugeVec
|
|
EventsOutstandingAcks prometheus.Gauge
|
|
EventsUnprocessed prometheus.Gauge
|
|
EventsRedelivered prometheus.Gauge
|
|
Finished *prometheus.CounterVec
|
|
Duration *prometheus.HistogramVec
|
|
}
|
|
|
|
// New initializes the available metrics.
|
|
func New() *Metrics {
|
|
m := &Metrics{
|
|
BuildInfo: buildInfo,
|
|
EventsOutstandingAcks: eventsOutstandingAcks,
|
|
EventsUnprocessed: eventsUnprocessed,
|
|
EventsRedelivered: eventsRedelivered,
|
|
Finished: finished,
|
|
Duration: duration,
|
|
}
|
|
|
|
return m
|
|
}
|