2023-06-14 08:00:44 +00:00
|
|
|
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,
|
2023-06-16 07:13:22 +00:00
|
|
|
}, []string{shardIDLabel, modeLabel}),
|
2023-06-14 08:00:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-27 12:34:29 +00:00
|
|
|
func (m *shardIDModeValue) SetMode(shardID, mode string) {
|
2023-06-14 08:00:44 +00:00
|
|
|
m.modeValue.DeletePartialMatch(prometheus.Labels{
|
2023-06-16 07:13:22 +00:00
|
|
|
shardIDLabel: shardID,
|
2023-06-14 08:00:44 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
m.modeValue.With(prometheus.Labels{
|
2023-06-16 07:13:22 +00:00
|
|
|
shardIDLabel: shardID,
|
|
|
|
modeLabel: mode,
|
2023-06-14 08:00:44 +00:00
|
|
|
}).Set(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *shardIDModeValue) Delete(shardID string) {
|
|
|
|
m.modeValue.DeletePartialMatch(prometheus.Labels{
|
2023-06-16 07:13:22 +00:00
|
|
|
shardIDLabel: shardID,
|
2023-06-14 08:00:44 +00:00
|
|
|
})
|
|
|
|
}
|
2023-06-07 14:06:02 +00:00
|
|
|
|
|
|
|
type shardIDPathModeValue struct {
|
|
|
|
modeValue *prometheus.GaugeVec
|
|
|
|
}
|
|
|
|
|
|
|
|
func newShardIDPathMode(subsystem, name, help string) *shardIDPathModeValue {
|
|
|
|
return &shardIDPathModeValue{
|
|
|
|
modeValue: metrics.NewGaugeVec(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
Namespace: namespace,
|
|
|
|
Subsystem: subsystem,
|
|
|
|
Name: name,
|
|
|
|
Help: help,
|
|
|
|
}, []string{shardIDLabel, pathLabel, modeLabel}),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-27 12:34:29 +00:00
|
|
|
func (m *shardIDPathModeValue) SetMode(shardID, path, mode string) {
|
2023-06-07 14:06:02 +00:00
|
|
|
m.modeValue.DeletePartialMatch(prometheus.Labels{
|
|
|
|
shardIDLabel: shardID,
|
|
|
|
pathLabel: path,
|
|
|
|
})
|
|
|
|
|
|
|
|
m.modeValue.With(prometheus.Labels{
|
|
|
|
shardIDLabel: shardID,
|
|
|
|
pathLabel: path,
|
|
|
|
modeLabel: mode,
|
|
|
|
}).Set(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *shardIDPathModeValue) Delete(shardID, path string) {
|
|
|
|
m.modeValue.DeletePartialMatch(prometheus.Labels{
|
|
|
|
shardIDLabel: shardID,
|
|
|
|
pathLabel: path,
|
|
|
|
})
|
|
|
|
}
|
2023-06-07 15:04:23 +00:00
|
|
|
|
2024-03-12 14:36:26 +00:00
|
|
|
func (m *shardIDPathModeValue) DeleteByShardID(shardID string) {
|
|
|
|
m.modeValue.DeletePartialMatch(prometheus.Labels{
|
|
|
|
shardIDLabel: shardID,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-06-07 15:04:23 +00:00
|
|
|
func modeFromBool(readOnly bool) string {
|
|
|
|
modeValue := readWriteMode
|
|
|
|
if readOnly {
|
|
|
|
modeValue = readOnlyMode
|
|
|
|
}
|
|
|
|
return modeValue
|
|
|
|
}
|