[#645] blobovnicza: Fix metrics

Fix naming. Add `metrics.Close` call. Fix `metrics.Close` implemetation.

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2023-10-04 14:41:42 +03:00
parent fba369ec34
commit 49668c3bfa
7 changed files with 55 additions and 43 deletions

View file

@ -808,7 +808,7 @@ func (c *cfg) getSubstorageOpts(shCfg shardCfg) []blobstor.SubStorage {
if c.metricsCollector != nil { if c.metricsCollector != nil {
blobTreeOpts = append(blobTreeOpts, blobTreeOpts = append(blobTreeOpts,
blobovniczatree.WithMetrics( blobovniczatree.WithMetrics(
lsmetrics.NewBlobovniczaTreeMetrics(sRead.path, c.metricsCollector.BlobobvnizcaTreeMetrics()), lsmetrics.NewBlobovniczaTreeMetrics(sRead.path, c.metricsCollector.BlobovniczaTreeMetrics()),
), ),
) )
} }

View file

@ -97,7 +97,7 @@ func TestBlobovnicza(t *testing.T) {
testPutGet(t, blz, oidtest.Address(), objSizeLim, nil, nil) testPutGet(t, blz, oidtest.Address(), objSizeLim, nil, nil)
} }
// blobovnizca accepts object event if full // blobovnicza accepts object event if full
testPutGet(t, blz, oidtest.Address(), 1024, func(err error) bool { testPutGet(t, blz, oidtest.Address(), 1024, func(err error) bool {
return err == nil return err == nil
}, nil) }, nil)

View file

@ -50,7 +50,7 @@ func (b *Blobovniczas) Close() error {
b.dbCache.Close() // order important b.dbCache.Close() // order important
b.activeDBManager.Close() b.activeDBManager.Close()
b.commondbManager.Close() b.commondbManager.Close()
b.metrics.Close()
return nil return nil
} }

View file

