Class: Labkit::Middleware::Sidekiq::UserExperienceSli::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/labkit/middleware/sidekiq/user_experience_sli/client.rb

Overview

This middleware for Sidekiq-client wraps scheduling jobs with covered experience context. It retrieves the current experiences and populates the job with them.

Instance Method Summary collapse

Instance Method Details

#call(worker_class, job, _queue, _redis_pool) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/labkit/middleware/sidekiq/user_experience_sli/client.rb', line 13

def call(worker_class, job, _queue, _redis_pool)
  data = Labkit::UserExperienceSli::Current.active_experiences.inject({}) do |data, (_, xp)|
    xp.checkpoint(checkpoint_action: "sidekiq_job_scheduled", worker: worker_class.to_s)
    data.merge!(xp.to_h)
  end

  job[Labkit::UserExperienceSli::Current::AGGREGATION_KEY] = data unless data.empty?

  yield
end