forked from TrueCloudLab/frostfs-node
[#966] node: Add path of the write_cache to metric labels
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
parent
4730ecfdb8
commit
c9efaa5819
4 changed files with 40 additions and 27 deletions
|
@ -9,12 +9,12 @@ import (
|
|||
)
|
||||
|
||||
type WriteCacheMetrics interface {
|
||||
AddMethodDuration(shardID, storageType, method string, success bool, d time.Duration)
|
||||
SetActualCount(shardID, storageType string, count uint64)
|
||||
SetEstimateSize(shardID, storageType string, size uint64)
|
||||
AddMethodDuration(shardID, path, storageType, method string, success bool, d time.Duration)
|
||||
SetActualCount(shardID, path, storageType string, count uint64)
|
||||
SetEstimateSize(shardID, path, storageType string, size uint64)
|
||||
SetMode(shardID, mode string)
|
||||
IncOperationCounter(shardID, storageType, operation string, success NullBool)
|
||||
Close(shardID string)
|
||||
IncOperationCounter(shardID, path, storageType, operation string, success NullBool)
|
||||
Close(shardID, path string)
|
||||
}
|
||||
|
||||
type writeCacheMetrics struct {
|
||||
|
@ -41,35 +41,38 @@ func newWriteCacheMetrics() *writeCacheMetrics {
|
|||
Subsystem: writeCacheSubsystem,
|
||||
Name: "operations_total",
|
||||
Help: "The number of writecache operations processed",
|
||||
}, []string{shardIDLabel, storageLabel, successLabel, operationLabel}),
|
||||
actualCount: newWCGaugeVec("actual_objects_total", "Actual objects count in writecache", []string{shardIDLabel, storageLabel}),
|
||||
estimatedSize: newWCGaugeVec("estimated_size_bytes", "Estimated writecache size", []string{shardIDLabel, storageLabel}),
|
||||
}, []string{shardIDLabel, storageLabel, successLabel, operationLabel, pathLabel}),
|
||||
actualCount: newWCGaugeVec("actual_objects_total", "Actual objects count in writecache", []string{shardIDLabel, storageLabel, pathLabel}),
|
||||
estimatedSize: newWCGaugeVec("estimated_size_bytes", "Estimated writecache size", []string{shardIDLabel, storageLabel, pathLabel}),
|
||||
mode: newShardIDMode(writeCacheSubsystem, "mode_info", "Writecache mode value"),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *writeCacheMetrics) AddMethodDuration(shardID, storageType, method string, success bool, d time.Duration) {
|
||||
func (m *writeCacheMetrics) AddMethodDuration(shardID, path, storageType, method string, success bool, d time.Duration) {
|
||||
m.methodDuration.With(
|
||||
prometheus.Labels{
|
||||
shardIDLabel: shardID,
|
||||
successLabel: strconv.FormatBool(success),
|
||||
storageLabel: storageType,
|
||||
methodLabel: method,
|
||||
pathLabel: path,
|
||||
},
|
||||
).Observe(d.Seconds())
|
||||
}
|
||||
|
||||
func (m *writeCacheMetrics) SetActualCount(shardID, storageType string, count uint64) {
|
||||
func (m *writeCacheMetrics) SetActualCount(shardID, path, storageType string, count uint64) {
|
||||
m.actualCount.With(prometheus.Labels{
|
||||
shardIDLabel: shardID,
|
||||
storageLabel: storageType,
|
||||
pathLabel: path,
|
||||
}).Set(float64(count))
|
||||
}
|
||||
|
||||
func (m *writeCacheMetrics) SetEstimateSize(shardID, storageType string, size uint64) {
|
||||
func (m *writeCacheMetrics) SetEstimateSize(shardID, path, storageType string, size uint64) {
|
||||
m.estimatedSize.With(prometheus.Labels{
|
||||
shardIDLabel: shardID,
|
||||
storageLabel: storageType,
|
||||
pathLabel: path,
|
||||
}).Set(float64(size))
|
||||
}
|
||||
|
||||
|
@ -77,21 +80,22 @@ func (m *writeCacheMetrics) SetMode(shardID string, mode string) {
|
|||
m.mode.SetMode(shardID, mode)
|
||||
}
|
||||
|
||||
func (m *writeCacheMetrics) IncOperationCounter(shardID, storageType, operation string, success NullBool) {
|
||||
func (m *writeCacheMetrics) IncOperationCounter(shardID, path, storageType, operation string, success NullBool) {
|
||||
m.operationCounter.With(prometheus.Labels{
|
||||
shardIDLabel: shardID,
|
||||
storageLabel: storageType,
|
||||
operationLabel: operation,
|
||||
successLabel: success.String(),
|
||||
pathLabel: path,
|
||||
}).Inc()
|
||||
}
|
||||
|
||||
func (m *writeCacheMetrics) Close(shardID string) {
|
||||
func (m *writeCacheMetrics) Close(shardID, path string) {
|
||||
m.mode.Delete(shardID)
|
||||
m.methodDuration.DeletePartialMatch(prometheus.Labels{shardIDLabel: shardID})
|
||||
m.operationCounter.DeletePartialMatch(prometheus.Labels{shardIDLabel: shardID})
|
||||
m.actualCount.DeletePartialMatch(prometheus.Labels{shardIDLabel: shardID})
|
||||
m.estimatedSize.DeletePartialMatch(prometheus.Labels{shardIDLabel: shardID})
|
||||
m.methodDuration.DeletePartialMatch(prometheus.Labels{shardIDLabel: shardID, pathLabel: path})
|
||||
m.operationCounter.DeletePartialMatch(prometheus.Labels{shardIDLabel: shardID, pathLabel: path})
|
||||
m.actualCount.DeletePartialMatch(prometheus.Labels{shardIDLabel: shardID, pathLabel: path})
|
||||
m.estimatedSize.DeletePartialMatch(prometheus.Labels{shardIDLabel: shardID, pathLabel: path})
|
||||
}
|
||||
|
||||
func newWCGaugeVec(name, help string, labels []string) *prometheus.GaugeVec {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue