2021-03-15 13:09:27 +00:00
|
|
|
package engine
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
2023-05-19 08:17:19 +00:00
|
|
|
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/metrics"
|
2021-03-15 13:09:27 +00:00
|
|
|
)
|
|
|
|
|
2021-03-16 08:14:56 +00:00
|
|
|
type MetricRegister interface {
|
2023-06-13 16:48:15 +00:00
|
|
|
AddMethodDuration(method string, d time.Duration)
|
2022-08-19 16:49:09 +00:00
|
|
|
|
2022-09-09 11:37:35 +00:00
|
|
|
SetObjectCounter(shardID, objectType string, v uint64)
|
|
|
|
AddToObjectCounter(shardID, objectType string, delta int)
|
2022-12-09 13:52:13 +00:00
|
|
|
|
|
|
|
SetReadonly(shardID string, readonly bool)
|
2022-12-01 11:59:22 +00:00
|
|
|
|
|
|
|
AddToContainerSize(cnrID string, size int64)
|
2023-01-25 14:01:25 +00:00
|
|
|
AddToPayloadCounter(shardID string, size int64)
|
2023-06-01 14:28:04 +00:00
|
|
|
IncErrorCounter(shardID string)
|
|
|
|
ClearErrorCounter(shardID string)
|
2023-06-13 16:48:15 +00:00
|
|
|
DeleteShardMetrics(shardID string)
|
2023-05-19 08:17:19 +00:00
|
|
|
|
|
|
|
WriteCache() metrics.WriteCacheMetrics
|
2023-05-29 14:32:13 +00:00
|
|
|
GC() metrics.GCMetrics
|
2021-03-15 13:09:27 +00:00
|
|
|
}
|
|
|
|
|
2023-06-13 16:48:15 +00:00
|
|
|
func elapsed(method string, addFunc func(method string, d time.Duration)) func() {
|
2021-03-15 13:09:27 +00:00
|
|
|
t := time.Now()
|
|
|
|
|
|
|
|
return func() {
|
2023-06-13 16:48:15 +00:00
|
|
|
addFunc(method, time.Since(t))
|
2021-03-15 13:09:27 +00:00
|
|
|
}
|
|
|
|
}
|
2023-05-29 14:32:13 +00:00
|
|
|
|
|
|
|
type gcMetrics struct {
|
|
|
|
storage metrics.GCMetrics
|
|
|
|
shardID string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *gcMetrics) AddRunDuration(d time.Duration, success bool) {
|
|
|
|
m.storage.AddRunDuration(m.shardID, d, success)
|
|
|
|
}
|
|
|
|
|
|
|
|
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) AddInhumedObjectCount(count uint64, objectType string) {
|
|
|
|
m.storage.AddInhumedObjectCount(m.shardID, count, objectType)
|
|
|
|
}
|