[#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:
Alexander Chuprov 2024-04-27 15:49:07 +03:00 committed by Evgenii Stratonikov
parent 4730ecfdb8
commit c9efaa5819
4 changed files with 40 additions and 27 deletions

View file

@ -143,6 +143,11 @@ func (e *StorageEngine) SealWriteCache(ctx context.Context, prm SealWriteCachePr
type writeCacheMetrics struct {
shardID string
metrics metrics.WriteCacheMetrics
path string
}
func (m *writeCacheMetrics) SetPath(path string) {
m.path = path
}
func (m *writeCacheMetrics) SetShardID(id string) {
@ -150,20 +155,20 @@ func (m *writeCacheMetrics) SetShardID(id string) {
}
func (m *writeCacheMetrics) Get(d time.Duration, success bool, st writecache.StorageType) {
m.metrics.AddMethodDuration(m.shardID, st.String(), "Get", success, d)
m.metrics.AddMethodDuration(m.shardID, m.path, st.String(), "Get", success, d)
}
func (m *writeCacheMetrics) Delete(d time.Duration, success bool, st writecache.StorageType) {
m.metrics.AddMethodDuration(m.shardID, st.String(), "Delete", success, d)
m.metrics.AddMethodDuration(m.shardID, m.path, st.String(), "Delete", success, d)
}
func (m *writeCacheMetrics) Put(d time.Duration, success bool, st writecache.StorageType) {
m.metrics.AddMethodDuration(m.shardID, st.String(), "Put", success, d)
m.metrics.AddMethodDuration(m.shardID, m.path, st.String(), "Put", success, d)
}
func (m *writeCacheMetrics) SetEstimateSize(db, fstree uint64) {
m.metrics.SetEstimateSize(m.shardID, writecache.StorageTypeDB.String(), db)
m.metrics.SetEstimateSize(m.shardID, writecache.StorageTypeFSTree.String(), fstree)
m.metrics.SetEstimateSize(m.shardID, m.path, writecache.StorageTypeDB.String(), db)
m.metrics.SetEstimateSize(m.shardID, m.path, writecache.StorageTypeFSTree.String(), fstree)
}
func (m *writeCacheMetrics) SetMode(mode mode.Mode) {
@ -171,18 +176,18 @@ func (m *writeCacheMetrics) SetMode(mode mode.Mode) {
}
func (m *writeCacheMetrics) SetActualCounters(db, fstree uint64) {
m.metrics.SetActualCount(m.shardID, writecache.StorageTypeDB.String(), db)
m.metrics.SetActualCount(m.shardID, writecache.StorageTypeFSTree.String(), fstree)
m.metrics.SetActualCount(m.shardID, m.path, writecache.StorageTypeDB.String(), db)
m.metrics.SetActualCount(m.shardID, m.path, writecache.StorageTypeFSTree.String(), fstree)
}
func (m *writeCacheMetrics) Flush(success bool, st writecache.StorageType) {
m.metrics.IncOperationCounter(m.shardID, st.String(), "Flush", metrics.NullBool{Bool: success, Valid: true})
m.metrics.IncOperationCounter(m.shardID, m.path, st.String(), "Flush", metrics.NullBool{Bool: success, Valid: true})
}
func (m *writeCacheMetrics) Evict(st writecache.StorageType) {
m.metrics.IncOperationCounter(m.shardID, st.String(), "Evict", metrics.NullBool{})
m.metrics.IncOperationCounter(m.shardID, m.path, st.String(), "Evict", metrics.NullBool{})
}
func (m *writeCacheMetrics) Close() {
m.metrics.Close(m.shardID)
m.metrics.Close(m.shardID, m.path)
}