mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-25 13:17:42 +00:00
update queue delay in a better spot
This commit is contained in:
parent
d9f64765f0
commit
0262133ce8
1 changed files with 8 additions and 6 deletions
|
@ -181,11 +181,6 @@ func (nc *notificationsConsumer) Consume(delivery rmq.Delivery) {
|
|||
return
|
||||
}
|
||||
|
||||
if account.LastCheckedAt > 0 {
|
||||
latency := now - account.LastCheckedAt - float64(backoff)
|
||||
nc.statsd.Histogram("apollo.queue.delay", latency, []string{}, rate)
|
||||
}
|
||||
|
||||
if err = nc.db.BeginFunc(ctx, func(tx pgx.Tx) error {
|
||||
stmt := `
|
||||
UPDATE accounts
|
||||
|
@ -231,7 +226,7 @@ refreshToken:
|
|||
stmt := `
|
||||
UPDATE accounts
|
||||
SET access_token = $1, refresh_token = $2, expires_at = $3 WHERE id = $4`
|
||||
_, err := tx.Exec(ctx, stmt, tokens.AccessToken, tokens.RefreshToken, int64(now+3540), account.ID)
|
||||
_, err := tx.Exec(ctx, stmt, account.AccessToken, account.RefreshToken, account.ExpiresAt, account.ID)
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -243,6 +238,13 @@ refreshToken:
|
|||
}
|
||||
}
|
||||
|
||||
// Only update delay on accounts we can actually check, otherwise it skews
|
||||
// the numbers too much.
|
||||
if account.LastCheckedAt > 0 {
|
||||
latency := now - account.LastCheckedAt - float64(backoff)
|
||||
nc.statsd.Histogram("apollo.queue.delay", latency, []string{}, rate)
|
||||
}
|
||||
|
||||
nc.logger.WithFields(logrus.Fields{
|
||||
"accountID": id,
|
||||
}).Debug("fetching message inbox")
|
||||
|
|
Loading…
Reference in a new issue