[#1445] shard/gc: Remove object type from duration metric
Before, expired objects of each type were handled in separate go-routines. Now expired objects of all types will be handled in one go-routine. There's no way to use object type when writing expired object handling duration metric, so remove object type from this metric. Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
parent
24709df702
commit
ab1362c297
3 changed files with 19 additions and 20 deletions
|
@ -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())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,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) {
|
||||||
|
@ -87,7 +87,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) {}
|
||||||
|
|
|
@ -86,17 +86,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
|
||||||
|
@ -355,7 +355,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))
|
||||||
|
@ -469,7 +469,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
|
||||||
|
@ -542,7 +542,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))
|
||||||
|
|
Loading…
Add table
Reference in a new issue