2023-01-27 12:49:49 -06:00
package metrics
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
type State struct {
2024-01-23 10:03:30 -06:00
StateUpdateDuration prometheus . Histogram
StateFullSyncDuration prometheus . Histogram
r prometheus . Registerer
2023-09-25 04:27:30 -05:00
}
// Registerer exposes the Prometheus register directly. The state package needs this as, it uses a collector to fetch the current alerts by state in the system.
func ( s State ) Registerer ( ) prometheus . Registerer {
return s . r
2023-01-27 12:49:49 -06:00
}
func NewStateMetrics ( r prometheus . Registerer ) * State {
return & State {
2023-09-25 04:27:30 -05:00
r : r ,
2023-08-16 02:04:18 -05:00
StateUpdateDuration : promauto . With ( r ) . NewHistogram (
prometheus . HistogramOpts {
Namespace : Namespace ,
Subsystem : Subsystem ,
Name : "state_calculation_duration_seconds" ,
Help : "The duration of calculation of a single state." ,
Buckets : [ ] float64 { 0.01 , 0.1 , 1 , 2 , 5 , 10 } ,
} ,
) ,
2024-01-23 10:03:30 -06:00
StateFullSyncDuration : promauto . With ( r ) . NewHistogram (
prometheus . HistogramOpts {
Namespace : Namespace ,
Subsystem : Subsystem ,
Name : "state_full_sync_duration_seconds" ,
Help : "The duration of fully synchronizing the state with the database." ,
Buckets : [ ] float64 { 0.01 , 0.1 , 1 , 2 , 5 , 10 , 60 } ,
} ,
) ,
2023-01-27 12:49:49 -06:00
}
}