mperham/sidekiq — pull request #1317 by jamesotron (2013-11-05 21:37:51+00:00)
Title: Stop `Sidekiq::Queue#latency` from exploding when there is no `enqueued_at` property.

So, I'm not sure if you'll want this patch or not, but after running `bundle update sidekiq` (from 2.6.4 to 2.16.1) I noticed that `Sidekiq::Queue#latency` started raising the following:

```
TypeError: nil can't be coerced into Float
from /Users/jnh/.rvm/gems/ruby-2.0.0-p247/gems/sidekiq-2.16.1/lib/sidekiq/api.rb:116:in `-'
```

This was being caused by a job in stored in redis without an `enqueued_at` property:

```text
[8] pry(#):1> entry = Sidekiq.redis { |conn| conn.lrange(@rname, -1, -1) }.first
=> "{\"retry\":true,\"queue\":\"uploads\",\"class\":\"UploadWorker\",\"args\":[\"NN5i7Qnx\"],\"jid\":\"e7fc9abb4c64357bc624bf05\"}"
```

I'm not really sure how that happened, but I've patched it so that latency won't explode (although will probably return the wrong value) in this case.