forked from TrueCloudLab/frostfs-node
[#451] metrics: Move to internal
`metrics` don't look like something others want to import. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
11a38a0a84
commit
81ea91de52
35 changed files with 14 additions and 14 deletions
39
internal/metrics/morphcache.go
Normal file
39
internal/metrics/morphcache.go
Normal file
|
@ -0,0 +1,39 @@
|
|||
package metrics
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
type MorphCacheMetrics interface {
|
||||
AddMethodDuration(method string, success bool, d time.Duration)
|
||||
}
|
||||
|
||||
type morphCacheMetrics struct {
|
||||
methodDuration *prometheus.HistogramVec
|
||||
}
|
||||
|
||||
var _ MorphCacheMetrics = (*morphCacheMetrics)(nil)
|
||||
|
||||
func newMorphCacheMetrics(ns string) *morphCacheMetrics {
|
||||
return &morphCacheMetrics{
|
||||
methodDuration: metrics.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: ns,
|
||||
Subsystem: morphCacheSubsystem,
|
||||
Name: "request_duration_seconds",
|
||||
Help: "Morph cache request process duration",
|
||||
}, []string{successLabel, methodLabel}),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *morphCacheMetrics) AddMethodDuration(method string, success bool, d time.Duration) {
|
||||
m.methodDuration.With(
|
||||
prometheus.Labels{
|
||||
successLabel: strconv.FormatBool(success),
|
||||
methodLabel: method,
|
||||
},
|
||||
).Observe(d.Seconds())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue