class SidekiqProfilingMiddleware::StackProf
Attributes
only[R]
options[R]
output_prefix[R]
s3_bucket[R]
Public Class Methods
default_output_prefix()
click to toggle source
# File lib/sidekiq_profiling_middleware/stack_prof.rb, line 39 def self.default_output_prefix @default_output_prefix ||= Util.default_output_prefix("stackprof") end
new(output_prefix: nil, only: nil, s3_bucket: nil, stack_prof_options: {})
click to toggle source
# File lib/sidekiq_profiling_middleware/stack_prof.rb, line 7 def initialize(output_prefix: nil, only: nil, s3_bucket: nil, stack_prof_options: {}) stack_prof_options[:mode] ||= :cpu stack_prof_options[:interval] ||= 1000 @options = stack_prof_options @output_prefix = output_prefix || self.class.default_output_prefix @only = only @s3_bucket = s3_bucket end
Public Instance Methods
call(worker, msg, queue) { || ... }
click to toggle source
# File lib/sidekiq_profiling_middleware/stack_prof.rb, line 17 def call(worker, msg, queue) # bail out if whitelist doesn't match if only && !only.include?(worker.class) return yield end out = "#{output_prefix}#{Util.worker_names[worker.class]}_#{Util.current_epoch_ms}.dump" unless s3_bucket ::StackProf.run(options.merge(out: out)) { yield } return end require "sidekiq_profiling_middleware/s3" out = S3::Object.new(bucket: s3_bucket, key: out) rep = ::StackProf.run(options) { yield } Marshal.dump(rep, out) ensure out.upload if out && s3_bucket end