class Sidekiq::Metrics::Deploy
Constants
- MARK_TTL
Public Class Methods
new(pool = Sidekiq.redis_pool)
click to toggle source
# File lib/sidekiq/metrics/deploy.rb, line 18 def initialize(pool = Sidekiq.redis_pool) @pool = pool end
Public Instance Methods
fetch(date = Time.now.utc.to_date)
click to toggle source
# File lib/sidekiq/metrics/deploy.rb, line 41 def fetch(date = Time.now.utc.to_date) datecode = date.strftime("%Y%m%d") @pool.with { |c| c.hgetall("#{datecode}-marks") } end
mark(at: Time.now, label: "")
click to toggle source
# File lib/sidekiq/metrics/deploy.rb, line 22 def mark(at: Time.now, label: "") # we need to round the timestamp so that we gracefully # handle an excepted common error in marking deploys: # having every process mark its deploy, leading # to N marks for each deploy. Instead we round the time # to the minute so that multple marks within that minute # will all naturally rollup into one mark per minute. whence = at.utc floor = Time.utc(whence.year, whence.month, whence.mday, whence.hour, whence.min, 0) datecode = floor.strftime("%Y%m%d") key = "#{datecode}-marks" @pool.with do |c| c.pipelined do |pipe| pipe.hsetnx(key, floor.iso8601, label) pipe.expire(key, MARK_TTL) end end end