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