@ -15,7 +15,7 @@ import (
"go.uber.org/zap" "go.uber.org/zap"
) )
// Put saves object in the maximum weight blobobnicza. // Put saves object in the maximum weight blobovnicza.
// //
// returns error if could not save object in any blobovnicza. // returns error if could not save object in any blobovnicza.
func (b *Blobovniczas) Put(ctx context.Context, prm common.PutPrm) (common.PutRes, error) { func (b *Blobovniczas) Put(ctx context.Context, prm common.PutPrm) (common.PutRes, error) {

View file

@ -8,7 +8,7 @@ import (
metrics_impl "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/metrics" metrics_impl "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/metrics"
) )
func NewBlobovniczaTreeMetrics(path string, m metrics_impl.BlobobvnizcaMetrics) blobovniczatree.Metrics { func NewBlobovniczaTreeMetrics(path string, m metrics_impl.BlobovniczaMetrics) blobovniczatree.Metrics {
return &blobovniczaTreeMetrics{ return &blobovniczaTreeMetrics{
path: path, path: path,
shardID: undefined, shardID: undefined,
@ -19,7 +19,7 @@ func NewBlobovniczaTreeMetrics(path string, m metrics_impl.BlobobvnizcaMetrics)
type blobovniczaTreeMetrics struct { type blobovniczaTreeMetrics struct {
shardID string shardID string
path string path string
m metrics_impl.BlobobvnizcaMetrics m metrics_impl.BlobovniczaMetrics
} }
func (m *blobovniczaTreeMetrics) Blobovnicza() blobovnicza.Metrics { func (m *blobovniczaTreeMetrics) Blobovnicza() blobovnicza.Metrics {
@ -35,48 +35,48 @@ func (m *blobovniczaTreeMetrics) SetParentID(parentID string) {
} }
func (m *blobovniczaTreeMetrics) SetMode(readOnly bool) { func (m *blobovniczaTreeMetrics) SetMode(readOnly bool) {
m.m.SetBlobobvnizcaTreeMode(m.shardID, m.path, readOnly) m.m.SetBlobovniczaTreeMode(m.shardID, m.path, readOnly)
} }
func (m *blobovniczaTreeMetrics) Close() { func (m *blobovniczaTreeMetrics) Close() {
m.m.CloseBlobobvnizcaTree(m.shardID, m.path) m.m.CloseBlobovniczaTree(m.shardID, m.path)
} }
func (m *blobovniczaTreeMetrics) Delete(d time.Duration, success, withStorageID bool) { func (m *blobovniczaTreeMetrics) Delete(d time.Duration, success, withStorageID bool) {
m.m.BlobobvnizcaTreeMethodDuration(m.shardID, m.path, "Delete", d, success, metrics_impl.NullBool{Valid: true, Bool: withStorageID}) m.m.BlobovniczaTreeMethodDuration(m.shardID, m.path, "Delete", d, success, metrics_impl.NullBool{Valid: true, Bool: withStorageID})
} }
func (m *blobovniczaTreeMetrics) Exists(d time.Duration, success, withStorageID bool) { func (m *blobovniczaTreeMetrics) Exists(d time.Duration, success, withStorageID bool) {
m.m.BlobobvnizcaTreeMethodDuration(m.shardID, m.path, "Exists", d, success, metrics_impl.NullBool{Valid: true, Bool: withStorageID}) m.m.BlobovniczaTreeMethodDuration(m.shardID, m.path, "Exists", d, success, metrics_impl.NullBool{Valid: true, Bool: withStorageID})
} }
func (m *blobovniczaTreeMetrics) GetRange(d time.Duration, size int, success, withStorageID bool) { func (m *blobovniczaTreeMetrics) GetRange(d time.Duration, size int, success, withStorageID bool) {
m.m.BlobobvnizcaTreeMethodDuration(m.shardID, m.path, "GetRange", d, success, metrics_impl.NullBool{Valid: true, Bool: withStorageID}) m.m.BlobovniczaTreeMethodDuration(m.shardID, m.path, "GetRange", d, success, metrics_impl.NullBool{Valid: true, Bool: withStorageID})
if success { if success {
m.m.AddBlobobvnizcaTreeGet(m.shardID, m.path, size) m.m.AddBlobovniczaTreeGet(m.shardID, m.path, size)
} }
} }
func (m *blobovniczaTreeMetrics) Get(d time.Duration, size int, success, withStorageID bool) { func (m *blobovniczaTreeMetrics) Get(d time.Duration, size int, success, withStorageID bool) {
m.m.BlobobvnizcaTreeMethodDuration(m.shardID, m.path, "Get", d, success, metrics_impl.NullBool{Valid: true, Bool: withStorageID}) m.m.BlobovniczaTreeMethodDuration(m.shardID, m.path, "Get", d, success, metrics_impl.NullBool{Valid: true, Bool: withStorageID})
if success { if success {
m.m.AddBlobobvnizcaTreeGet(m.shardID, m.path, size) m.m.AddBlobovniczaTreeGet(m.shardID, m.path, size)
} }
} }
func (m *blobovniczaTreeMetrics) Iterate(d time.Duration, success bool) { func (m *blobovniczaTreeMetrics) Iterate(d time.Duration, success bool) {
m.m.BlobobvnizcaTreeMethodDuration(m.shardID, m.path, "Iterate", d, success, metrics_impl.NullBool{}) m.m.BlobovniczaTreeMethodDuration(m.shardID, m.path, "Iterate", d, success, metrics_impl.NullBool{})
} }
func (m *blobovniczaTreeMetrics) Put(d time.Duration, size int, success bool) { func (m *blobovniczaTreeMetrics) Put(d time.Duration, size int, success bool) {
m.m.BlobobvnizcaTreeMethodDuration(m.shardID, m.path, "Put", d, success, metrics_impl.NullBool{}) m.m.BlobovniczaTreeMethodDuration(m.shardID, m.path, "Put", d, success, metrics_impl.NullBool{})
if success { if success {
m.m.AddBlobobvnizcaTreePut(m.shardID, m.path, size) m.m.AddBlobovniczaTreePut(m.shardID, m.path, size)
} }
} }
type blobovniczaMetrics struct { type blobovniczaMetrics struct {
m metrics_impl.BlobobvnizcaMetrics m metrics_impl.BlobovniczaMetrics
shardID func() string shardID func() string
path string path string
} }

View file

@ -8,12 +8,12 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
) )
type BlobobvnizcaMetrics interface { type BlobovniczaMetrics interface {
SetBlobobvnizcaTreeMode(shardID, path string, readOnly bool) SetBlobovniczaTreeMode(shardID, path string, readOnly bool)
CloseBlobobvnizcaTree(shardID, path string) CloseBlobovniczaTree(shardID, path string)
BlobobvnizcaTreeMethodDuration(shardID, path string, method string, d time.Duration, success bool, withStorageID NullBool) BlobovniczaTreeMethodDuration(shardID, path string, method string, d time.Duration, success bool, withStorageID NullBool)
AddBlobobvnizcaTreePut(shardID, path string, size int) AddBlobovniczaTreePut(shardID, path string, size int)
AddBlobobvnizcaTreeGet(shardID, path string, size int) AddBlobovniczaTreeGet(shardID, path string, size int)
AddOpenBlobovniczaSize(shardID, path string, size uint64) AddOpenBlobovniczaSize(shardID, path string, size uint64)
SubOpenBlobovniczaSize(shardID, path string, size uint64) SubOpenBlobovniczaSize(shardID, path string, size uint64)
@ -78,11 +78,11 @@ func newBlobovnicza() *blobovnicza {
} }
} }
func (b *blobovnicza) SetBlobobvnizcaTreeMode(shardID, path string, readOnly bool) { func (b *blobovnicza) SetBlobovniczaTreeMode(shardID, path string, readOnly bool) {
b.treeMode.SetMode(shardID, path, modeFromBool(readOnly)) b.treeMode.SetMode(shardID, path, modeFromBool(readOnly))
} }
func (b *blobovnicza) CloseBlobobvnizcaTree(shardID, path string) { func (b *blobovnicza) CloseBlobovniczaTree(shardID, path string) {
b.treeMode.SetMode(shardID, path, closedMode) b.treeMode.SetMode(shardID, path, closedMode)
b.treeReqDuration.DeletePartialMatch(prometheus.Labels{ b.treeReqDuration.DeletePartialMatch(prometheus.Labels{
shardIDLabel: shardID, shardIDLabel: shardID,
@ -96,9 +96,21 @@ func (b *blobovnicza) CloseBlobobvnizcaTree(shardID, path string) {
shardIDLabel: shardID, shardIDLabel: shardID,
pathLabel: path, pathLabel: path,
}) })
b.treeOpenSize.DeletePartialMatch(prometheus.Labels{
shardIDLabel: shardID,
pathLabel: path,
})
b.treeOpenItems.DeletePartialMatch(prometheus.Labels{
shardIDLabel: shardID,
pathLabel: path,
})
b.treeOpenCounter.DeletePartialMatch(prometheus.Labels{
shardIDLabel: shardID,
pathLabel: path,
})
} }
func (b *blobovnicza) BlobobvnizcaTreeMethodDuration(shardID, path string, method string, d time.Duration, success bool, withStorageID NullBool) { func (b *blobovnicza) BlobovniczaTreeMethodDuration(shardID, path string, method string, d time.Duration, success bool, withStorageID NullBool) {
b.treeReqDuration.With(prometheus.Labels{ b.treeReqDuration.With(prometheus.Labels{
shardIDLabel: shardID, shardIDLabel: shardID,
pathLabel: path, pathLabel: path,
@ -108,14 +120,14 @@ func (b *blobovnicza) BlobobvnizcaTreeMethodDuration(shardID, path string, metho
}).Observe(d.Seconds()) }).Observe(d.Seconds())
} }
func (b *blobovnicza) AddBlobobvnizcaTreePut(shardID, path string, size int) { func (b *blobovnicza) AddBlobovniczaTreePut(shardID, path string, size int) {
b.treePut.With(prometheus.Labels{ b.treePut.With(prometheus.Labels{
shardIDLabel: shardID, shardIDLabel: shardID,
pathLabel: path, pathLabel: path,
}).Add(float64(size)) }).Add(float64(size))
} }
func (b *blobovnicza) AddBlobobvnizcaTreeGet(shardID, path string, size int) { func (b *blobovnicza) AddBlobovniczaTreeGet(shardID, path string, size int) {
b.treeGet.With(prometheus.Labels{ b.treeGet.With(prometheus.Labels{
shardIDLabel: shardID, shardIDLabel: shardID,
pathLabel: path, pathLabel: path,

View file

@ -16,7 +16,7 @@ type NodeMetrics struct {
epoch prometheus.Gauge epoch prometheus.Gauge
fstree *fstreeMetrics fstree *fstreeMetrics
blobstore *blobstoreMetrics blobstore *blobstoreMetrics
blobobvnizca *blobovnicza blobovnicza *blobovnicza
metabase *metabaseMetrics metabase *metabaseMetrics
pilorama *piloramaMetrics pilorama *piloramaMetrics
grpc *grpcServerMetrics grpc *grpcServerMetrics
@ -40,17 +40,17 @@ func NewNodeMetrics() *NodeMetrics {
Name: "epoch", Name: "epoch",
Help: "Current epoch as seen by inner-ring node.", Help: "Current epoch as seen by inner-ring node.",
}), }),
fstree: newFSTreeMetrics(), fstree: newFSTreeMetrics(),
blobstore: newBlobstoreMetrics(), blobstore: newBlobstoreMetrics(),
blobobvnizca: newBlobovnicza(), blobovnicza: newBlobovnicza(),
metabase: newMetabaseMetrics(), metabase: newMetabaseMetrics(),
pilorama: newPiloramaMetrics(), pilorama: newPiloramaMetrics(),
grpc: newGrpcServerMetrics(), grpc: newGrpcServerMetrics(),
policer: newPolicerMetrics(), policer: newPolicerMetrics(),
morphClient: newMorphClientMetrics(), morphClient: newMorphClientMetrics(),
morphCache: newMorphCacheMetrics(namespace), morphCache: newMorphCacheMetrics(namespace),
log: logger.NewLogMetrics(namespace), log: logger.NewLogMetrics(namespace),
blobTree: newBlobTreeMetrics(), blobTree: newBlobTreeMetrics(),
} }
} }
@ -87,8 +87,8 @@ func (m *NodeMetrics) Blobstore() BlobstoreMetrics {
return m.blobstore return m.blobstore
} }
func (m *NodeMetrics) BlobobvnizcaTreeMetrics() BlobobvnizcaMetrics { func (m *NodeMetrics) BlobovniczaTreeMetrics() BlobovniczaMetrics {
return m.blobobvnizca return m.blobovnicza
} }
func (m *NodeMetrics) MetabaseMetrics() MetabaseMetrics { func (m *NodeMetrics) MetabaseMetrics() MetabaseMetrics {