diff --git a/internal/metrics/writecache.go b/internal/metrics/writecache.go index 1b708f710..9caaf734e 100644 --- a/internal/metrics/writecache.go +++ b/internal/metrics/writecache.go @@ -9,7 +9,7 @@ import ( ) type WriteCacheMetrics interface { - AddMethodDuration(shardID, path, storageType, method string, success bool, d time.Duration) + AddMethodDuration(shardID, path, storageType, method string, success bool, d time.Duration, ioTag string) SetActualCount(shardID, path, storageType string, count uint64) SetEstimateSize(shardID, path, storageType string, size uint64) SetMode(shardID, mode string) @@ -35,7 +35,7 @@ func newWriteCacheMetrics() *writeCacheMetrics { Subsystem: writeCacheSubsystem, Name: "request_duration_seconds", Help: "Writecache request process duration", - }, []string{shardIDLabel, successLabel, storageLabel, methodLabel, pathLabel}), + }, []string{shardIDLabel, successLabel, storageLabel, methodLabel, pathLabel, ioTagLabel}), operationCounter: metrics.NewCounterVec(prometheus.CounterOpts{ Namespace: namespace, Subsystem: writeCacheSubsystem, @@ -48,7 +48,7 @@ func newWriteCacheMetrics() *writeCacheMetrics { } } -func (m *writeCacheMetrics) AddMethodDuration(shardID, path, storageType, method string, success bool, d time.Duration) { +func (m *writeCacheMetrics) AddMethodDuration(shardID, path, storageType, method string, success bool, d time.Duration, ioTag string) { m.methodDuration.With( prometheus.Labels{ shardIDLabel: shardID, @@ -56,6 +56,7 @@ func (m *writeCacheMetrics) AddMethodDuration(shardID, path, storageType, method storageLabel: storageType, methodLabel: method, pathLabel: path, + ioTagLabel: ioTag, }, ).Observe(d.Seconds()) } diff --git a/pkg/local_object_storage/engine/metrics.go b/pkg/local_object_storage/engine/metrics.go index 963292d83..d23143549 100644 --- a/pkg/local_object_storage/engine/metrics.go +++ b/pkg/local_object_storage/engine/metrics.go @@ -80,12 +80,13 @@ func (noopMetrics) SetEvacuationInProgress(string, bool) {} func (noopMetrics) WriteCache() WriteCacheMetrics { return noopWriteCacheMetrics{} } func (noopMetrics) GC() GCMetrics { return noopGCMetrics{} } -func (noopWriteCacheMetrics) AddMethodDuration(string, string, string, string, bool, time.Duration) {} -func (noopWriteCacheMetrics) SetActualCount(string, string, string, uint64) {} -func (noopWriteCacheMetrics) SetEstimateSize(string, string, string, uint64) {} -func (noopWriteCacheMetrics) SetMode(string, string) {} -func (noopWriteCacheMetrics) IncOperationCounter(string, string, string, string, metrics.NullBool) {} -func (noopWriteCacheMetrics) Close(string, string) {} +func (noopWriteCacheMetrics) AddMethodDuration(string, string, string, string, bool, time.Duration, string) { +} +func (noopWriteCacheMetrics) SetActualCount(string, string, string, uint64) {} +func (noopWriteCacheMetrics) SetEstimateSize(string, string, string, uint64) {} +func (noopWriteCacheMetrics) SetMode(string, string) {} +func (noopWriteCacheMetrics) IncOperationCounter(string, string, string, string, metrics.NullBool) {} +func (noopWriteCacheMetrics) Close(string, string) {} func (noopGCMetrics) AddRunDuration(string, time.Duration, bool) {} func (noopGCMetrics) AddDeletedCount(string, uint64, uint64) {} diff --git a/pkg/local_object_storage/engine/writecache.go b/pkg/local_object_storage/engine/writecache.go index e9ba3410f..9a0dda035 100644 --- a/pkg/local_object_storage/engine/writecache.go +++ b/pkg/local_object_storage/engine/writecache.go @@ -157,16 +157,16 @@ func (m *writeCacheMetrics) SetShardID(id string) { m.shardID = id } -func (m *writeCacheMetrics) Get(d time.Duration, success bool, st writecache.StorageType) { - m.metrics.AddMethodDuration(m.shardID, m.path, st.String(), "Get", success, d) +func (m *writeCacheMetrics) Get(d time.Duration, success bool, st writecache.StorageType, ioTag string) { + m.metrics.AddMethodDuration(m.shardID, m.path, st.String(), "Get", success, d, ioTag) } -func (m *writeCacheMetrics) Delete(d time.Duration, success bool, st writecache.StorageType) { - m.metrics.AddMethodDuration(m.shardID, m.path, st.String(), "Delete", success, d) +func (m *writeCacheMetrics) Delete(d time.Duration, success bool, st writecache.StorageType, ioTag string) { + m.metrics.AddMethodDuration(m.shardID, m.path, st.String(), "Delete", success, d, ioTag) } -func (m *writeCacheMetrics) Put(d time.Duration, success bool, st writecache.StorageType) { - m.metrics.AddMethodDuration(m.shardID, m.path, st.String(), "Put", success, d) +func (m *writeCacheMetrics) Put(d time.Duration, success bool, st writecache.StorageType, ioTag string) { + m.metrics.AddMethodDuration(m.shardID, m.path, st.String(), "Put", success, d, ioTag) } func (m *writeCacheMetrics) SetEstimateSize(size uint64) { diff --git a/pkg/local_object_storage/writecache/delete.go b/pkg/local_object_storage/writecache/delete.go index 94a0a40db..0e494c540 100644 --- a/pkg/local_object_storage/writecache/delete.go +++ b/pkg/local_object_storage/writecache/delete.go @@ -4,6 +4,7 @@ import ( "context" "time" + "git.frostfs.info/TrueCloudLab/frostfs-node/internal/qos" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common" storagelog "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/log" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/metaerr" @@ -29,7 +30,7 @@ func (c *cache) Delete(ctx context.Context, addr oid.Address) error { storageType := StorageTypeUndefined startedAt := time.Now() defer func() { - c.metrics.Delete(time.Since(startedAt), deleted, storageType) + c.metrics.Delete(time.Since(startedAt), deleted, storageType, qos.IOTagStringFromContext(ctx)) }() if !c.modeMtx.TryRLock() { diff --git a/pkg/local_object_storage/writecache/get.go b/pkg/local_object_storage/writecache/get.go index c0847a65f..a96212790 100644 --- a/pkg/local_object_storage/writecache/get.go +++ b/pkg/local_object_storage/writecache/get.go @@ -5,6 +5,7 @@ import ( "context" "time" + "git.frostfs.info/TrueCloudLab/frostfs-node/internal/qos" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/metaerr" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr" @@ -46,7 +47,7 @@ func (c *cache) getInternal(ctx context.Context, addr oid.Address) (*objectSDK.O storageType := StorageTypeUndefined startedAt := time.Now() defer func() { - c.metrics.Get(time.Since(startedAt), found, storageType) + c.metrics.Get(time.Since(startedAt), found, storageType, qos.IOTagStringFromContext(ctx)) }() res, err := c.fsTree.Get(ctx, common.GetPrm{Address: addr}) diff --git a/pkg/local_object_storage/writecache/metrics.go b/pkg/local_object_storage/writecache/metrics.go index e3641f85e..c8d1bdd01 100644 --- a/pkg/local_object_storage/writecache/metrics.go +++ b/pkg/local_object_storage/writecache/metrics.go @@ -20,9 +20,9 @@ const ( type Metrics interface { SetShardID(string) - Get(d time.Duration, success bool, st StorageType) - Delete(d time.Duration, success bool, st StorageType) - Put(d time.Duration, success bool, st StorageType) + Get(d time.Duration, success bool, st StorageType, ioTag string) + Delete(d time.Duration, success bool, st StorageType, ioTag string) + Put(d time.Duration, success bool, st StorageType, ioTag string) Flush(success bool, st StorageType) Evict(st StorageType) @@ -41,11 +41,11 @@ func (metricsStub) SetShardID(string) {} func (metricsStub) SetPath(string) {} -func (metricsStub) Get(time.Duration, bool, StorageType) {} +func (metricsStub) Get(time.Duration, bool, StorageType, string) {} -func (metricsStub) Delete(time.Duration, bool, StorageType) {} +func (metricsStub) Delete(time.Duration, bool, StorageType, string) {} -func (metricsStub) Put(time.Duration, bool, StorageType) {} +func (metricsStub) Put(time.Duration, bool, StorageType, string) {} func (metricsStub) SetEstimateSize(uint64) {} diff --git a/pkg/local_object_storage/writecache/put.go b/pkg/local_object_storage/writecache/put.go index 7da5c4d3a..f9434a380 100644 --- a/pkg/local_object_storage/writecache/put.go +++ b/pkg/local_object_storage/writecache/put.go @@ -4,6 +4,7 @@ import ( "context" "time" + "git.frostfs.info/TrueCloudLab/frostfs-node/internal/qos" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common" storagelog "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/log" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/metaerr" @@ -30,7 +31,7 @@ func (c *cache) Put(ctx context.Context, prm common.PutPrm) (common.PutRes, erro added := false storageType := StorageTypeUndefined defer func() { - c.metrics.Put(time.Since(startedAt), added, storageType) + c.metrics.Put(time.Since(startedAt), added, storageType, qos.IOTagStringFromContext(ctx)) }() if !c.modeMtx.TryRLock() {