forked from TrueCloudLab/frostfs-node
[#966] node: Refactor WriteCacheMetrics interface
Grouping common fields of methods will enhance the readability of the interface. Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
parent
52bebe9452
commit
4730ecfdb8
3 changed files with 20 additions and 20 deletions
|
@ -150,20 +150,20 @@ func (m *writeCacheMetrics) SetShardID(id string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *writeCacheMetrics) Get(d time.Duration, success bool, st writecache.StorageType) {
|
func (m *writeCacheMetrics) Get(d time.Duration, success bool, st writecache.StorageType) {
|
||||||
m.metrics.AddMethodDuration(m.shardID, "Get", success, d, st.String())
|
m.metrics.AddMethodDuration(m.shardID, st.String(), "Get", success, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *writeCacheMetrics) Delete(d time.Duration, success bool, st writecache.StorageType) {
|
func (m *writeCacheMetrics) Delete(d time.Duration, success bool, st writecache.StorageType) {
|
||||||
m.metrics.AddMethodDuration(m.shardID, "Delete", success, d, st.String())
|
m.metrics.AddMethodDuration(m.shardID, st.String(), "Delete", success, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *writeCacheMetrics) Put(d time.Duration, success bool, st writecache.StorageType) {
|
func (m *writeCacheMetrics) Put(d time.Duration, success bool, st writecache.StorageType) {
|
||||||
m.metrics.AddMethodDuration(m.shardID, "Put", success, d, st.String())
|
m.metrics.AddMethodDuration(m.shardID, st.String(), "Put", success, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *writeCacheMetrics) SetEstimateSize(db, fstree uint64) {
|
func (m *writeCacheMetrics) SetEstimateSize(db, fstree uint64) {
|
||||||
m.metrics.SetEstimateSize(m.shardID, db, writecache.StorageTypeDB.String())
|
m.metrics.SetEstimateSize(m.shardID, writecache.StorageTypeDB.String(), db)
|
||||||
m.metrics.SetEstimateSize(m.shardID, fstree, writecache.StorageTypeFSTree.String())
|
m.metrics.SetEstimateSize(m.shardID, writecache.StorageTypeFSTree.String(), fstree)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *writeCacheMetrics) SetMode(mode mode.Mode) {
|
func (m *writeCacheMetrics) SetMode(mode mode.Mode) {
|
||||||
|
@ -171,16 +171,16 @@ func (m *writeCacheMetrics) SetMode(mode mode.Mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *writeCacheMetrics) SetActualCounters(db, fstree uint64) {
|
func (m *writeCacheMetrics) SetActualCounters(db, fstree uint64) {
|
||||||
m.metrics.SetActualCount(m.shardID, db, writecache.StorageTypeDB.String())
|
m.metrics.SetActualCount(m.shardID, writecache.StorageTypeDB.String(), db)
|
||||||
m.metrics.SetActualCount(m.shardID, fstree, writecache.StorageTypeFSTree.String())
|
m.metrics.SetActualCount(m.shardID, writecache.StorageTypeFSTree.String(), fstree)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *writeCacheMetrics) Flush(success bool, st writecache.StorageType) {
|
func (m *writeCacheMetrics) Flush(success bool, st writecache.StorageType) {
|
||||||
m.metrics.IncOperationCounter(m.shardID, "Flush", metrics.NullBool{Bool: success, Valid: true}, st.String())
|
m.metrics.IncOperationCounter(m.shardID, st.String(), "Flush", metrics.NullBool{Bool: success, Valid: true})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *writeCacheMetrics) Evict(st writecache.StorageType) {
|
func (m *writeCacheMetrics) Evict(st writecache.StorageType) {
|
||||||
m.metrics.IncOperationCounter(m.shardID, "Evict", metrics.NullBool{}, st.String())
|
m.metrics.IncOperationCounter(m.shardID, st.String(), "Evict", metrics.NullBool{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *writeCacheMetrics) Close() {
|
func (m *writeCacheMetrics) Close() {
|
||||||
|
|
|
@ -21,7 +21,7 @@ func newShardIDMode(subsystem, name, help string) *shardIDModeValue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *shardIDModeValue) SetMode(shardID string, mode string) {
|
func (m *shardIDModeValue) SetMode(shardID, mode string) {
|
||||||
m.modeValue.DeletePartialMatch(prometheus.Labels{
|
m.modeValue.DeletePartialMatch(prometheus.Labels{
|
||||||
shardIDLabel: shardID,
|
shardIDLabel: shardID,
|
||||||
})
|
})
|
||||||
|
@ -54,7 +54,7 @@ func newShardIDPathMode(subsystem, name, help string) *shardIDPathModeValue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *shardIDPathModeValue) SetMode(shardID, path string, mode string) {
|
func (m *shardIDPathModeValue) SetMode(shardID, path, mode string) {
|
||||||
m.modeValue.DeletePartialMatch(prometheus.Labels{
|
m.modeValue.DeletePartialMatch(prometheus.Labels{
|
||||||
shardIDLabel: shardID,
|
shardIDLabel: shardID,
|
||||||
pathLabel: path,
|
pathLabel: path,
|
||||||
|
|
|
@ -9,11 +9,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type WriteCacheMetrics interface {
|
type WriteCacheMetrics interface {
|
||||||
AddMethodDuration(shardID string, method string, success bool, d time.Duration, storageType string)
|
AddMethodDuration(shardID, storageType, method string, success bool, d time.Duration)
|
||||||
SetActualCount(shardID string, count uint64, storageType string)
|
SetActualCount(shardID, storageType string, count uint64)
|
||||||
SetEstimateSize(shardID string, size uint64, storageType string)
|
SetEstimateSize(shardID, storageType string, size uint64)
|
||||||
SetMode(shardID string, mode string)
|
SetMode(shardID, mode string)
|
||||||
IncOperationCounter(shardID string, operation string, success NullBool, storageType string)
|
IncOperationCounter(shardID, storageType, operation string, success NullBool)
|
||||||
Close(shardID string)
|
Close(shardID string)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ func newWriteCacheMetrics() *writeCacheMetrics {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *writeCacheMetrics) AddMethodDuration(shardID string, method string, success bool, d time.Duration, storageType string) {
|
func (m *writeCacheMetrics) AddMethodDuration(shardID, storageType, method string, success bool, d time.Duration) {
|
||||||
m.methodDuration.With(
|
m.methodDuration.With(
|
||||||
prometheus.Labels{
|
prometheus.Labels{
|
||||||
shardIDLabel: shardID,
|
shardIDLabel: shardID,
|
||||||
|
@ -59,14 +59,14 @@ func (m *writeCacheMetrics) AddMethodDuration(shardID string, method string, suc
|
||||||
).Observe(d.Seconds())
|
).Observe(d.Seconds())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *writeCacheMetrics) SetActualCount(shardID string, count uint64, storageType string) {
|
func (m *writeCacheMetrics) SetActualCount(shardID, storageType string, count uint64) {
|
||||||
m.actualCount.With(prometheus.Labels{
|
m.actualCount.With(prometheus.Labels{
|
||||||
shardIDLabel: shardID,
|
shardIDLabel: shardID,
|
||||||
storageLabel: storageType,
|
storageLabel: storageType,
|
||||||
}).Set(float64(count))
|
}).Set(float64(count))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *writeCacheMetrics) SetEstimateSize(shardID string, size uint64, storageType string) {
|
func (m *writeCacheMetrics) SetEstimateSize(shardID, storageType string, size uint64) {
|
||||||
m.estimatedSize.With(prometheus.Labels{
|
m.estimatedSize.With(prometheus.Labels{
|
||||||
shardIDLabel: shardID,
|
shardIDLabel: shardID,
|
||||||
storageLabel: storageType,
|
storageLabel: storageType,
|
||||||
|
@ -77,7 +77,7 @@ func (m *writeCacheMetrics) SetMode(shardID string, mode string) {
|
||||||
m.mode.SetMode(shardID, mode)
|
m.mode.SetMode(shardID, mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *writeCacheMetrics) IncOperationCounter(shardID string, operation string, success NullBool, storageType string) {
|
func (m *writeCacheMetrics) IncOperationCounter(shardID, storageType, operation string, success NullBool) {
|
||||||
m.operationCounter.With(prometheus.Labels{
|
m.operationCounter.With(prometheus.Labels{
|
||||||
shardIDLabel: shardID,
|
shardIDLabel: shardID,
|
||||||
storageLabel: storageType,
|
storageLabel: storageType,
|
||||||
|
|
Loading…
Reference in a new issue