forked from TrueCloudLab/frostfs-node
[#451] frostfs-node: Add cache metrics
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
81ea91de52
commit
df894fbac7
4 changed files with 99 additions and 12 deletions
35
internal/metrics/cache.go
Normal file
35
internal/metrics/cache.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package metrics
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
var cacheRequests = metrics.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: commonCacheSubsystem,
|
||||
Name: "request_duration_seconds",
|
||||
Help: "Accumulated common cache request process duration",
|
||||
}, []string{hitLabel, methodLabel, cacheLabel})
|
||||
|
||||
type CacheMetrics struct {
|
||||
cache string
|
||||
}
|
||||
|
||||
// NewCacheMetrics returns new CacheMetrics instance for cache specified.
|
||||
func NewCacheMetrics(cache string) *CacheMetrics {
|
||||
return &CacheMetrics{
|
||||
cache: cache,
|
||||
}
|
||||
}
|
||||
|
||||
func (m *CacheMetrics) AddMethodDuration(method string, d time.Duration, hit bool) {
|
||||
cacheRequests.With(prometheus.Labels{
|
||||
hitLabel: strconv.FormatBool(hit),
|
||||
methodLabel: method,
|
||||
cacheLabel: m.cache,
|
||||
}).Observe(d.Seconds())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue