Sha256: ada89943089f95b969faf280349af9d544f0ec7f6bd14ac4466a9daca4cbea8d
Contents?: true
Size: 1.78 KB
Versions: 3
Compression:
Stored size: 1.78 KB
Contents
# encoding: utf-8 LibraryDetection.defer do @name = :sidekiq depends_on do defined?(::Sidekiq) && !OneApm::Agent.config[:disable_sidekiq] end executes do ::OneApm::Agent.logger.info 'Installing Sidekiq instrumentation' end executes do class OneApm::SidekiqInstrumentation include OneApm::Agent::Instrumentation::TransactionBase # Client middleware has additional parameters, and our tests use the # middleware client-side to work inline. def call(worker, msg, queue, *_) trace_args = if worker.respond_to?(:oneapm_trace_args) worker.oneapm_trace_args(msg, queue) else self.class.default_trace_args(msg) end perform_action_with_oneapm_trace(trace_args) do if OneApm::Agent.config[:'sidekiq.capture_params'] OneApm::Agent.add_custom_parameters(:job_arguments => msg['args']) end yield end end def self.default_trace_args(msg) { :name => 'perform', :class_name => msg['class'], :category => 'OtherTransaction/SidekiqJob' } end end class Sidekiq::Extensions::DelayedClass def oneapm_trace_args(msg, queue) (target, method_name, _args) = YAML.load(msg['args'][0]) { :name => method_name, :class_name => target.name, :category => 'OtherTransaction/SidekiqJob' } rescue => e OneApm::Agent.logger.error("Failure during deserializing YAML for Sidekiq::Extensions::DelayedClass", e) OneApm::SidekiqInstrumentation.default_trace_args(msg) end end Sidekiq.configure_server do |config| config.server_middleware do |chain| chain.add OneApm::SidekiqInstrumentation end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
oneapm_rpm-1.1.2 | lib/one_apm/inst/background_job/sidekiq.rb |
oneapm_rpm-1.1.1 | lib/one_apm/inst/background_job/sidekiq.rb |
oneapm_rpm-1.1.0 | lib/one_apm/inst/background_job/sidekiq.rb |