Sha256: 24e6e2dda7a0bbe083ac9a8b890ee8936b509b50be5eee9abc96c99718e53c3e
Contents?: true
Size: 1.6 KB
Versions: 3
Compression:
Stored size: 1.6 KB
Contents
module Appsignal class Hooks # @api private class SidekiqPlugin include Appsignal::Hooks::Helpers def job_keys @job_keys ||= Set.new(%w( class args retried_at failed_at error_message error_class backtrace error_backtrace enqueued_at retry jid retry created_at wrapped )) end def call(_worker, item, _queue) params = if item["class"] == "ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper" format_args(item["args"].first["arguments"]) else format_args(item["args"]) end Appsignal.monitor_transaction( "perform_job.sidekiq", :class => item["wrapped"] || item["class"], :method => "perform", :metadata => formatted_metadata(item), :params => params, :queue_start => item["enqueued_at"], :queue_time => (Time.now.to_f - item["enqueued_at"].to_f) * 1000 ) do yield end end def formatted_metadata(item) {}.tap do |hsh| item.each do |key, val| hsh[key] = truncate(string_or_inspect(val)) unless job_keys.include?(key) end end end end class SidekiqHook < Appsignal::Hooks::Hook register :sidekiq def dependencies_present? defined?(::Sidekiq) end def install ::Sidekiq.configure_server do |config| config.server_middleware do |chain| chain.add Appsignal::Hooks::SidekiqPlugin end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
appsignal-2.2.1 | lib/appsignal/hooks/sidekiq.rb |
appsignal-2.2.0 | lib/appsignal/hooks/sidekiq.rb |
appsignal-2.2.0.beta.1 | lib/appsignal/hooks/sidekiq.rb |