Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log Sidekiq worker arguments #3386

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'three_scale/sidekiq_retry_support'
require 'three_scale/sidekiq_logging_middleware'
require 'sidekiq/throttled'
require 'sidekiq/logging'

Sidekiq::Throttled.setup!

Expand Down Expand Up @@ -49,3 +50,19 @@
chain.add ThreeScale::SidekiqLoggingMiddleware
end
end

module Sidekiq
module Logging
# override existing log to include the arguments passed to `perform`
# source: https://github.com/sidekiq/sidekiq/issues/1786#issuecomment-313461945
# NOTE: needs to be changed after upgrading to Sidekiq 6
def self.job_hash_context(job_hash)
# If we're using a wrapper class, like ActiveJob, use the "wrapped"
# attribute to expose the underlying thing.
klass = job_hash['wrapped'] || job_hash['class']
bid = job_hash['bid']
args = job_hash['args']
"#{klass} JID-#{job_hash['jid']}#{" BID-#{bid}" if bid}#{" ARGS-#{args}" if args}"
end
end
end