diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b9cad6..ca0f808 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## Unreleased +## 0.8.1 - 2021-08-24 + +### Fixed + + - Compatibility with Sidekiq 6.2.2+ due to renamings in Sidekiq's undocumented API that yabeda-sidekiq uses. See [mperham/sidekiq#4971](https://github.com/mperham/sidekiq/discussions/4971). [@Envek] + ## 0.8.0 - 2021-05-12 ### Added diff --git a/lib/yabeda/sidekiq/server_middleware.rb b/lib/yabeda/sidekiq/server_middleware.rb index d1fad9d..0dba19f 100644 --- a/lib/yabeda/sidekiq/server_middleware.rb +++ b/lib/yabeda/sidekiq/server_middleware.rb @@ -4,13 +4,16 @@ module Yabeda module Sidekiq # Sidekiq worker middleware class ServerMiddleware + # See https://github.com/mperham/sidekiq/discussions/4971 + JOB_RECORD_CLASS = defined?(::Sidekiq::JobRecord) ? ::Sidekiq::JobRecord : ::Sidekiq::Job + # rubocop: disable Metrics/AbcSize, Metrics/MethodLength: def call(worker, job, queue) custom_tags = Yabeda::Sidekiq.custom_tags(worker, job).to_h labels = Yabeda::Sidekiq.labelize(worker, job, queue).merge(custom_tags) start = Process.clock_gettime(Process::CLOCK_MONOTONIC) begin - job_instance = ::Sidekiq::Job.new(job) + job_instance = JOB_RECORD_CLASS.new(job) Yabeda.sidekiq_job_latency.measure(labels, job_instance.latency) Yabeda::Sidekiq.jobs_started_at[labels][job["jid"]] = start Yabeda.with_tags(**custom_tags) do diff --git a/lib/yabeda/sidekiq/version.rb b/lib/yabeda/sidekiq/version.rb index 4660b5e..736b0d1 100644 --- a/lib/yabeda/sidekiq/version.rb +++ b/lib/yabeda/sidekiq/version.rb @@ -2,6 +2,6 @@ module Yabeda module Sidekiq - VERSION = "0.8.0" + VERSION = "0.8.1" end end