openreplay/ee/backend/pkg/metrics/heuristics/metrics.go
Alexander 3b3e95a413
Observability upgrade (#3146)
* feat(metrics): grand update

* feat(metrics): fixed missing part in ee tracer

* feat(assets): added missing arg

* feat(metrics): fixed naming problems
2025-03-13 08:09:29 +01:00

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,
}
}