forked from TrueCloudLab/frostfs-node
[#371] ir: Add morph cache metrics
Signed-off-by: Airat Arifullin a.arifullin@yadro.com
This commit is contained in:
parent
4f83ab0fb4
commit
90e9247b69
11 changed files with 154 additions and 27 deletions
77
pkg/metrics/morphcache.go
Normal file
77
pkg/metrics/morphcache.go
Normal file
|
@ -0,0 +1,77 @@
|
|||
package metrics
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const (
|
||||
mcSubsystem = "morphcache"
|
||||
mcSuccess = "success"
|
||||
)
|
||||
|
||||
type MorphCacheMetrics interface {
|
||||
AddNNSContractHashDuration(success bool, d time.Duration)
|
||||
|
||||
AddGroupKeyDuration(success bool, d time.Duration)
|
||||
|
||||
AddTxHeightDuration(hash util.Uint256, success bool, d time.Duration)
|
||||
}
|
||||
|
||||
type morphCacheMetrics struct {
|
||||
// Duration of processing get nns contract hash request
|
||||
nnsContractHashDuration *prometheus.HistogramVec
|
||||
|
||||
// Duration of processing get group key request
|
||||
groupKeyDuration *prometheus.HistogramVec
|
||||
|
||||
// Duration of processing get tx height request
|
||||
txHeightDuration *prometheus.HistogramVec
|
||||
}
|
||||
|
||||
var _ MorphCacheMetrics = (*morphCacheMetrics)(nil)
|
||||
|
||||
func newMorphCacheMetrics() *morphCacheMetrics {
|
||||
return &morphCacheMetrics{
|
||||
nnsContractHashDuration: newMCMethodDurationCounter("nns_contract_hash"),
|
||||
groupKeyDuration: newMCMethodDurationCounter("group_key"),
|
||||
txHeightDuration: newMCMethodDurationCounter("tx_height"),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *morphCacheMetrics) AddNNSContractHashDuration(success bool, d time.Duration) {
|
||||
m.nnsContractHashDuration.With(
|
||||
prometheus.Labels{
|
||||
mcSuccess: fmt.Sprintf("%v", success),
|
||||
},
|
||||
).Observe(float64(d))
|
||||
}
|
||||
|
||||
func (m *morphCacheMetrics) AddGroupKeyDuration(success bool, d time.Duration) {
|
||||
m.groupKeyDuration.With(
|
||||
prometheus.Labels{
|
||||
mcSuccess: fmt.Sprintf("%v", success),
|
||||
},
|
||||
).Observe(float64(d))
|
||||
}
|
||||
|
||||
func (m *morphCacheMetrics) AddTxHeightDuration(hash util.Uint256, success bool, d time.Duration) {
|
||||
m.txHeightDuration.With(
|
||||
prometheus.Labels{
|
||||
mcSuccess: fmt.Sprintf("%v", success),
|
||||
},
|
||||
).Observe(float64(d))
|
||||
}
|
||||
|
||||
func newMCMethodDurationCounter(method string) *prometheus.HistogramVec {
|
||||
return metrics.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: mcSubsystem,
|
||||
Name: fmt.Sprintf("%s_req_duration_seconds", method),
|
||||
Help: fmt.Sprintf("Accumulated %s request process duration", method),
|
||||
}, []string{mcSuccess})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue