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
|
@ -1,20 +1,45 @@
|
|||
package metrics
|
||||
|
||||
const (
|
||||
namespace = "frostfs_node"
|
||||
innerRingNamespace = "frostfs_ir"
|
||||
|
||||
fstreeSubSystem = "fstree"
|
||||
blobstoreSubSystem = "blobstore"
|
||||
blobovnizaTreeSubSystem = "blobovniza_tree"
|
||||
metabaseSubSystem = "metabase"
|
||||
piloramaSubSystem = "pilorama"
|
||||
engineSubsystem = "engine"
|
||||
gcSubsystem = "garbage_collector"
|
||||
innerRingSubsystem = "ir"
|
||||
morphSubsystem = "morph"
|
||||
morphCacheSubsystem = "morphcache"
|
||||
objectSubsystem = "object"
|
||||
replicatorSubsystem = "replicator"
|
||||
stateSubsystem = "state"
|
||||
treeServiceSubsystem = "treeservice"
|
||||
writeCacheSubsystem = "writecache"
|
||||
|
||||
successLabel = "success"
|
||||
shardIDLabel = "shardID"
|
||||
shardIDLabel = "shard_id"
|
||||
modeLabel = "mode"
|
||||
pathLabel = "path"
|
||||
methodLabel = "method"
|
||||
withStorageIDLabel = "withStorageID"
|
||||
withStorageIDLabel = "with_storage_id"
|
||||
statusLabel = "status"
|
||||
objectTypeLabel = "object_type"
|
||||
typeLabel = "type"
|
||||
notificationTypeLabel = "notification_type"
|
||||
invokeTypeLabel = "invoke_type"
|
||||
contractLabel = "contract"
|
||||
containerIDLabelKey = "cid"
|
||||
storageLabel = "storage"
|
||||
operationLabel = "operation"
|
||||
|
||||
readWriteMode = "READ_WRITE"
|
||||
readOnlyMode = "READ_ONLY"
|
||||
closedMode = "CLOSED"
|
||||
|
||||
failedToDeleteStatus = "failed_to_delete"
|
||||
deletedStatus = "deleted"
|
||||
)
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -8,16 +8,6 @@ import (
|
|||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const (
|
||||
gcSubsystem = "garbage_collector"
|
||||
gcShardID = "shard_id"
|
||||
gcSuccess = "success"
|
||||
gcStatus = "status"
|
||||
gcDeleted = "deleted"
|
||||
gcFailed = "failed_to_delete"
|
||||
gcObjectType = "object_type"
|
||||
)
|
||||
|
||||
type GCMetrics interface {
|
||||
AddRunDuration(shardID string, d time.Duration, success bool)
|
||||
AddDeletedCount(shardID string, deleted, failed uint64)
|
||||
|
@ -39,60 +29,60 @@ func newGCMetrics() *gcMetrics {
|
|||
Subsystem: gcSubsystem,
|
||||
Name: "delete_duration_seconds",
|
||||
Help: "The total time of GC runs to delete objects from disk",
|
||||
}, []string{gcShardID, gcSuccess}),
|
||||
}, []string{shardIDLabel, successLabel}),
|
||||
deletedCounter: metrics.NewCounterVec(prometheus.CounterOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: gcSubsystem,
|
||||
Name: "deleted_objects_total",
|
||||
Help: "Total count of objects GC deleted or failed to delete from disk",
|
||||
}, []string{gcShardID, gcStatus}),
|
||||
}, []string{shardIDLabel, statusLabel}),
|
||||
expCollectDuration: metrics.NewCounterVec(prometheus.CounterOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: gcSubsystem,
|
||||
Name: "marking_duration_seconds",
|
||||
Help: "The total time of GC runs to mark expired objects as removed",
|
||||
}, []string{gcShardID, gcSuccess, gcObjectType}),
|
||||
}, []string{shardIDLabel, successLabel, objectTypeLabel}),
|
||||
inhumedCounter: metrics.NewCounterVec(prometheus.CounterOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: gcSubsystem,
|
||||
Name: "marked_for_removal_objects_total",
|
||||
Help: "Total count of expired objects GC marked to remove",
|
||||
}, []string{gcShardID, gcObjectType}),
|
||||
}, []string{shardIDLabel, objectTypeLabel}),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *gcMetrics) AddRunDuration(shardID string, d time.Duration, success bool) {
|
||||
m.runDuration.With(prometheus.Labels{
|
||||
gcShardID: shardID,
|
||||
gcSuccess: strconv.FormatBool(success),
|
||||
shardIDLabel: shardID,
|
||||
successLabel: strconv.FormatBool(success),
|
||||
}).Add(d.Seconds())
|
||||
}
|
||||
|
||||
func (m *gcMetrics) AddDeletedCount(shardID string, deleted, failed uint64) {
|
||||
m.deletedCounter.With(
|
||||
prometheus.Labels{
|
||||
gcShardID: shardID,
|
||||
gcStatus: gcDeleted,
|
||||
shardIDLabel: shardID,
|
||||
statusLabel: deletedStatus,
|
||||
}).Add(float64(deleted))
|
||||
m.deletedCounter.With(
|
||||
prometheus.Labels{
|
||||
gcShardID: shardID,
|
||||
gcStatus: gcFailed,
|
||||
shardIDLabel: shardID,
|
||||
statusLabel: failedToDeleteStatus,
|
||||
}).Add(float64(failed))
|
||||
}
|
||||
|
||||
func (m *gcMetrics) AddExpiredObjectCollectionDuration(shardID string, d time.Duration, success bool, objectType string) {
|
||||
m.expCollectDuration.With(prometheus.Labels{
|
||||
gcShardID: shardID,
|
||||
gcSuccess: strconv.FormatBool(success),
|
||||
gcObjectType: objectType,
|
||||
shardIDLabel: shardID,
|
||||
successLabel: strconv.FormatBool(success),
|
||||
objectTypeLabel: objectType,
|
||||
}).Add(d.Seconds())
|
||||
}
|
||||
|
||||
func (m *gcMetrics) AddInhumedObjectCount(shardID string, count uint64, objectType string) {
|
||||
m.inhumedCounter.With(
|
||||
prometheus.Labels{
|
||||
gcShardID: shardID,
|
||||
gcObjectType: objectType,
|
||||
shardIDLabel: shardID,
|
||||
objectTypeLabel: objectType,
|
||||
}).Add(float64(count))
|
||||
}
|
||||
|
|
|
@ -8,13 +8,6 @@ import (
|
|||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const (
|
||||
innerRingSubsystem = "ir"
|
||||
innerRingLabelSuccess = "success"
|
||||
innerRingLabelType = "type"
|
||||
innerRingNamespace = "frostfs_ir"
|
||||
)
|
||||
|
||||
// InnerRingServiceMetrics contains metrics collected by inner ring.
|
||||
type InnerRingServiceMetrics struct {
|
||||
epoch prometheus.Gauge
|
||||
|
@ -43,7 +36,7 @@ func NewInnerRingMetrics() *InnerRingServiceMetrics {
|
|||
Subsystem: innerRingSubsystem,
|
||||
Name: "event_duration_seconds",
|
||||
Help: "Duration of processing of inner-ring events",
|
||||
}, []string{innerRingLabelType, innerRingLabelSuccess})
|
||||
}, []string{typeLabel, successLabel})
|
||||
)
|
||||
|
||||
return &InnerRingServiceMetrics{
|
||||
|
@ -66,8 +59,8 @@ func (m *InnerRingServiceMetrics) SetHealth(s int32) {
|
|||
|
||||
func (m *InnerRingServiceMetrics) AddEvent(d time.Duration, typ string, success bool) {
|
||||
m.eventDuration.With(prometheus.Labels{
|
||||
innerRingLabelType: typ,
|
||||
innerRingLabelSuccess: strconv.FormatBool(success),
|
||||
typeLabel: typ,
|
||||
successLabel: strconv.FormatBool(success),
|
||||
}).Observe(d.Seconds())
|
||||
}
|
||||
|
||||
|
|
|
@ -17,24 +17,24 @@ func newShardIDMode(subsystem, name, help string) *shardIDModeValue {
|
|||
Subsystem: subsystem,
|
||||
Name: name,
|
||||
Help: help,
|
||||
}, []string{wcShardID, wcMode}),
|
||||
}, []string{shardIDLabel, modeLabel}),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *shardIDModeValue) SetMode(shardID string, mode string) {
|
||||
m.modeValue.DeletePartialMatch(prometheus.Labels{
|
||||
wcShardID: shardID,
|
||||
shardIDLabel: shardID,
|
||||
})
|
||||
|
||||
m.modeValue.With(prometheus.Labels{
|
||||
wcShardID: shardID,
|
||||
wcMode: mode,
|
||||
shardIDLabel: shardID,
|
||||
modeLabel: mode,
|
||||
}).Set(1)
|
||||
}
|
||||
|
||||
func (m *shardIDModeValue) Delete(shardID string) {
|
||||
m.modeValue.DeletePartialMatch(prometheus.Labels{
|
||||
wcShardID: shardID,
|
||||
shardIDLabel: shardID,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
|
|
|
@ -8,12 +8,6 @@ import (
|
|||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const (
|
||||
mcSubsystem = "morphcache"
|
||||
mcSuccess = "success"
|
||||
mcMethod = "method"
|
||||
)
|
||||
|
||||
type MorphCacheMetrics interface {
|
||||
AddMethodDuration(method string, success bool, d time.Duration)
|
||||
}
|
||||
|
@ -32,18 +26,18 @@ func newMorphCacheMetrics(ns string) *morphCacheMetrics {
|
|||
return &morphCacheMetrics{
|
||||
methodDuration: metrics.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: ns,
|
||||
Subsystem: mcSubsystem,
|
||||
Subsystem: morphCacheSubsystem,
|
||||
Name: "request_duration_seconds",
|
||||
Help: "Morph cache request process duration",
|
||||
}, []string{mcSuccess, mcMethod}),
|
||||
}, []string{successLabel, methodLabel}),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *morphCacheMetrics) AddMethodDuration(method string, success bool, d time.Duration) {
|
||||
m.methodDuration.With(
|
||||
prometheus.Labels{
|
||||
mcSuccess: strconv.FormatBool(success),
|
||||
mcMethod: method,
|
||||
successLabel: strconv.FormatBool(success),
|
||||
methodLabel: method,
|
||||
},
|
||||
).Observe(d.Seconds())
|
||||
}
|
||||
|
|
|
@ -5,8 +5,6 @@ import (
|
|||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const namespace = "frostfs_node"
|
||||
|
||||
type NodeMetrics struct {
|
||||
engine *engineMetrics
|
||||
state *stateMetrics
|
||||
|
|
|
@ -8,8 +8,6 @@ import (
|
|||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const objectSubsystem = "object"
|
||||
|
||||
type ObjectServiceMetrics interface {
|
||||
AddRequestDuration(method string, d time.Duration, success bool)
|
||||
AddPayloadSize(method string, size int)
|
||||
|
@ -20,14 +18,6 @@ type objectServiceMetrics struct {
|
|||
payloadCounter *prometheus.CounterVec
|
||||
}
|
||||
|
||||
const (
|
||||
shardIDLabelKey = "shard"
|
||||
counterTypeLabelKey = "type"
|
||||
containerIDLabelKey = "cid"
|
||||
methodLabelKey = "method"
|
||||
successLabelKey = "success"
|
||||
)
|
||||
|
||||
func newObjectServiceMetrics() *objectServiceMetrics {
|
||||
return &objectServiceMetrics{
|
||||
methodDuration: metrics.NewHistogramVec(prometheus.HistogramOpts{
|
||||
|
@ -35,25 +25,25 @@ func newObjectServiceMetrics() *objectServiceMetrics {
|
|||
Subsystem: objectSubsystem,
|
||||
Name: "request_duration_seconds",
|
||||
Help: "Object Service request process duration",
|
||||
}, []string{methodLabelKey, successLabelKey}),
|
||||
}, []string{methodLabel, successLabel}),
|
||||
payloadCounter: metrics.NewCounterVec(prometheus.CounterOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: objectSubsystem,
|
||||
Name: "request_payload_bytes",
|
||||
Help: "Object Service request payload",
|
||||
}, []string{methodLabelKey}),
|
||||
}, []string{methodLabel}),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *objectServiceMetrics) AddRequestDuration(method string, d time.Duration, success bool) {
|
||||
m.methodDuration.With(prometheus.Labels{
|
||||
methodLabelKey: method,
|
||||
successLabelKey: strconv.FormatBool(success),
|
||||
methodLabel: method,
|
||||
successLabel: strconv.FormatBool(success),
|
||||
}).Observe(d.Seconds())
|
||||
}
|
||||
|
||||
func (m *objectServiceMetrics) AddPayloadSize(method string, size int) {
|
||||
m.payloadCounter.With(prometheus.Labels{
|
||||
methodLabelKey: method,
|
||||
methodLabel: method,
|
||||
}).Add(float64(size))
|
||||
}
|
||||
|
|
|
@ -5,8 +5,6 @@ import (
|
|||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const replicatorSubsystem = "replicator"
|
||||
|
||||
//TODO
|
||||
|
||||
type ReplicatorMetrics interface {
|
||||
|
|
|
@ -5,8 +5,6 @@ import (
|
|||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const stateSubsystem = "state"
|
||||
|
||||
type StateMetrics interface {
|
||||
SetHealth(s int32)
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@ import (
|
|||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const treeServiceLabelSuccess = "success"
|
||||
|
||||
type TreeMetricsRegister interface {
|
||||
AddReplicateTaskDuration(time.Duration, bool)
|
||||
AddReplicateWaitDuration(time.Duration, bool)
|
||||
|
@ -25,43 +23,42 @@ type treeServiceMetrics struct {
|
|||
var _ TreeMetricsRegister = (*treeServiceMetrics)(nil)
|
||||
|
||||
func newTreeServiceMetrics() *treeServiceMetrics {
|
||||
const treeServiceSubsystem = "treeservice"
|
||||
return &treeServiceMetrics{
|
||||
replicateTaskDuration: metrics.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: treeServiceSubsystem,
|
||||
Name: "replicate_task_duration_seconds",
|
||||
Help: "Duration of individual replication tasks executed as part of replication loops",
|
||||
}, []string{treeServiceLabelSuccess}),
|
||||
}, []string{successLabel}),
|
||||
replicateWaitDuration: metrics.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: treeServiceSubsystem,
|
||||
Name: "replicate_wait_duration_seconds",
|
||||
Help: "Duration of overall waiting time for replication loops",
|
||||
}, []string{treeServiceLabelSuccess}),
|
||||
}, []string{successLabel}),
|
||||
syncOpDuration: metrics.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: treeServiceSubsystem,
|
||||
Name: "sync_duration_seconds",
|
||||
Help: "Duration of synchronization operations",
|
||||
}, []string{treeServiceLabelSuccess}),
|
||||
}, []string{successLabel}),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *treeServiceMetrics) AddReplicateTaskDuration(d time.Duration, success bool) {
|
||||
m.replicateTaskDuration.With(prometheus.Labels{
|
||||
treeServiceLabelSuccess: strconv.FormatBool(success),
|
||||
successLabel: strconv.FormatBool(success),
|
||||
}).Observe(d.Seconds())
|
||||
}
|
||||
|
||||
func (m *treeServiceMetrics) AddReplicateWaitDuration(d time.Duration, success bool) {
|
||||
m.replicateWaitDuration.With(prometheus.Labels{
|
||||
treeServiceLabelSuccess: strconv.FormatBool(success),
|
||||
successLabel: strconv.FormatBool(success),
|
||||
}).Observe(d.Seconds())
|
||||
}
|
||||
|
||||
func (m *treeServiceMetrics) AddSyncDuration(d time.Duration, success bool) {
|
||||
m.syncOpDuration.With(prometheus.Labels{
|
||||
treeServiceLabelSuccess: strconv.FormatBool(success),
|
||||
successLabel: strconv.FormatBool(success),
|
||||
}).Observe(d.Seconds())
|
||||
}
|
||||
|
|
|
@ -8,16 +8,6 @@ import (
|
|||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const (
|
||||
wcSubsystem = "writecache"
|
||||
wcShardID = "shard_id"
|
||||
wcSuccess = "success"
|
||||
wcStorage = "storage"
|
||||
wcMode = "mode"
|
||||
wcMethod = "method"
|
||||
wcOperation = "operation"
|
||||
)
|
||||
|
||||
type WriteCacheMetrics interface {
|
||||
AddMethodDuration(shardID string, method string, success bool, d time.Duration, storageType string)
|
||||
|
||||
|
@ -48,58 +38,58 @@ func newWriteCacheMetrics() *writeCacheMetrics {
|
|||
return &writeCacheMetrics{
|
||||
methodDuration: metrics.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: wcSubsystem,
|
||||
Subsystem: writeCacheSubsystem,
|
||||
Name: "request_duration_seconds",
|
||||
Help: "Writecache request process duration",
|
||||
}, []string{wcShardID, wcSuccess, wcStorage, wcMethod}),
|
||||
}, []string{shardIDLabel, successLabel, storageLabel, methodLabel}),
|
||||
operationCounter: metrics.NewCounterVec(prometheus.CounterOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: wcSubsystem,
|
||||
Subsystem: writeCacheSubsystem,
|
||||
Name: "operations_total",
|
||||
Help: "The number of writecache operations processed",
|
||||
}, []string{wcShardID, wcStorage, wcSuccess, wcOperation}),
|
||||
actualCount: newWCGaugeVec("actual_objects_total", "Actual objects count in writecache", []string{wcShardID, wcStorage}),
|
||||
estimatedSize: newWCGaugeVec("estimated_size_bytes", "Estimated writecache size", []string{wcShardID, wcStorage}),
|
||||
mode: newShardIDMode(wcSubsystem, "mode_info", "Writecache mode value"),
|
||||
}, []string{shardIDLabel, storageLabel, successLabel, operationLabel}),
|
||||
actualCount: newWCGaugeVec("actual_objects_total", "Actual objects count in writecache", []string{shardIDLabel, storageLabel}),
|
||||
estimatedSize: newWCGaugeVec("estimated_size_bytes", "Estimated writecache size", []string{shardIDLabel, storageLabel}),
|
||||
mode: newShardIDMode(writeCacheSubsystem, "mode_info", "Writecache mode value"),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *writeCacheMetrics) AddMethodDuration(shardID string, method string, success bool, d time.Duration, storageType string) {
|
||||
m.methodDuration.With(
|
||||
prometheus.Labels{
|
||||
wcShardID: shardID,
|
||||
wcSuccess: fmt.Sprintf("%v", success),
|
||||
wcStorage: storageType,
|
||||
wcMethod: method,
|
||||
shardIDLabel: shardID,
|
||||
successLabel: fmt.Sprintf("%v", success),
|
||||
storageLabel: storageType,
|
||||
methodLabel: method,
|
||||
},
|
||||
).Observe(d.Seconds())
|
||||
}
|
||||
|
||||
func (m *writeCacheMetrics) IncActualCount(shardID string, storageType string) {
|
||||
m.actualCount.With(prometheus.Labels{
|
||||
wcShardID: shardID,
|
||||
wcStorage: storageType,
|
||||
shardIDLabel: shardID,
|
||||
storageLabel: storageType,
|
||||
}).Inc()
|
||||
}
|
||||
|
||||
func (m *writeCacheMetrics) DecActualCount(shardID string, storageType string) {
|
||||
m.actualCount.With(prometheus.Labels{
|
||||
wcShardID: shardID,
|
||||
wcStorage: storageType,
|
||||
shardIDLabel: shardID,
|
||||
storageLabel: storageType,
|
||||
}).Dec()
|
||||
}
|
||||
|
||||
func (m *writeCacheMetrics) SetActualCount(shardID string, count uint64, storageType string) {
|
||||
m.actualCount.With(prometheus.Labels{
|
||||
wcShardID: shardID,
|
||||
wcStorage: storageType,
|
||||
shardIDLabel: shardID,
|
||||
storageLabel: storageType,
|
||||
}).Set(float64(count))
|
||||
}
|
||||
|
||||
func (m *writeCacheMetrics) SetEstimateSize(shardID string, size uint64, storageType string) {
|
||||
m.estimatedSize.With(prometheus.Labels{
|
||||
wcShardID: shardID,
|
||||
wcStorage: storageType,
|
||||
shardIDLabel: shardID,
|
||||
storageLabel: storageType,
|
||||
}).Set(float64(size))
|
||||
}
|
||||
|
||||
|
@ -109,25 +99,25 @@ func (m *writeCacheMetrics) SetMode(shardID string, mode string) {
|
|||
|
||||
func (m *writeCacheMetrics) IncOperationCounter(shardID string, operation string, success NullBool, storageType string) {
|
||||
m.operationCounter.With(prometheus.Labels{
|
||||
wcShardID: shardID,
|
||||
wcStorage: storageType,
|
||||
wcOperation: operation,
|
||||
wcSuccess: success.String(),
|
||||
shardIDLabel: shardID,
|
||||
storageLabel: storageType,
|
||||
operationLabel: operation,
|
||||
successLabel: success.String(),
|
||||
}).Inc()
|
||||
}
|
||||
|
||||
func (m *writeCacheMetrics) Close(shardID string) {
|
||||
m.mode.Delete(shardID)
|
||||
m.methodDuration.DeletePartialMatch(prometheus.Labels{wcShardID: shardID})
|
||||
m.operationCounter.DeletePartialMatch(prometheus.Labels{wcShardID: shardID})
|
||||
m.actualCount.DeletePartialMatch(prometheus.Labels{wcShardID: shardID})
|
||||
m.estimatedSize.DeletePartialMatch(prometheus.Labels{wcShardID: shardID})
|
||||
m.methodDuration.DeletePartialMatch(prometheus.Labels{shardIDLabel: shardID})
|
||||
m.operationCounter.DeletePartialMatch(prometheus.Labels{shardIDLabel: shardID})
|
||||
m.actualCount.DeletePartialMatch(prometheus.Labels{shardIDLabel: shardID})
|
||||
m.estimatedSize.DeletePartialMatch(prometheus.Labels{shardIDLabel: shardID})
|
||||
}
|
||||
|
||||
func newWCGaugeVec(name, help string, labels []string) *prometheus.GaugeVec {
|
||||
return metrics.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: wcSubsystem,
|
||||
Subsystem: writeCacheSubsystem,
|
||||
Name: name,
|
||||
Help: help,
|
||||
}, labels)
|
||||
|
|
Loading…
Reference in a new issue