frostfs-node/pkg/metrics/mode.go
Dmitrii Stepanov 4449006862 [#424] metrics: Use mode value as metric value for shard
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
2023-06-14 18:26:19 +03:00

39 lines
867 B
Go

package metrics
import (
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
"github.com/prometheus/client_golang/prometheus"
)
type shardIDModeValue struct {
modeValue *prometheus.GaugeVec
}
func newShardIDMode(subsystem, name, help string) *shardIDModeValue {
return &shardIDModeValue{
modeValue: metrics.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: name,
Help: help,
}, []string{wcShardID, wcMode}),
}
}
func (m *shardIDModeValue) SetMode(shardID string, mode string) {
m.modeValue.DeletePartialMatch(prometheus.Labels{
wcShardID: shardID,
})
m.modeValue.With(prometheus.Labels{
wcShardID: shardID,
wcMode: mode,
}).Set(1)
}
func (m *shardIDModeValue) Delete(shardID string) {
m.modeValue.DeletePartialMatch(prometheus.Labels{
wcShardID: shardID,
})
}