[#1445] shard/gc: Remove object type from metrics

Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
Aleksey Savchuk 2024-12-17 16:00:43 +03:00
parent e2a6663ef6
commit 8d6d829348
Signed by: a-savchuk
GPG key ID: 70C0A7FF6F9C4639
3 changed files with 19 additions and 20 deletions

View file

@ -11,7 +11,7 @@ import (
type GCMetrics interface { type GCMetrics interface {
AddRunDuration(shardID string, d time.Duration, success bool) AddRunDuration(shardID string, d time.Duration, success bool)
AddDeletedCount(shardID string, deleted, failed uint64) 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) AddInhumedObjectCount(shardID string, count uint64, objectType string)
} }
@ -71,11 +71,10 @@ func (m *gcMetrics) AddDeletedCount(shardID string, deleted, failed uint64) {
}).Add(float64(failed)) }).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{ m.expCollectDuration.With(prometheus.Labels{
shardIDLabel: shardID, shardIDLabel: shardID,
successLabel: strconv.FormatBool(success), successLabel: strconv.FormatBool(success),
objectTypeLabel: objectType,
}).Add(d.Seconds()) }).Add(d.Seconds())
} }

View file

@ -61,8 +61,8 @@ func (m *gcMetrics) AddDeletedCount(deleted, failed uint64) {
m.storage.AddDeletedCount(m.shardID, deleted, failed) m.storage.AddDeletedCount(m.shardID, deleted, failed)
} }
func (m *gcMetrics) AddExpiredObjectCollectionDuration(d time.Duration, success bool, objectType string) { func (m *gcMetrics) AddExpiredObjectCollectionDuration(d time.Duration, success bool) {
m.storage.AddExpiredObjectCollectionDuration(m.shardID, d, success, objectType) m.storage.AddExpiredObjectCollectionDuration(m.shardID, d, success)
} }
func (m *gcMetrics) AddInhumedObjectCount(count uint64, objectType string) { 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) IncOperationCounter(string, string, string, string, metrics.NullBool) {}
func (noopWriteCacheMetrics) Close(string, string) {} 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) {}
func (noopGCMetrics) AddExpiredObjectCollectionDuration(string, time.Duration, bool, string) {} func (noopGCMetrics) AddExpiredObjectCollectionDuration(string, time.Duration, bool) {}
func (noopGCMetrics) AddInhumedObjectCount(string, uint64, string) {} func (noopGCMetrics) AddInhumedObjectCount(string, uint64, string) {}

View file

@ -84,17 +84,17 @@ type GCMectrics interface {
SetShardID(string) SetShardID(string)
AddRunDuration(d time.Duration, success bool) AddRunDuration(d time.Duration, success bool)
AddDeletedCount(deleted, failed uint64) AddDeletedCount(deleted, failed uint64)
AddExpiredObjectCollectionDuration(d time.Duration, success bool, objectType string) AddExpiredObjectCollectionDuration(d time.Duration, success bool)
AddInhumedObjectCount(count uint64, objectType string) AddInhumedObjectCount(count uint64, objectType string)
} }
type noopGCMetrics struct{} type noopGCMetrics struct{}
func (m *noopGCMetrics) SetShardID(string) {} func (m *noopGCMetrics) SetShardID(string) {}
func (m *noopGCMetrics) AddRunDuration(time.Duration, bool) {} func (m *noopGCMetrics) AddRunDuration(time.Duration, bool) {}
func (m *noopGCMetrics) AddDeletedCount(uint64, uint64) {} func (m *noopGCMetrics) AddDeletedCount(uint64, uint64) {}
func (m *noopGCMetrics) AddExpiredObjectCollectionDuration(time.Duration, bool, string) {} func (m *noopGCMetrics) AddExpiredObjectCollectionDuration(time.Duration, bool) {}
func (m *noopGCMetrics) AddInhumedObjectCount(uint64, string) {} func (m *noopGCMetrics) AddInhumedObjectCount(uint64, string) {}
type gc struct { type gc struct {
*gcCfg *gcCfg
@ -353,7 +353,7 @@ func (s *Shard) collectExpiredObjects(ctx context.Context, e Event) {
startedAt := time.Now() startedAt := time.Now()
defer func() { 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)) 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() startedAt := time.Now()
defer func() { 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 epoch := e.(newEpoch).epoch
@ -540,7 +540,7 @@ func (s *Shard) collectExpiredLockObjects(ctx context.Context, e Event) {
startedAt := time.Now() startedAt := time.Now()
defer func() { 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)) s.log.Debug(ctx, logs.ShardGCCollectingExpiredLocksStarted, zap.Uint64("epoch", e.(newEpoch).epoch))