forked from TrueCloudLab/frostfs-node
[#373] metrics: Move labels to consts
To unify label naming all lable keys and other consts are moved to one file. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
b5d9f4a285
commit
03aa210145
13 changed files with 119 additions and 160 deletions
|
@ -9,15 +9,6 @@ import (
|
|||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const (
|
||||
morphSubsystem = "morph"
|
||||
morphNotificationTypeLabel = "notification_type"
|
||||
morphInvokeTypeLabel = "invoke_type"
|
||||
morphContractLabel = "contract"
|
||||
morphMethodLabel = "method"
|
||||
morphSuccessLabel = "success"
|
||||
)
|
||||
|
||||
type morphClientMetrics struct {
|
||||
switchCount prometheus.Counter
|
||||
lastBlock prometheus.Gauge
|
||||
|
@ -44,13 +35,13 @@ func NewMorphClientMetrics() morphmetrics.Register {
|
|||
Subsystem: morphSubsystem,
|
||||
Name: "notifications_total",
|
||||
Help: "Number of notifications received by notification type",
|
||||
}, []string{morphNotificationTypeLabel}),
|
||||
}, []string{notificationTypeLabel}),
|
||||
invokeDuration: metrics.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: morphSubsystem,
|
||||
Name: "invoke_duration_seconds",
|
||||
Help: "Cummulative duration of contract invocations",
|
||||
}, []string{morphInvokeTypeLabel, morphContractLabel, morphMethodLabel, morphSuccessLabel}),
|
||||
}, []string{invokeTypeLabel, contractLabel, methodLabel, successLabel}),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +56,7 @@ func (m *morphClientMetrics) SetLastBlock(index uint32) {
|
|||
func (m *morphClientMetrics) IncNotificationCount(typ string) {
|
||||
m.notificationCount.With(
|
||||
prometheus.Labels{
|
||||
morphNotificationTypeLabel: typ,
|
||||
notificationTypeLabel: typ,
|
||||
},
|
||||
).Inc()
|
||||
}
|
||||
|
@ -73,10 +64,10 @@ func (m *morphClientMetrics) IncNotificationCount(typ string) {
|
|||
func (m *morphClientMetrics) ObserveInvoke(typ string, contract string, method string, success bool, d time.Duration) {
|
||||
m.invokeDuration.With(
|
||||
prometheus.Labels{
|
||||
morphInvokeTypeLabel: typ,
|
||||
morphContractLabel: contract,
|
||||
morphMethodLabel: method,
|
||||
morphSuccessLabel: strconv.FormatBool(success),
|
||||
invokeTypeLabel: typ,
|
||||
contractLabel: contract,
|
||||
methodLabel: method,
|
||||
successLabel: strconv.FormatBool(success),
|
||||
},
|
||||
).Observe(d.Seconds())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue