[#701] metrics: add metric to evaluate policer performance
All checks were successful
Build / Build Components (1.21) (pull_request) Successful in 3m8s
DCO action / DCO (pull_request) Successful in 3m30s
Vulncheck / Vulncheck (pull_request) Successful in 4m43s
Build / Build Components (1.20) (pull_request) Successful in 7m36s
Tests and linters / Staticcheck (pull_request) Successful in 7m45s
Tests and linters / Tests (1.21) (pull_request) Successful in 8m14s
Tests and linters / Lint (pull_request) Successful in 8m56s
Tests and linters / Tests (1.20) (pull_request) Successful in 10m3s
Tests and linters / Tests with -race (pull_request) Successful in 10m4s
All checks were successful
Build / Build Components (1.21) (pull_request) Successful in 3m8s
DCO action / DCO (pull_request) Successful in 3m30s
Vulncheck / Vulncheck (pull_request) Successful in 4m43s
Build / Build Components (1.20) (pull_request) Successful in 7m36s
Tests and linters / Staticcheck (pull_request) Successful in 7m45s
Tests and linters / Tests (1.21) (pull_request) Successful in 8m14s
Tests and linters / Lint (pull_request) Successful in 8m56s
Tests and linters / Tests (1.20) (pull_request) Successful in 10m3s
Tests and linters / Tests with -race (pull_request) Successful in 10m4s
Add processed objects counter in policerMetrics, add policer field to NodeMetrics Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
This commit is contained in:
parent
d07afd803c
commit
e0ce2adbce
6 changed files with 44 additions and 0 deletions
|
@ -20,6 +20,7 @@ const (
|
||||||
treeServiceSubsystem = "treeservice"
|
treeServiceSubsystem = "treeservice"
|
||||||
writeCacheSubsystem = "writecache"
|
writeCacheSubsystem = "writecache"
|
||||||
grpcServerSubsystem = "grpc_server"
|
grpcServerSubsystem = "grpc_server"
|
||||||
|
policerSubsystem = "policer"
|
||||||
|
|
||||||
successLabel = "success"
|
successLabel = "success"
|
||||||
shardIDLabel = "shard_id"
|
shardIDLabel = "shard_id"
|
||||||
|
|
|
@ -18,6 +18,7 @@ type NodeMetrics struct {
|
||||||
metabase *metabaseMetrics
|
metabase *metabaseMetrics
|
||||||
pilorama *piloramaMetrics
|
pilorama *piloramaMetrics
|
||||||
grpc *grpcServerMetrics
|
grpc *grpcServerMetrics
|
||||||
|
policer *policerMetrics
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNodeMetrics() *NodeMetrics {
|
func NewNodeMetrics() *NodeMetrics {
|
||||||
|
@ -39,6 +40,7 @@ func NewNodeMetrics() *NodeMetrics {
|
||||||
metabase: newMetabaseMetrics(),
|
metabase: newMetabaseMetrics(),
|
||||||
pilorama: newPiloramaMetrics(),
|
pilorama: newPiloramaMetrics(),
|
||||||
grpc: newGrpcServerMetrics(),
|
grpc: newGrpcServerMetrics(),
|
||||||
|
policer: newPolicerMetrics(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,3 +92,7 @@ func (m *NodeMetrics) PiloramaMetrics() PiloramaMetrics {
|
||||||
func (m *NodeMetrics) GrpcServerMetrics() GrpcServerMetrics {
|
func (m *NodeMetrics) GrpcServerMetrics() GrpcServerMetrics {
|
||||||
return m.grpc
|
return m.grpc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *NodeMetrics) PolicerMetrics() PolicerMetrics {
|
||||||
|
return m.policer
|
||||||
|
}
|
||||||
|
|
29
pkg/metrics/policer.go
Normal file
29
pkg/metrics/policer.go
Normal 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()
|
||||||
|
}
|
5
pkg/services/policer/metrics.go
Normal file
5
pkg/services/policer/metrics.go
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
package policer
|
||||||
|
|
||||||
|
type MetricsRegister interface {
|
||||||
|
IncProcessedObjects()
|
||||||
|
}
|
|
@ -69,6 +69,8 @@ type cfg struct {
|
||||||
batchSize, cacheSize uint32
|
batchSize, cacheSize uint32
|
||||||
|
|
||||||
rebalanceFreq, evictDuration, sleepDuration time.Duration
|
rebalanceFreq, evictDuration, sleepDuration time.Duration
|
||||||
|
|
||||||
|
metrics MetricsRegister
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultCfg() *cfg {
|
func defaultCfg() *cfg {
|
||||||
|
|
|
@ -60,6 +60,7 @@ func (p *Policer) shardPolicyWorker(ctx context.Context) {
|
||||||
}
|
}
|
||||||
p.cache.Add(addr.Address, time.Now())
|
p.cache.Add(addr.Address, time.Now())
|
||||||
p.objsInWork.remove(addr.Address)
|
p.objsInWork.remove(addr.Address)
|
||||||
|
p.metrics.IncProcessedObjects()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue