From 8d6d829348af308f39594a55e7daa0ffd64b9aeb Mon Sep 17 00:00:00 2001 From: Aleksey Savchuk Date: Tue, 17 Dec 2024 16:00:43 +0300 Subject: [PATCH] [#1445] shard/gc: Remove object type from metrics Signed-off-by: Aleksey Savchuk --- internal/metrics/gc.go | 9 ++++----- pkg/local_object_storage/engine/metrics.go | 12 ++++++------ pkg/local_object_storage/shard/gc.go | 18 +++++++++--------- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/internal/metrics/gc.go b/internal/metrics/gc.go index 53bfef0e5..664944b05 100644 --- a/internal/metrics/gc.go +++ b/internal/metrics/gc.go @@ -11,7 +11,7 @@ import ( type GCMetrics interface { AddRunDuration(shardID string, d time.Duration, success bool) AddDeletedCount(shardID string, deleted, failed uint64) - AddExpiredObjectCollectionDuration(shardID string, d time.Duration, success bool, objectType string) + AddExpiredObjectCollectionDuration(shardID string, d time.Duration, success bool) AddInhumedObjectCount(shardID string, count uint64, objectType string) } @@ -71,11 +71,10 @@ func (m *gcMetrics) AddDeletedCount(shardID string, deleted, failed uint64) { }).Add(float64(failed)) } -func (m *gcMetrics) AddExpiredObjectCollectionDuration(shardID string, d time.Duration, success bool, objectType string) { +func (m *gcMetrics) AddExpiredObjectCollectionDuration(shardID string, d time.Duration, success bool) { m.expCollectDuration.With(prometheus.Labels{ - shardIDLabel: shardID, - successLabel: strconv.FormatBool(success), - objectTypeLabel: objectType, + shardIDLabel: shardID, + successLabel: strconv.FormatBool(success), }).Add(d.Seconds()) } diff --git a/pkg/local_object_storage/engine/metrics.go b/pkg/local_object_storage/engine/metrics.go index 75936206d..55b7b74d6 100644 --- a/pkg/local_object_storage/engine/metrics.go +++ b/pkg/local_object_storage/engine/metrics.go @@ -61,8 +61,8 @@ func (m *gcMetrics) AddDeletedCount(deleted, failed uint64) { m.storage.AddDeletedCount(m.shardID, deleted, failed) } -func (m *gcMetrics) AddExpiredObjectCollectionDuration(d time.Duration, success bool, objectType string) { - m.storage.AddExpiredObjectCollectionDuration(m.shardID, d, success, objectType) +func (m *gcMetrics) AddExpiredObjectCollectionDuration(d time.Duration, success bool) { + m.storage.AddExpiredObjectCollectionDuration(m.shardID, d, success) } func (m *gcMetrics) AddInhumedObjectCount(count uint64, objectType string) { @@ -109,7 +109,7 @@ 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) {} -func (noopGCMetrics) AddExpiredObjectCollectionDuration(string, time.Duration, bool, string) {} -func (noopGCMetrics) AddInhumedObjectCount(string, uint64, string) {} +func (noopGCMetrics) AddRunDuration(string, time.Duration, bool) {} +func (noopGCMetrics) AddDeletedCount(string, uint64, uint64) {} +func (noopGCMetrics) AddExpiredObjectCollectionDuration(string, time.Duration, bool) {} +func (noopGCMetrics) AddInhumedObjectCount(string, uint64, string) {} diff --git a/pkg/local_object_storage/shard/gc.go b/pkg/local_object_storage/shard/gc.go index f0ca4446a..3087ca1b1 100644 --- a/pkg/local_object_storage/shard/gc.go +++ b/pkg/local_object_storage/shard/gc.go @@ -84,17 +84,17 @@ type GCMectrics interface { SetShardID(string) AddRunDuration(d time.Duration, success bool) AddDeletedCount(deleted, failed uint64) - AddExpiredObjectCollectionDuration(d time.Duration, success bool, objectType string) + AddExpiredObjectCollectionDuration(d time.Duration, success bool) AddInhumedObjectCount(count uint64, objectType string) } type noopGCMetrics struct{} -func (m *noopGCMetrics) SetShardID(string) {} -func (m *noopGCMetrics) AddRunDuration(time.Duration, bool) {} -func (m *noopGCMetrics) AddDeletedCount(uint64, uint64) {} -func (m *noopGCMetrics) AddExpiredObjectCollectionDuration(time.Duration, bool, string) {} -func (m *noopGCMetrics) AddInhumedObjectCount(uint64, string) {} +func (m *noopGCMetrics) SetShardID(string) {} +func (m *noopGCMetrics) AddRunDuration(time.Duration, bool) {} +func (m *noopGCMetrics) AddDeletedCount(uint64, uint64) {} +func (m *noopGCMetrics) AddExpiredObjectCollectionDuration(time.Duration, bool) {} +func (m *noopGCMetrics) AddInhumedObjectCount(uint64, string) {} type gc struct { *gcCfg @@ -353,7 +353,7 @@ func (s *Shard) collectExpiredObjects(ctx context.Context, e Event) { startedAt := time.Now() defer func() { - s.gc.metrics.AddExpiredObjectCollectionDuration(time.Since(startedAt), err == nil, objectTypeRegular) + s.gc.metrics.AddExpiredObjectCollectionDuration(time.Since(startedAt), err == nil) }() s.log.Debug(ctx, logs.ShardGCCollectingExpiredObjectsStarted, zap.Uint64("epoch", e.(newEpoch).epoch)) @@ -467,7 +467,7 @@ func (s *Shard) collectExpiredGraves(ctx context.Context, e Event) { startedAt := time.Now() defer func() { - s.gc.metrics.AddExpiredObjectCollectionDuration(time.Since(startedAt), err == nil, objectTypeTombstone) + s.gc.metrics.AddExpiredObjectCollectionDuration(time.Since(startedAt), err == nil) }() epoch := e.(newEpoch).epoch @@ -540,7 +540,7 @@ func (s *Shard) collectExpiredLockObjects(ctx context.Context, e Event) { startedAt := time.Now() defer func() { - s.gc.metrics.AddExpiredObjectCollectionDuration(time.Since(startedAt), err == nil, objectTypeLock) + s.gc.metrics.AddExpiredObjectCollectionDuration(time.Since(startedAt), err == nil) }() s.log.Debug(ctx, logs.ShardGCCollectingExpiredLocksStarted, zap.Uint64("epoch", e.(newEpoch).epoch))