From 029566b625142b4c240c6f06cb6dd509aaed6a54 Mon Sep 17 00:00:00 2001 From: Joshua Gutow Date: Mon, 10 Apr 2023 16:13:52 -0700 Subject: [PATCH] op-service/metrics: Add subssystem to event metrics --- op-batcher/metrics/metrics.go | 4 ++-- op-service/metrics/event.go | 8 ++++++-- op-service/txmgr/metrics/tx_metrics.go | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/op-batcher/metrics/metrics.go b/op-batcher/metrics/metrics.go index 6c92602ab85b9..b9af9ee46ff05 100644 --- a/op-batcher/metrics/metrics.go +++ b/op-batcher/metrics/metrics.go @@ -100,7 +100,7 @@ func NewMetrics(procName string) *Metrics { Help: "1 if the op-batcher has finished starting up", }), - ChannelEvs: opmetrics.NewEventVec(factory, ns, "channel", "Channel", []string{"stage"}), + ChannelEvs: opmetrics.NewEventVec(factory, ns, "", "channel", "Channel", []string{"stage"}), PendingBlocksCount: *factory.NewGaugeVec(prometheus.GaugeOpts{ Namespace: ns, @@ -145,7 +145,7 @@ func NewMetrics(procName string) *Metrics { Buckets: append([]float64{0.1, 0.2}, prometheus.LinearBuckets(0.3, 0.05, 14)...), }), - BatcherTxEvs: opmetrics.NewEventVec(factory, ns, "batcher_tx", "BatcherTx", []string{"stage"}), + BatcherTxEvs: opmetrics.NewEventVec(factory, ns, "", "batcher_tx", "BatcherTx", []string{"stage"}), } } diff --git a/op-service/metrics/event.go b/op-service/metrics/event.go index 78143727189e3..552e0ad414d3f 100644 --- a/op-service/metrics/event.go +++ b/op-service/metrics/event.go @@ -16,17 +16,19 @@ func (e *Event) Record() { e.LastTime.SetToCurrentTime() } -func NewEvent(factory Factory, ns string, name string, displayName string) Event { +func NewEvent(factory Factory, ns string, subsystem string, name string, displayName string) Event { return Event{ Total: factory.NewCounter(prometheus.CounterOpts{ Namespace: ns, Name: fmt.Sprintf("%s_total", name), Help: fmt.Sprintf("Count of %s events", displayName), + Subsystem: subsystem, }), LastTime: factory.NewGauge(prometheus.GaugeOpts{ Namespace: ns, Name: fmt.Sprintf("last_%s_unix", name), Help: fmt.Sprintf("Timestamp of last %s event", displayName), + Subsystem: subsystem, }), } } @@ -41,17 +43,19 @@ func (e *EventVec) Record(lvs ...string) { e.LastTime.WithLabelValues(lvs...).SetToCurrentTime() } -func NewEventVec(factory Factory, ns string, name string, displayName string, labelNames []string) EventVec { +func NewEventVec(factory Factory, ns string, subsystem string, name string, displayName string, labelNames []string) EventVec { return EventVec{ Total: *factory.NewCounterVec(prometheus.CounterOpts{ Namespace: ns, Name: fmt.Sprintf("%s_total", name), Help: fmt.Sprintf("Count of %s events", displayName), + Subsystem: subsystem, }, labelNames), LastTime: *factory.NewGaugeVec(prometheus.GaugeOpts{ Namespace: ns, Name: fmt.Sprintf("last_%s_unix", name), Help: fmt.Sprintf("Timestamp of last %s event", displayName), + Subsystem: subsystem, }, labelNames), } } diff --git a/op-service/txmgr/metrics/tx_metrics.go b/op-service/txmgr/metrics/tx_metrics.go index 2ae036b33f814..28dd465002330 100644 --- a/op-service/txmgr/metrics/tx_metrics.go +++ b/op-service/txmgr/metrics/tx_metrics.go @@ -73,8 +73,8 @@ func MakeTxMetrics(ns string, factory metrics.Factory) TxMetrics { Help: "Count of publish errors. Labells are sanitized error strings", Subsystem: "txmgr", }, []string{"error"}), - confirmEvent: metrics.NewEventVec(factory, ns, "confirm", "tx confirm", []string{"status"}), - publishEvent: metrics.NewEvent(factory, ns, "publish", "tx publish"), + confirmEvent: metrics.NewEventVec(factory, ns, "txmgr", "confirm", "tx confirm", []string{"status"}), + publishEvent: metrics.NewEvent(factory, ns, "txmgr", "publish", "tx publish"), rpcError: factory.NewCounter(prometheus.CounterOpts{ Namespace: ns, Name: "rpc_error_count",