mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-04-23 03:00:50 -04:00
41 lines
827 B
Go
41 lines
827 B
Go
package controller
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
|
)
|
|
|
|
type cacheMetrics struct {
|
|
cacheHits *prometheus.CounterVec
|
|
cacheMisses *prometheus.CounterVec
|
|
}
|
|
|
|
var (
|
|
initMetricsOnce sync.Once
|
|
cm *cacheMetrics
|
|
)
|
|
|
|
func initCacheMetrics() *cacheMetrics {
|
|
initMetricsOnce.Do(func() {
|
|
cm = &cacheMetrics{
|
|
cacheHits: promauto.NewCounterVec(
|
|
prometheus.CounterOpts{
|
|
Name: "bridge_history_api_cache_hits_total",
|
|
Help: "The total number of cache hits",
|
|
},
|
|
[]string{"api"},
|
|
),
|
|
cacheMisses: promauto.NewCounterVec(
|
|
prometheus.CounterOpts{
|
|
Name: "bridge_history_api_cache_misses_total",
|
|
Help: "The total number of cache misses",
|
|
},
|
|
[]string{"api"},
|
|
),
|
|
}
|
|
})
|
|
return cm
|
|
}
|