diff --git a/pkg/local_object_storage/engine/writecache.go b/pkg/local_object_storage/engine/writecache.go index b947f12f..2e518c6f 100644 --- a/pkg/local_object_storage/engine/writecache.go +++ b/pkg/local_object_storage/engine/writecache.go @@ -102,3 +102,7 @@ func (m *writeCacheMetrics) Evict(st writecache.StorageType) { m.metrics.DecActualCount(m.shardID, st.String()) m.metrics.IncOperationCounter(m.shardID, "Evict", metrics.NullBool{}, st.String()) } + +func (m *writeCacheMetrics) Close() { + m.metrics.Close(m.shardID) +} diff --git a/pkg/local_object_storage/writecache/metrics.go b/pkg/local_object_storage/writecache/metrics.go index e20c7e65..957bf277 100644 --- a/pkg/local_object_storage/writecache/metrics.go +++ b/pkg/local_object_storage/writecache/metrics.go @@ -28,6 +28,7 @@ type Metrics interface { SetEstimateSize(db, fstree uint64) SetMode(m mode.Mode) SetActualCounters(db, fstree uint64) + Close() } type metricsStub struct{} @@ -47,3 +48,5 @@ func (s *metricsStub) SetActualCounters(uint64, uint64) {} func (s *metricsStub) Flush(bool, StorageType) {} func (s *metricsStub) Evict(StorageType) {} + +func (s *metricsStub) Close() {} diff --git a/pkg/local_object_storage/writecache/writecache.go b/pkg/local_object_storage/writecache/writecache.go index 664beff8..6fa0e36d 100644 --- a/pkg/local_object_storage/writecache/writecache.go +++ b/pkg/local_object_storage/writecache/writecache.go @@ -170,5 +170,6 @@ func (c *cache) Close() error { c.db = nil } } + c.metrics.Close() return nil } diff --git a/pkg/metrics/writecache.go b/pkg/metrics/writecache.go index 33c58fc6..31636a29 100644 --- a/pkg/metrics/writecache.go +++ b/pkg/metrics/writecache.go @@ -34,6 +34,8 @@ type WriteCacheMetrics interface { SetMode(shardID string, mode string) IncOperationCounter(shardID string, operation string, success NullBool, storageType string) + + Close(shardID string) } type writeCacheMetrics struct { @@ -155,6 +157,14 @@ func (m *writeCacheMetrics) IncOperationCounter(shardID string, operation string }).Inc() } +func (m *writeCacheMetrics) Close(shardID string) { + m.SetMode(shardID, "CLOSED") + m.methodDuration.DeletePartialMatch(prometheus.Labels{wcShardID: shardID}) + m.operationCounter.DeletePartialMatch(prometheus.Labels{wcShardID: shardID}) + m.actualCount.DeletePartialMatch(prometheus.Labels{wcShardID: shardID}) + m.estimatedSize.DeletePartialMatch(prometheus.Labels{wcShardID: shardID}) +} + func newWCGaugeVec(name, help string, labels []string) *prometheus.GaugeVec { return metrics.NewGaugeVec(prometheus.GaugeOpts{ Namespace: namespace,