mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-04 11:19:39 -06:00
70 lines
1.6 KiB
Go
70 lines
1.6 KiB
Go
package metrics
|
|
|
|
import (
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
)
|
|
|
|
var (
|
|
// Namespace defines the namespace for the defines metrics.
|
|
Namespace = "ocis"
|
|
|
|
// Subsystem defines the subsystem for the defines metrics.
|
|
Subsystem = "proxy"
|
|
)
|
|
|
|
// Metrics defines the available metrics of this service.
|
|
type Metrics struct {
|
|
Counter *prometheus.CounterVec
|
|
Latency *prometheus.SummaryVec
|
|
Duration *prometheus.HistogramVec
|
|
BuildInfo *prometheus.GaugeVec
|
|
}
|
|
|
|
// New initializes the available metrics.
|
|
func New() *Metrics {
|
|
m := &Metrics{
|
|
Counter: prometheus.NewCounterVec(prometheus.CounterOpts{
|
|
Namespace: Namespace,
|
|
Subsystem: Subsystem,
|
|
Name: "proxy_total",
|
|
Help: "How many proxy requests processed",
|
|
}, []string{}),
|
|
Latency: prometheus.NewSummaryVec(prometheus.SummaryOpts{
|
|
Namespace: Namespace,
|
|
Subsystem: Subsystem,
|
|
Name: "proxy_latency_microseconds",
|
|
Help: "proxy request latencies in microseconds",
|
|
}, []string{}),
|
|
Duration: prometheus.NewHistogramVec(prometheus.HistogramOpts{
|
|
Namespace: Namespace,
|
|
Subsystem: Subsystem,
|
|
Name: "proxy_duration_seconds",
|
|
Help: "proxy method request time in seconds",
|
|
}, []string{}),
|
|
BuildInfo: prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
|
Namespace: Namespace,
|
|
Subsystem: Subsystem,
|
|
Name: "build_info",
|
|
Help: "Build Information",
|
|
}, []string{"versions"}),
|
|
}
|
|
|
|
prometheus.Register(
|
|
m.Counter,
|
|
)
|
|
|
|
prometheus.Register(
|
|
m.Latency,
|
|
)
|
|
|
|
prometheus.Register(
|
|
m.Duration,
|
|
)
|
|
|
|
prometheus.Register(
|
|
m.BuildInfo,
|
|
)
|
|
|
|
return m
|
|
}
|