node: Add path of the write_cache to metric labels #1107

Merged
fyrchik merged 3 commits from achuprov/frostfs-node:add_path_writecache_metrics into master 2024-05-02 06:46:49 +00:00
6 changed files with 44 additions and 33 deletions

View file

@ -143,6 +143,11 @@ func (e *StorageEngine) SealWriteCache(ctx context.Context, prm SealWriteCachePr
type writeCacheMetrics struct { type writeCacheMetrics struct {
shardID string shardID string
metrics metrics.WriteCacheMetrics metrics metrics.WriteCacheMetrics
path string
}
func (m *writeCacheMetrics) SetPath(path string) {
m.path = path
} }
func (m *writeCacheMetrics) SetShardID(id string) { func (m *writeCacheMetrics) SetShardID(id string) {
@ -150,20 +155,20 @@ func (m *writeCacheMetrics) SetShardID(id string) {
} }
func (m *writeCacheMetrics) Get(d time.Duration, success bool, st writecache.StorageType) { func (m *writeCacheMetrics) Get(d time.Duration, success bool, st writecache.StorageType) {
m.metrics.AddMethodDuration(m.shardID, "Get", success, d, st.String()) m.metrics.AddMethodDuration(m.shardID, m.path, st.String(), "Get", success, d)
} }
func (m *writeCacheMetrics) Delete(d time.Duration, success bool, st writecache.StorageType) { func (m *writeCacheMetrics) Delete(d time.Duration, success bool, st writecache.StorageType) {
m.metrics.AddMethodDuration(m.shardID, "Delete", success, d, st.String()) m.metrics.AddMethodDuration(m.shardID, m.path, st.String(), "Delete", success, d)
} }
func (m *writeCacheMetrics) Put(d time.Duration, success bool, st writecache.StorageType) { func (m *writeCacheMetrics) Put(d time.Duration, success bool, st writecache.StorageType) {
m.metrics.AddMethodDuration(m.shardID, "Put", success, d, st.String()) m.metrics.AddMethodDuration(m.shardID, m.path, st.String(), "Put", success, d)
} }
func (m *writeCacheMetrics) SetEstimateSize(db, fstree uint64) { func (m *writeCacheMetrics) SetEstimateSize(db, fstree uint64) {
m.metrics.SetEstimateSize(m.shardID, db, writecache.StorageTypeDB.String()) m.metrics.SetEstimateSize(m.shardID, m.path, writecache.StorageTypeDB.String(), db)
m.metrics.SetEstimateSize(m.shardID, fstree, writecache.StorageTypeFSTree.String()) m.metrics.SetEstimateSize(m.shardID, m.path, writecache.StorageTypeFSTree.String(), fstree)
} }
func (m *writeCacheMetrics) SetMode(mode mode.Mode) { func (m *writeCacheMetrics) SetMode(mode mode.Mode) {
@ -171,18 +176,18 @@ func (m *writeCacheMetrics) SetMode(mode mode.Mode) {
} }
func (m *writeCacheMetrics) SetActualCounters(db, fstree uint64) { func (m *writeCacheMetrics) SetActualCounters(db, fstree uint64) {
m.metrics.SetActualCount(m.shardID, db, writecache.StorageTypeDB.String()) m.metrics.SetActualCount(m.shardID, m.path, writecache.StorageTypeDB.String(), db)
m.metrics.SetActualCount(m.shardID, fstree, writecache.StorageTypeFSTree.String()) m.metrics.SetActualCount(m.shardID, m.path, writecache.StorageTypeFSTree.String(), fstree)
} }
func (m *writeCacheMetrics) Flush(success bool, st writecache.StorageType) { func (m *writeCacheMetrics) Flush(success bool, st writecache.StorageType) {
m.metrics.IncOperationCounter(m.shardID, "Flush", metrics.NullBool{Bool: success, Valid: true}, st.String()) m.metrics.IncOperationCounter(m.shardID, m.path, st.String(), "Flush", metrics.NullBool{Bool: success, Valid: true})
} }
func (m *writeCacheMetrics) Evict(st writecache.StorageType) { func (m *writeCacheMetrics) Evict(st writecache.StorageType) {
m.metrics.IncOperationCounter(m.shardID, "Evict", metrics.NullBool{}, st.String()) m.metrics.IncOperationCounter(m.shardID, m.path, st.String(), "Evict", metrics.NullBool{})
} }
func (m *writeCacheMetrics) Close() { func (m *writeCacheMetrics) Close() {
m.metrics.Close(m.shardID) m.metrics.Close(m.shardID, m.path)
} }

View file

@ -182,6 +182,7 @@ func New(opts ...Option) *Shard {
writecache.WithReportErrorFunc(reportFunc), writecache.WithReportErrorFunc(reportFunc),
writecache.WithBlobstor(bs), writecache.WithBlobstor(bs),
writecache.WithMetabase(mb))...) writecache.WithMetabase(mb))...)
s.writeCache.GetMetrics().SetPath(s.writeCache.DumpInfo().Path)
} }
if s.piloramaOpts != nil { if s.piloramaOpts != nil {

View file

@ -29,6 +29,7 @@ type Metrics interface {
SetEstimateSize(db, fstree uint64) SetEstimateSize(db, fstree uint64)
SetMode(m mode.Mode) SetMode(m mode.Mode)
SetActualCounters(db, fstree uint64) SetActualCounters(db, fstree uint64)
SetPath(path string)
Close() Close()
} }
@ -38,6 +39,8 @@ type metricsStub struct{}
func (metricsStub) SetShardID(string) {} func (metricsStub) SetShardID(string) {}
func (metricsStub) SetPath(string) {}
func (metricsStub) Get(time.Duration, bool, StorageType) {} func (metricsStub) Get(time.Duration, bool, StorageType) {}
func (metricsStub) Delete(time.Duration, bool, StorageType) {} func (metricsStub) Delete(time.Duration, bool, StorageType) {}

View file

@ -21,7 +21,7 @@ func newShardIDMode(subsystem, name, help string) *shardIDModeValue {
} }
} }
func (m *shardIDModeValue) SetMode(shardID string, mode string) { func (m *shardIDModeValue) SetMode(shardID, mode string) {
m.modeValue.DeletePartialMatch(prometheus.Labels{ m.modeValue.DeletePartialMatch(prometheus.Labels{
shardIDLabel: shardID, shardIDLabel: shardID,
}) })
@ -54,7 +54,7 @@ func newShardIDPathMode(subsystem, name, help string) *shardIDPathModeValue {
} }
} }
func (m *shardIDPathModeValue) SetMode(shardID, path string, mode string) { func (m *shardIDPathModeValue) SetMode(shardID, path, mode string) {
m.modeValue.DeletePartialMatch(prometheus.Labels{ m.modeValue.DeletePartialMatch(prometheus.Labels{
shardIDLabel: shardID, shardIDLabel: shardID,
pathLabel: path, pathLabel: path,

View file

@ -9,12 +9,12 @@ import (
) )
type WriteCacheMetrics interface { type WriteCacheMetrics interface {
AddMethodDuration(shardID string, method string, success bool, d time.Duration, storageType string) AddMethodDuration(shardID, path, storageType, method string, success bool, d time.Duration)
SetActualCount(shardID string, count uint64, storageType string) SetActualCount(shardID, path, storageType string, count uint64)
SetEstimateSize(shardID string, size uint64, storageType string) SetEstimateSize(shardID, path, storageType string, size uint64)
SetMode(shardID string, mode string) SetMode(shardID, mode string)
IncOperationCounter(shardID string, operation string, success NullBool, storageType string) IncOperationCounter(shardID, path, storageType, operation string, success NullBool)
Close(shardID string) Close(shardID, path string)
} }
type writeCacheMetrics struct { type writeCacheMetrics struct {
@ -41,35 +41,38 @@ func newWriteCacheMetrics() *writeCacheMetrics {
Subsystem: writeCacheSubsystem, Subsystem: writeCacheSubsystem,
Name: "operations_total", Name: "operations_total",
Help: "The number of writecache operations processed", Help: "The number of writecache operations processed",
}, []string{shardIDLabel, storageLabel, successLabel, operationLabel}), }, []string{shardIDLabel, storageLabel, successLabel, operationLabel, pathLabel}),
actualCount: newWCGaugeVec("actual_objects_total", "Actual objects count in writecache", []string{shardIDLabel, storageLabel}), actualCount: newWCGaugeVec("actual_objects_total", "Actual objects count in writecache", []string{shardIDLabel, storageLabel, pathLabel}),
estimatedSize: newWCGaugeVec("estimated_size_bytes", "Estimated writecache size", []string{shardIDLabel, storageLabel}), estimatedSize: newWCGaugeVec("estimated_size_bytes", "Estimated writecache size", []string{shardIDLabel, storageLabel, pathLabel}),
mode: newShardIDMode(writeCacheSubsystem, "mode_info", "Writecache mode value"), mode: newShardIDMode(writeCacheSubsystem, "mode_info", "Writecache mode value"),
} }
} }
func (m *writeCacheMetrics) AddMethodDuration(shardID string, method string, success bool, d time.Duration, storageType string) { func (m *writeCacheMetrics) AddMethodDuration(shardID, path, storageType, method string, success bool, d time.Duration) {
m.methodDuration.With( m.methodDuration.With(
prometheus.Labels{ prometheus.Labels{
shardIDLabel: shardID, shardIDLabel: shardID,
successLabel: strconv.FormatBool(success), successLabel: strconv.FormatBool(success),
storageLabel: storageType, storageLabel: storageType,
methodLabel: method, methodLabel: method,
pathLabel: path,
}, },
).Observe(d.Seconds()) ).Observe(d.Seconds())
} }
func (m *writeCacheMetrics) SetActualCount(shardID string, count uint64, storageType string) { func (m *writeCacheMetrics) SetActualCount(shardID, path, storageType string, count uint64) {
m.actualCount.With(prometheus.Labels{ m.actualCount.With(prometheus.Labels{
shardIDLabel: shardID, shardIDLabel: shardID,
storageLabel: storageType, storageLabel: storageType,
pathLabel: path,
}).Set(float64(count)) }).Set(float64(count))
} }
func (m *writeCacheMetrics) SetEstimateSize(shardID string, size uint64, storageType string) { func (m *writeCacheMetrics) SetEstimateSize(shardID, path, storageType string, size uint64) {
m.estimatedSize.With(prometheus.Labels{ m.estimatedSize.With(prometheus.Labels{
shardIDLabel: shardID, shardIDLabel: shardID,
storageLabel: storageType, storageLabel: storageType,
pathLabel: path,
}).Set(float64(size)) }).Set(float64(size))
} }
@ -77,21 +80,22 @@ func (m *writeCacheMetrics) SetMode(shardID string, mode string) {
m.mode.SetMode(shardID, mode) m.mode.SetMode(shardID, mode)
} }
func (m *writeCacheMetrics) IncOperationCounter(shardID string, operation string, success NullBool, storageType string) { func (m *writeCacheMetrics) IncOperationCounter(shardID, path, storageType, operation string, success NullBool) {
m.operationCounter.With(prometheus.Labels{ m.operationCounter.With(prometheus.Labels{
shardIDLabel: shardID, shardIDLabel: shardID,
storageLabel: storageType, storageLabel: storageType,
operationLabel: operation, operationLabel: operation,
successLabel: success.String(), successLabel: success.String(),
pathLabel: path,
}).Inc() }).Inc()
} }
func (m *writeCacheMetrics) Close(shardID string) { func (m *writeCacheMetrics) Close(shardID, path string) {
m.mode.Delete(shardID) m.mode.Delete(shardID)
m.methodDuration.DeletePartialMatch(prometheus.Labels{shardIDLabel: shardID}) m.methodDuration.DeletePartialMatch(prometheus.Labels{shardIDLabel: shardID, pathLabel: path})
m.operationCounter.DeletePartialMatch(prometheus.Labels{shardIDLabel: shardID}) m.operationCounter.DeletePartialMatch(prometheus.Labels{shardIDLabel: shardID, pathLabel: path})
m.actualCount.DeletePartialMatch(prometheus.Labels{shardIDLabel: shardID}) m.actualCount.DeletePartialMatch(prometheus.Labels{shardIDLabel: shardID, pathLabel: path})
m.estimatedSize.DeletePartialMatch(prometheus.Labels{shardIDLabel: shardID}) m.estimatedSize.DeletePartialMatch(prometheus.Labels{shardIDLabel: shardID, pathLabel: path})
} }
func newWCGaugeVec(name, help string, labels []string) *prometheus.GaugeVec { func newWCGaugeVec(name, help string, labels []string) *prometheus.GaugeVec {

View file

@ -19,9 +19,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
) )
var ( var subjectNotFoundErrorMessage = "subject not found"
subjectNotFoundErrorMessage = "subject not found"
)
func (s *Service) checkAPE(container *core.Container, cid cid.ID, operation acl.Op, role acl.Role, publicKey *keys.PublicKey) error { func (s *Service) checkAPE(container *core.Container, cid cid.ID, operation acl.Op, role acl.Role, publicKey *keys.PublicKey) error {
namespace := "" namespace := ""