* feat(metrics): grand update * feat(metrics): fixed missing part in ee tracer * feat(assets): added missing arg * feat(metrics): fixed naming problems
41 lines
881 B
Go
41 lines
881 B
Go
package heuristics
|
|
|
|
import (
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
)
|
|
|
|
type Heuristics interface {
|
|
IncreaseTotalEvents(eventType string)
|
|
List() []prometheus.Collector
|
|
}
|
|
|
|
type heuristicsImpl struct {
|
|
totalEvents *prometheus.CounterVec
|
|
}
|
|
|
|
func New(serviceName string) Heuristics {
|
|
return &heuristicsImpl{
|
|
totalEvents: newTotalEvents(serviceName),
|
|
}
|
|
}
|
|
|
|
func newTotalEvents(serviceName string) *prometheus.CounterVec {
|
|
return prometheus.NewCounterVec(
|
|
prometheus.CounterOpts{
|
|
Namespace: serviceName,
|
|
Name: "events_total",
|
|
Help: "A counter displaying the number of all processed events",
|
|
},
|
|
[]string{"type"},
|
|
)
|
|
}
|
|
|
|
func (h *heuristicsImpl) IncreaseTotalEvents(eventType string) {
|
|
h.totalEvents.WithLabelValues(eventType).Inc()
|
|
}
|
|
|
|
func (h *heuristicsImpl) List() []prometheus.Collector {
|
|
return []prometheus.Collector{
|
|
h.totalEvents,
|
|
}
|
|
}
|