2021-03-15 13:09:27 +00:00
|
|
|
package engine
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
2023-05-19 08:17:19 +00:00
|
|
|
|
2024-06-24 14:12:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/metrics"
|
2023-06-14 08:00:44 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
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)
|
|
|
|
|
2024-03-12 14:36:26 +00:00
|
|
|
IncRefillObjectsCount(shardID, path string, size int, success bool)
|
|
|
|
SetRefillPercent(shardID, path string, percent uint32)
|
|
|
|
SetRefillStatus(shardID, path, status string)
|
2024-09-03 09:18:10 +00:00
|
|
|
SetEvacuationInProgress(shardID string, value bool)
|
2024-03-12 14:36:26 +00:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2024-02-13 06:09:47 +00:00
|
|
|
func (m *gcMetrics) SetShardID(id string) {
|
|
|
|
m.shardID = id
|
|
|
|
}
|
|
|
|
|
2023-05-29 14:32:13 +00:00
|
|
|
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)
|
|
|
|
}
|
2024-10-03 07:40:56 +00:00
|
|
|
|
|
|
|
type (
|
|
|
|
noopMetrics struct{}
|
|
|
|
noopWriteCacheMetrics struct{}
|
|
|
|
noopGCMetrics struct{}
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
_ MetricRegister = noopMetrics{}
|
|
|
|
_ metrics.WriteCacheMetrics = noopWriteCacheMetrics{}
|
|
|
|
_ metrics.GCMetrics = noopGCMetrics{}
|
|
|
|
)
|
|
|
|
|
|
|
|
func (noopMetrics) AddMethodDuration(string, time.Duration) {}
|
|
|
|
func (noopMetrics) SetObjectCounter(string, string, uint64) {}
|
|
|
|
func (noopMetrics) AddToObjectCounter(string, string, int) {}
|
|
|
|
func (noopMetrics) SetMode(string, mode.Mode) {}
|
|
|
|
func (noopMetrics) AddToContainerSize(string, int64) {}
|
|
|
|
func (noopMetrics) DeleteContainerSize(string) {}
|
|
|
|
func (noopMetrics) DeleteContainerCount(string) {}
|
|
|
|
func (noopMetrics) AddToPayloadCounter(string, int64) {}
|
|
|
|
func (noopMetrics) IncErrorCounter(string) {}
|
|
|
|
func (noopMetrics) ClearErrorCounter(string) {}
|
|
|
|
func (noopMetrics) DeleteShardMetrics(string) {}
|
|
|
|
func (noopMetrics) SetContainerObjectCounter(string, string, string, uint64) {}
|
|
|
|
func (noopMetrics) IncContainerObjectCounter(string, string, string) {}
|
|
|
|
func (noopMetrics) SubContainerObjectCounter(string, string, string, uint64) {}
|
|
|
|
func (noopMetrics) IncRefillObjectsCount(string, string, int, bool) {}
|
|
|
|
func (noopMetrics) SetRefillPercent(string, string, uint32) {}
|
|
|
|
func (noopMetrics) SetRefillStatus(string, string, string) {}
|
|
|
|
func (noopMetrics) SetEvacuationInProgress(string, bool) {}
|
|
|
|
func (noopMetrics) WriteCache() metrics.WriteCacheMetrics { return noopWriteCacheMetrics{} }
|
|
|
|
func (noopMetrics) GC() metrics.GCMetrics { return noopGCMetrics{} }
|
|
|
|
|
|
|
|
func (noopWriteCacheMetrics) AddMethodDuration(string, string, string, string, bool, time.Duration) {}
|
|
|
|
func (noopWriteCacheMetrics) SetActualCount(string, string, string, uint64) {}
|
|
|
|
func (noopWriteCacheMetrics) SetEstimateSize(string, string, string, uint64) {}
|
|
|
|
func (noopWriteCacheMetrics) SetMode(string, string) {}
|
|
|
|
func (noopWriteCacheMetrics) IncOperationCounter(string, string, string, string, metrics.NullBool) {}
|
|
|
|
func (noopWriteCacheMetrics) Close(string, string) {}
|
|
|
|
|
|
|
|
func (noopGCMetrics) AddRunDuration(string, time.Duration, bool) {}
|
|
|
|
func (noopGCMetrics) AddDeletedCount(string, uint64, uint64) {}
|
|
|
|
func (noopGCMetrics) AddExpiredObjectCollectionDuration(string, time.Duration, bool, string) {}
|
|
|
|
func (noopGCMetrics) AddInhumedObjectCount(string, uint64, string) {}
|