diff --git a/internal/worker/notifications.go b/internal/worker/notifications.go index c95c196..47152f9 100644 --- a/internal/worker/notifications.go +++ b/internal/worker/notifications.go @@ -214,13 +214,6 @@ func (nc *notificationsConsumer) Consume(delivery rmq.Delivery) { rac = nc.reddit.NewAuthenticatedClient(account.AccountID, tokens.RefreshToken, tokens.AccessToken) } - // Only update delay on accounts we can actually check, otherwise it skews - // the numbers too much. - if !newAccount { - latency := now.Sub(previousNextCheck) - _ = nc.statsd.Histogram("apollo.queue.delay", float64(latency.Milliseconds()), []string{}, rate) - } - nc.logger.Debug("fetching message inbox", zap.String("account#reddit_account_id", id), zap.String("account#username", account.NormalizedUsername())) opts := []reddit.RequestOption{reddit.WithQuery("limit", "10")} @@ -313,6 +306,11 @@ func (nc *notificationsConsumer) Consume(delivery rmq.Delivery) { continue } + // Latency is the time difference between the appearence of the new message and the + // time we notified at. + latency := now.Sub(msg.CreatedAt) + _ = nc.statsd.Histogram("apollo.queue.delay", float64(latency.Milliseconds()), []string{}, rate) + notification := &apns2.Notification{} notification.Topic = "com.christianselig.Apollo" notification.Payload = payloadFromMessage(account, msg, msgs.Count)