2021-03-15 13:09:27 +00:00
|
|
|
package engine
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
2023-05-19 08:17:19 +00:00
|
|
|
|
2023-06-14 08:00:44 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
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
|
|
|
|
2023-06-14 08:00:44 +00:00
|
|
|
SetMode(shardID string, mode mode.Mode)
|
2022-12-01 11:59:22 +00:00
|
|
|
|
|
|
|
AddToContainerSize(cnrID string, size int64)
|
2023-12-27 15:58:36 +00:00
|
|
|
DeleteContainerSize(cnrID string)
|
2023-12-27 15:23:12 +00:00
|
|
|
DeleteContainerCount(cnrID string)
|
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
|
|
|
|
2023-11-02 10:50:52 +00:00
|
|
|
SetContainerObjectCounter(shardID, contID, objectType string, v uint64)
|
|
|
|
IncContainerObjectCounter(shardID, contID, objectType string)
|
|
|
|
SubContainerObjectCounter(shardID, contID, objectType string, v uint64)
|
|
|
|
|
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)
|
|
|
|
}
|