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
|
@ -35,23 +35,18 @@ type engineMetrics struct {
|
|||
writeCache *writeCacheMetrics
|
||||
}
|
||||
|
||||
const (
|
||||
engineSubsystem = "engine"
|
||||
engineMethod = "method"
|
||||
)
|
||||
|
||||
func newEngineMetrics() *engineMetrics {
|
||||
return &engineMetrics{
|
||||
containerSize: newEngineGaugeVector("container_size_bytes", "Accumulated size of all objects in a container", []string{containerIDLabelKey}),
|
||||
payloadSize: newEngineGaugeVector("payload_size_bytes", "Accumulated size of all objects in a shard", []string{shardIDLabelKey}),
|
||||
errorCounter: newEngineGaugeVector("errors_total", "Shard's error counter", []string{shardIDLabelKey}),
|
||||
payloadSize: newEngineGaugeVector("payload_size_bytes", "Accumulated size of all objects in a shard", []string{shardIDLabel}),
|
||||
errorCounter: newEngineGaugeVector("errors_total", "Shard's error counter", []string{shardIDLabel}),
|
||||
methodDuration: metrics.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: engineSubsystem,
|
||||
Name: "request_duration_seconds",
|
||||
Help: "Duration of Engine requests",
|
||||
}, []string{engineMethod}),
|
||||
objectCounter: newEngineGaugeVector("objects_total", "Objects counters per shards", []string{shardIDLabelKey, counterTypeLabelKey}),
|
||||
}, []string{methodLabel}),
|
||||
objectCounter: newEngineGaugeVector("objects_total", "Objects counters per shards", []string{shardIDLabel, typeLabel}),
|
||||
gc: newGCMetrics(),
|
||||
writeCache: newWriteCacheMetrics(),
|
||||
mode: newShardIDMode(engineSubsystem, "mode_info", "Shard mode"),
|
||||
|
@ -69,7 +64,7 @@ func newEngineGaugeVector(name, help string, labels []string) *prometheus.GaugeV
|
|||
|
||||
func (m *engineMetrics) AddMethodDuration(method string, d time.Duration) {
|
||||
m.methodDuration.With(prometheus.Labels{
|
||||
engineMethod: method,
|
||||
methodLabel: method,
|
||||
}).Observe(d.Seconds())
|
||||
}
|
||||
|
||||
|
@ -78,29 +73,29 @@ func (m *engineMetrics) AddToContainerSize(cnrID string, size int64) {
|
|||
}
|
||||
|
||||
func (m *engineMetrics) AddToPayloadCounter(shardID string, size int64) {
|
||||
m.payloadSize.With(prometheus.Labels{shardIDLabelKey: shardID}).Add(float64(size))
|
||||
m.payloadSize.With(prometheus.Labels{shardIDLabel: shardID}).Add(float64(size))
|
||||
}
|
||||
|
||||
func (m *engineMetrics) IncErrorCounter(shardID string) {
|
||||
m.errorCounter.With(prometheus.Labels{shardIDLabelKey: shardID}).Inc()
|
||||
m.errorCounter.With(prometheus.Labels{shardIDLabel: shardID}).Inc()
|
||||
}
|
||||
|
||||
func (m *engineMetrics) ClearErrorCounter(shardID string) {
|
||||
m.errorCounter.With(prometheus.Labels{shardIDLabelKey: shardID}).Set(0)
|
||||
m.errorCounter.With(prometheus.Labels{shardIDLabel: shardID}).Set(0)
|
||||
}
|
||||
|
||||
func (m *engineMetrics) DeleteShardMetrics(shardID string) {
|
||||
m.errorCounter.Delete(prometheus.Labels{shardIDLabelKey: shardID})
|
||||
m.payloadSize.Delete(prometheus.Labels{shardIDLabelKey: shardID})
|
||||
m.objectCounter.DeletePartialMatch(prometheus.Labels{shardIDLabelKey: shardID})
|
||||
m.errorCounter.Delete(prometheus.Labels{shardIDLabel: shardID})
|
||||
m.payloadSize.Delete(prometheus.Labels{shardIDLabel: shardID})
|
||||
m.objectCounter.DeletePartialMatch(prometheus.Labels{shardIDLabel: shardID})
|
||||
m.mode.Delete(shardID)
|
||||
}
|
||||
|
||||
func (m *engineMetrics) AddToObjectCounter(shardID, objectType string, delta int) {
|
||||
m.objectCounter.With(
|
||||
prometheus.Labels{
|
||||
shardIDLabelKey: shardID,
|
||||
counterTypeLabelKey: objectType,
|
||||
shardIDLabel: shardID,
|
||||
typeLabel: objectType,
|
||||
},
|
||||
).Add(float64(delta))
|
||||
}
|
||||
|
@ -108,8 +103,8 @@ func (m *engineMetrics) AddToObjectCounter(shardID, objectType string, delta int
|
|||
func (m *engineMetrics) SetObjectCounter(shardID, objectType string, v uint64) {
|
||||
m.objectCounter.With(
|
||||
prometheus.Labels{
|
||||
shardIDLabelKey: shardID,
|
||||
counterTypeLabelKey: objectType,
|
||||
shardIDLabel: shardID,
|
||||
typeLabel: objectType,
|
||||
},
|
||||
).Set(float64(v))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue