{"action":"opened","issue":{"url":"https://api.github.com/repos/mperham/sidekiq/issues/2373","labels_url":"https://api.github.com/repos/mperham/sidekiq/issues/2373/labels{/name}","comments_url":"https://api.github.com/repos/mperham/sidekiq/issues/2373/comments","events_url":"https://api.github.com/repos/mperham/sidekiq/issues/2373/events","html_url":"https://github.com/mperham/sidekiq/issues/2373","id":83919336,"number":2373,"title":"Latency is confusing for scheduled jobs","user":{"login":"mrsimo","id":19203,"avatar_url":"https://avatars.githubusercontent.com/u/19203?v=3","gravatar_id":"","url":"https://api.github.com/users/mrsimo","html_url":"https://github.com/mrsimo","followers_url":"https://api.github.com/users/mrsimo/followers","following_url":"https://api.github.com/users/mrsimo/following{/other_user}","gists_url":"https://api.github.com/users/mrsimo/gists{/gist_id}","starred_url":"https://api.github.com/users/mrsimo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrsimo/subscriptions","organizations_url":"https://api.github.com/users/mrsimo/orgs","repos_url":"https://api.github.com/users/mrsimo/repos","events_url":"https://api.github.com/users/mrsimo/events{/privacy}","received_events_url":"https://api.github.com/users/mrsimo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-02T08:46:30Z","updated_at":"2015-06-02T08:46:30Z","closed_at":null,"body":"We're monitoring our [queue's `latency`](https://github.com/mperham/sidekiq/blob/2fc1d81cc9691c9232a088f1410c5a27fae5e11f/lib/sidekiq/api.rb#L213-L219) to get notified if it gets out of control.\r\n\r\nWe recently released a feature that schedules a sidekiq job to run in 10 hours. It's working great, but has caused that our monitoring sometines reports a latency of ~3600s (10 hours).\r\n\r\nThis is some debugging info:\r\n\r\n```\r\nlow has a latency of 36003.53266143799\r\nentry.enqueued_at: 1433196986.023483\r\nTime.now:          1433232989.5564206\r\n\"{\\\"retry\\\":0,\\\"queue\\\":\\\"low\\\",\\\"class\\\":\\\"WarnAboutRunawayTimerWorker\\\",\\\"args\\\":[337121779],\\\"jid\\\":\\\"b5acceac3b94680bc7d06448\\\",\\\"enqueued_at\\\":1433196986.023483}\"\r\n```\r\n\r\nI guess the `enqueued_at` is correct in a sense, but I wonder if we could do something about it. I've been using `Sidekiq::Stats::Queue#latency` to get that number, but I'd be fine calculating it manually.\r\n\r\nWould it make sense to change the `enqueued_at` to the time it's actually pulled from the scheduled set and into the actual queue? Maybe add another field `originally_enqueued_at` or something.\r\n\r\nThat's just an idea, anything that would let me know a more realistic latency would be welcome.\r\n\r\nThanks a lot!"}}