feat(api): implement new api handler

This commit is contained in:
nils måsén 2023-10-21 19:35:41 +02:00
parent 72e437f173
commit 47091761a5
17 changed files with 571 additions and 294 deletions

View file

@ -45,12 +45,11 @@ func (metrics *Metrics) Register(metric *Metric) {
metrics.channel <- metric
}
// Default creates a new metrics handler if none exists, otherwise returns the existing one
func Default() *Metrics {
// Init creates a new metrics handler if none exists
func Init() {
if metrics != nil {
return metrics
return
}
metrics = &Metrics{
scanned: promauto.NewGauge(prometheus.GaugeOpts{
Name: "watchtower_containers_scanned",
@ -76,6 +75,11 @@ func Default() *Metrics {
}
go metrics.HandleUpdate(metrics.channel)
}
// Default creates a new metrics handler if none exists, otherwise returns the existing one
func Default() *Metrics {
Init()
return metrics
}