[#373] metrics: Add FSTree metrics

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2023-06-07 17:06:02 +03:00
parent d8ecc69d00
commit 16a142cd0c
8 changed files with 236 additions and 6 deletions

View file

@ -37,3 +37,39 @@ func (m *shardIDModeValue) Delete(shardID string) {
wcShardID: shardID,
})
}
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}),
}
}
func (m *shardIDPathModeValue) SetMode(shardID, path string, mode string) {
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,
})
}