52 lines
1.5 KiB
Go
52 lines
1.5 KiB
Go
package metrics
|
|
|
|
import (
|
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
)
|
|
|
|
type QoSMetrics struct {
|
|
opsCounter *prometheus.GaugeVec
|
|
}
|
|
|
|
func newQoSMetrics() *QoSMetrics {
|
|
return &QoSMetrics{
|
|
opsCounter: metrics.NewGaugeVec(prometheus.GaugeOpts{
|
|
Namespace: namespace,
|
|
Subsystem: qosSubsystem,
|
|
Name: "operations_total",
|
|
Help: "Count of pending, in progree, completed and failed due of resource exhausted error operations for each shard",
|
|
}, []string{shardIDLabel, operationLabel, ioTagLabel, typeLabel}),
|
|
}
|
|
}
|
|
|
|
func (m *QoSMetrics) SetOperationTagCounters(shardID, operation, tag string, pending, inProgress, completed, resourceExhausted uint64) {
|
|
m.opsCounter.With(prometheus.Labels{
|
|
shardIDLabel: shardID,
|
|
operationLabel: operation,
|
|
ioTagLabel: tag,
|
|
typeLabel: "pending",
|
|
}).Set(float64(pending))
|
|
m.opsCounter.With(prometheus.Labels{
|
|
shardIDLabel: shardID,
|
|
operationLabel: operation,
|
|
ioTagLabel: tag,
|
|
typeLabel: "in_progress",
|
|
}).Set(float64(inProgress))
|
|
m.opsCounter.With(prometheus.Labels{
|
|
shardIDLabel: shardID,
|
|
operationLabel: operation,
|
|
ioTagLabel: tag,
|
|
typeLabel: "completed",
|
|
}).Set(float64(completed))
|
|
m.opsCounter.With(prometheus.Labels{
|
|
shardIDLabel: shardID,
|
|
operationLabel: operation,
|
|
ioTagLabel: tag,
|
|
typeLabel: "resource_exhausted",
|
|
}).Set(float64(resourceExhausted))
|
|
}
|
|
|
|
func (m *QoSMetrics) Close(shardID string) {
|
|
m.opsCounter.DeletePartialMatch(prometheus.Labels{shardIDLabel: shardID})
|
|
}
|