Skip to content

Instantly share code, notes, and snippets.

@nandilugio
Last active January 6, 2023 10:01
Show Gist options
  • Save nandilugio/b88cd8d2d84931910e7bc0c42be6adff to your computer and use it in GitHub Desktop.
Save nandilugio/b88cd8d2d84931910e7bc0c42be6adff to your computer and use it in GitHub Desktop.
#### Move queue data between machines ####
# Extract data as .yml file
rs = Sidekiq::RetrySet.new
report_yml = rs.to_a.to_yaml;
File.open('sidekiq_retries.yml', 'w') { |f| f.write(report_yml) }
# Read the data back
report_yml = File.open("sidekiq_retries.yml rb").read;
rs = YAML::load(report_yml);
#### Normalize AsyncMethodInvokerWorker usages ####
items = rs.map(&:item);
relation = items.map do |item|
if item["class"] == "AsyncMethodInvokerWorker"
worker = "AsyncMethodInvokerWorker: #{item["args"][0]}##{item["args"][2]}"
args = [item["args"][1]] + item["args"][3..-1]
else
worker = item["class"]
args = item["args"]
end
[item["queue"], worker, args, item["error_class"], item["error_message"], item["retry_count"]]
end;
#### Convert data into analysis-friendly .csv ####
CSV.open("sidekiq_retries.csv", "wb") do |csv|
relation.each { |item| csv << item }
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment