diff --git a/internal/subaccountsync/metrics.go b/internal/subaccountsync/metrics.go index 890900eb6e..2daafb1b98 100644 --- a/internal/subaccountsync/metrics.go +++ b/internal/subaccountsync/metrics.go @@ -8,6 +8,7 @@ type Metrics struct { cisRequests *prometheus.CounterVec states *prometheus.GaugeVec informer *prometheus.CounterVec + timeInQueue prometheus.Gauge } func NewMetrics(reg prometheus.Registerer, namespace string) *Metrics { @@ -37,6 +38,11 @@ func NewMetrics(reg prometheus.Registerer, namespace string) *Metrics { Name: "priority_queue_size", Help: "Queue size.", }), + timeInQueue: prometheus.NewGauge(prometheus.GaugeOpts{ + Namespace: namespace, + Name: "time_in_queue", + Help: "Time spent in queue.", + }), } reg.MustRegister(m.queue, m.queueOps, m.states, m.informer, m.cisRequests) return m diff --git a/internal/subaccountsync/subaccount_sync_service.go b/internal/subaccountsync/subaccount_sync_service.go index 55e2272c2d..54df82e755 100644 --- a/internal/subaccountsync/subaccount_sync_service.go +++ b/internal/subaccountsync/subaccount_sync_service.go @@ -114,6 +114,7 @@ func (s *SyncService) Run() { OnExtract: func(queueSize int, timeEnqueued int64) { metrics.queue.Set(float64(queueSize)) metrics.queueOps.With(prometheus.Labels{"operation": "extract"}).Inc() + metrics.timeInQueue.Set(float64(epochInMillis() - timeEnqueued)) }, })