1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Flush job stats at exit, fixes #4498

This commit is contained in:
Mike Perham 2020-03-18 19:45:53 -07:00
parent 6bd4eaffdc
commit 4540903dd4
2 changed files with 19 additions and 0 deletions

View file

@ -9,6 +9,7 @@ HEAD
Set `Type=notify` in [sidekiq.service](https://github.com/mperham/sidekiq/blob/4b8a8bd3ae42f6e48ae1fdaf95ed7d7af18ed8bb/examples/systemd/sidekiq.service#L30-L39). The integration works automatically.
- Use `setTimeout` rather than `setInterval` to avoid thundering herd [#4480]
- Fix edge case where a job can be pushed without a queue.
- Flush job stats at exit [#4498]
- Check RAILS_ENV before RACK_ENV [#4493]
- Add Lithuanian locale [#4476]

View file

@ -96,6 +96,24 @@ module Sidekiq
end
def self.flush_stats
nowdate = Time.now.utc.strftime("%Y-%m-%d")
fails = Processor::FAILURE.reset
procd = Processor::PROCESSED.reset
Sidekiq.redis do |conn|
conn.pipelined do
conn.incrby("stat:processed", procd)
conn.incrby("stat:processed:#{nowdate}", procd)
conn.expire("stat:processed:#{nowdate}", STATS_TTL)
conn.incrby("stat:failed", fails)
conn.incrby("stat:failed:#{nowdate}", fails)
conn.expire("stat:failed:#{nowdate}", STATS_TTL)
end
end
end
at_exit(&method(:flush_stats))
def
key = identity
fails = procd = 0