From da20e76d1b82e3dec093953eaea702fa869261a0 Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Wed, 13 Jul 2022 16:46:10 -0400 Subject: [PATCH] measure message age --- internal/worker/notifications.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/worker/notifications.go b/internal/worker/notifications.go index 7c47927..db7b8dc 100644 --- a/internal/worker/notifications.go +++ b/internal/worker/notifications.go @@ -139,8 +139,9 @@ func (nc *notificationsConsumer) Consume(delivery rmq.Delivery) { key := fmt.Sprintf("locks:accounts:%s", id) // Measure queue latency - ttl := nc.redis.TTL(nc, key).Val().Milliseconds() - _ = nc.statsd.Histogram("apollo.dequeue.time", float64(ttl), []string{"queue:notifications"}, 1.0) + ttl := nc.redis.TTL(nc, key).Val() + age := (domain.NotificationCheckTimeout - ttl) + _ = nc.statsd.Histogram("apollo.dequeue.latency", float64(age.Milliseconds()), []string{"queue:notifications"}, 1.0) defer func() { if err := nc.redis.Del(nc, key).Err(); err != nil {