[#9999] writecache: Add IO tag label to metrics

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2025-02-18 11:55:56 +03:00
parent 81746f33e3
commit 2e8bc23292
Signed by: dstepanov-yadro
GPG key ID: 237AF1A763293BC0
7 changed files with 29 additions and 24 deletions

View file

@ -9,7 +9,7 @@ import (
) )
type WriteCacheMetrics interface { 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) SetActualCount(shardID, path, storageType string, count uint64)
SetEstimateSize(shardID, path, storageType string, size uint64) SetEstimateSize(shardID, path, storageType string, size uint64)
SetMode(shardID, mode string) SetMode(shardID, mode string)
@ -35,7 +35,7 @@ func newWriteCacheMetrics() *writeCacheMetrics {
Subsystem: writeCacheSubsystem, Subsystem: writeCacheSubsystem,
Name: "request_duration_seconds", Name: "request_duration_seconds",
Help: "Writecache request process duration", Help: "Writecache request process duration",
}, []string{shardIDLabel, successLabel, storageLabel, methodLabel, pathLabel}), }, []string{shardIDLabel, successLabel, storageLabel, methodLabel, pathLabel, ioTagLabel}),
operationCounter: metrics.NewCounterVec(prometheus.CounterOpts{ operationCounter: metrics.NewCounterVec(prometheus.CounterOpts{
Namespace: namespace, Namespace: namespace,
Subsystem: writeCacheSubsystem, 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( m.methodDuration.With(
prometheus.Labels{ prometheus.Labels{
shardIDLabel: shardID, shardIDLabel: shardID,
@ -56,6 +56,7 @@ func (m *writeCacheMetrics) AddMethodDuration(shardID, path, storageType, method
storageLabel: storageType, storageLabel: storageType,
methodLabel: method, methodLabel: method,
pathLabel: path, pathLabel: path,
ioTagLabel: ioTag,
}, },
).Observe(d.Seconds()) ).Observe(d.Seconds())
} }

View file

@ -80,12 +80,13 @@ func (noopMetrics) SetEvacuationInProgress(string, bool) {}
func (noopMetrics) WriteCache() WriteCacheMetrics { return noopWriteCacheMetrics{} } func (noopMetrics) WriteCache() WriteCacheMetrics { return noopWriteCacheMetrics{} }
func (noopMetrics) GC() GCMetrics { return noopGCMetrics{} } func (noopMetrics) GC() GCMetrics { return noopGCMetrics{} }
func (noopWriteCacheMetrics) AddMethodDuration(string, string, string, string, bool, time.Duration) {} 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) SetActualCount(string, string, string, uint64) {}
func (noopWriteCacheMetrics) SetMode(string, string) {} func (noopWriteCacheMetrics) SetEstimateSize(string, string, string, uint64) {}
func (noopWriteCacheMetrics) IncOperationCounter(string, string, string, string, metrics.NullBool) {} func (noopWriteCacheMetrics) SetMode(string, string) {}
func (noopWriteCacheMetrics) Close(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) AddRunDuration(string, time.Duration, bool) {}
func (noopGCMetrics) AddDeletedCount(string, uint64, uint64) {} func (noopGCMetrics) AddDeletedCount(string, uint64, uint64) {}

View file

@ -157,16 +157,16 @@ func (m *writeCacheMetrics) SetShardID(id string) {
m.shardID = id m.shardID = id
} }
func (m *writeCacheMetrics) Get(d time.Duration, success bool, st writecache.StorageType) { 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) 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) { 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) 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) { 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) m.metrics.AddMethodDuration(m.shardID, m.path, st.String(), "Put", success, d, ioTag)
} }
func (m *writeCacheMetrics) SetEstimateSize(size uint64) { func (m *writeCacheMetrics) SetEstimateSize(size uint64) {

View file

@ -4,6 +4,7 @@ import (
"context" "context"
"time" "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/blobstor/common"
storagelog "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/log" 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" "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 storageType := StorageTypeUndefined
startedAt := time.Now() startedAt := time.Now()
defer func() { 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() { if !c.modeMtx.TryRLock() {

View file

@ -5,6 +5,7 @@ import (
"context" "context"
"time" "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/blobstor/common"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/metaerr" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/metaerr"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr" "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 storageType := StorageTypeUndefined
startedAt := time.Now() startedAt := time.Now()
defer func() { 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}) res, err := c.fsTree.Get(ctx, common.GetPrm{Address: addr})

View file

@ -20,9 +20,9 @@ const (
type Metrics interface { type Metrics interface {
SetShardID(string) SetShardID(string)
Get(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) Delete(d time.Duration, success bool, st StorageType, ioTag string)
Put(d time.Duration, success bool, st StorageType) Put(d time.Duration, success bool, st StorageType, ioTag string)
Flush(success bool, st StorageType) Flush(success bool, st StorageType)
Evict(st StorageType) Evict(st StorageType)
@ -41,11 +41,11 @@ func (metricsStub) SetShardID(string) {}
func (metricsStub) SetPath(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) {} func (metricsStub) SetEstimateSize(uint64) {}

View file

@ -4,6 +4,7 @@ import (
"context" "context"
"time" "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/blobstor/common"
storagelog "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/log" 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" "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 added := false
storageType := StorageTypeUndefined storageType := StorageTypeUndefined
defer func() { 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() { if !c.modeMtx.TryRLock() {