Skip to content

Instantly share code, notes, and snippets.

@eguchi-ken
Created September 1, 2022 09:39
Show Gist options
  • Save eguchi-ken/718291e3c986b001a4a5e56cb7244d35 to your computer and use it in GitHub Desktop.
Save eguchi-ken/718291e3c986b001a4a5e56cb7244d35 to your computer and use it in GitHub Desktop.
sidekiq のジョブの引数の長さとか調べるやつ
def get_working_job_argument_size
workers = Sidekiq::Workers.new
workers.filter_map do |_process_id, _thread_id, work|
payload = work.to_a[1]
job_class = payload[1]['args'][0]["job_class"]
arguments = payload[1]['args'][0]["arguments"]
if arguments && arguments.length > 1
result = [job_class]
# 引数のうち配列部分だけ長さチェック
arguments.each do |argument|
if argument.is_a?(Array)
result << argument.length
end
end
result
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment