metrics: add metric to evaluate the policer performance #720

Merged
fyrchik merged 1 commit from elebedeva/frostfs-node:metrics-policer into master 2023-10-09 19:02:11 +00:00
6 changed files with 44 additions and 0 deletions

View file

@ -20,6 +20,7 @@ const (
treeServiceSubsystem = "treeservice"
writeCacheSubsystem = "writecache"
grpcServerSubsystem = "grpc_server"
policerSubsystem = "policer"
successLabel = "success"
shardIDLabel = "shard_id"

View file

@ -18,6 +18,7 @@ type NodeMetrics struct {
metabase *metabaseMetrics
pilorama *piloramaMetrics
grpc *grpcServerMetrics
policer *policerMetrics
}
func NewNodeMetrics() *NodeMetrics {
@ -39,6 +40,7 @@ func NewNodeMetrics() *NodeMetrics {
metabase: newMetabaseMetrics(),
pilorama: newPiloramaMetrics(),
grpc: newGrpcServerMetrics(),
policer: newPolicerMetrics(),
}
}
@ -90,3 +92,7 @@ func (m *NodeMetrics) PiloramaMetrics() PiloramaMetrics {
func (m *NodeMetrics) GrpcServerMetrics() GrpcServerMetrics {
return m.grpc
}
func (m *NodeMetrics) PolicerMetrics() PolicerMetrics {
return m.policer
}

29
pkg/metrics/policer.go Normal file
View file

@ -0,0 +1,29 @@
package metrics
import (
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
"github.com/prometheus/client_golang/prometheus"
)
type PolicerMetrics interface {
IncProcessedObjects()
}
type policerMetrics struct {
processedObjectsCounter prometheus.Counter
}
func newPolicerMetrics() *policerMetrics {
return &policerMetrics{
processedObjectsCounter: metrics.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Subsystem: policerSubsystem,
Name: "processed_objects_total",
Help: "Total number of objects processed by policer",
}),
}
}
func (m *policerMetrics) IncProcessedObjects() {
m.processedObjectsCounter.Inc()
}

View file

@ -0,0 +1,5 @@
package policer
type MetricsRegister interface {
IncProcessedObjects()
}

View file

@ -69,6 +69,8 @@ type cfg struct {
batchSize, cacheSize uint32
rebalanceFreq, evictDuration, sleepDuration time.Duration
metrics MetricsRegister
}
func defaultCfg() *cfg {

View file

@ -60,6 +60,7 @@ func (p *Policer) shardPolicyWorker(ctx context.Context) {
}
p.cache.Add(addr.Address, time.Now())
p.objsInWork.remove(addr.Address)
p.metrics.IncProcessedObjects()
}
})
if err != nil {