Class: Appsignal::Integrations::SidekiqMiddleware Private
- Includes:
- Hooks::Helpers
- Defined in:
- lib/appsignal/integrations/sidekiq.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- EXCLUDED_JOB_KEYS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%w[ args backtrace class created_at enqueued_at error_backtrace error_class error_message failed_at jid retried_at retry wrapped ].freeze
Class Method Summary collapse
- .sidekiq8? ⇒ Boolean private
Instance Method Summary collapse
Methods included from Hooks::Helpers
Class Method Details
.sidekiq8? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
61 62 63 64 65 |
# File 'lib/appsignal/integrations/sidekiq.rb', line 61 def self.sidekiq8? return false unless ::Sidekiq.respond_to?(:gem_version) @sidekiq8 ||= ::Sidekiq.gem_version >= Gem::Version.new("8.0.0") end |
Instance Method Details
#call(_worker, item, _queue, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/appsignal/integrations/sidekiq.rb', line 67 def call(_worker, item, _queue, &block) job_status = nil transaction = Appsignal::Transaction.create(Appsignal::Transaction::BACKGROUND_JOB) transaction.set_action_if_nil(formatted_action_name(item)) (item).each do |key, value| transaction. key, value end Appsignal.instrument "perform_job.sidekiq", &block rescue Exception => exception # rubocop:disable Lint/RescueException job_status = :failed raise exception ensure if transaction transaction.add_params_if_nil { parse_arguments(item) } enqueued_at = item["enqueued_at"] queue_start = if self.class.sidekiq8? enqueued_at.to_i # Sidekiq 8 stores it as epoc milliseconds else # Convert seconds to milliseconds for Sidekiq 7 and older (enqueued_at.to_f * 1000.0).to_i end transaction.set_queue_start(queue_start) transaction.(:request_id => item["jid"]) Appsignal::Transaction.complete_current! unless exception queue = item["queue"] || "unknown" if job_status increment_counter "queue_job_count", 1, :queue => queue, :status => job_status end increment_counter "queue_job_count", 1, :queue => queue, :status => :processed end end |