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
49
internal/metrics/object.go
Normal file
49
internal/metrics/object.go
Normal file
|
@ -0,0 +1,49 @@
|
|||
package metrics
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
type ObjectServiceMetrics interface {
|
||||
AddRequestDuration(method string, d time.Duration, success bool)
|
||||
AddPayloadSize(method string, size int)
|
||||
}
|
||||
|
||||
type objectServiceMetrics struct {
|
||||
methodDuration *prometheus.HistogramVec
|
||||
payloadCounter *prometheus.CounterVec
|
||||
}
|
||||
|
||||
func newObjectServiceMetrics() *objectServiceMetrics {
|
||||
return &objectServiceMetrics{
|
||||
methodDuration: metrics.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: objectSubsystem,
|
||||
Name: "request_duration_seconds",
|
||||
Help: "Object Service request process duration",
|
||||
}, []string{methodLabel, successLabel}),
|
||||
payloadCounter: metrics.NewCounterVec(prometheus.CounterOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: objectSubsystem,
|
||||
Name: "request_payload_bytes",
|
||||
Help: "Object Service request payload",
|
||||
}, []string{methodLabel}),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *objectServiceMetrics) AddRequestDuration(method string, d time.Duration, success bool) {
|
||||
m.methodDuration.With(prometheus.Labels{
|
||||
methodLabel: method,
|
||||
successLabel: strconv.FormatBool(success),
|
||||
}).Observe(d.Seconds())
|
||||
}
|
||||
|
||||
func (m *objectServiceMetrics) AddPayloadSize(method string, size int) {
|
||||
m.payloadCounter.With(prometheus.Labels{
|
||||
methodLabel: method,
|
||||
}).Add(float64(size))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue