Sha256: 48a4850cea68825f98ea7f01656769a7f01da6bdcfab89b2f0de1e6b821d51bd

Contents?: true

Size: 1.47 KB

Versions: 34

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

module Appsignal
  module Integrations
    module QuePlugin
      def self.included(base)
        base.class_eval do
          def _run_with_appsignal(*)
            local_attrs = respond_to?(:que_attrs) ? que_attrs : attrs
            env = {
              :metadata    => {
                :id        => local_attrs[:job_id] || local_attrs[:id],
                :queue     => local_attrs[:queue],
                :run_at    => local_attrs[:run_at].to_s,
                :priority  => local_attrs[:priority],
                :attempts  => local_attrs[:error_count].to_i
              },
              :params => local_attrs[:args]
            }

            request = Appsignal::Transaction::GenericRequest.new(env)

            transaction = Appsignal::Transaction.create(
              SecureRandom.uuid,
              Appsignal::Transaction::BACKGROUND_JOB,
              request
            )

            begin
              Appsignal.instrument("perform_job.que") { _run_without_appsignal }
            rescue Exception => error # rubocop:disable Lint/RescueException
              transaction.set_error(error)
              raise error
            ensure
              transaction.set_action_if_nil "#{local_attrs[:job_class]}#run"
              Appsignal::Transaction.complete_current!
            end
          end

          alias_method :_run_without_appsignal, :_run
          alias_method :_run, :_run_with_appsignal
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
appsignal-2.11.10-java lib/appsignal/integrations/que.rb
appsignal-2.11.10 lib/appsignal/integrations/que.rb
appsignal-2.11.9-java lib/appsignal/integrations/que.rb
appsignal-2.11.9 lib/appsignal/integrations/que.rb
appsignal-2.11.8-java lib/appsignal/integrations/que.rb
appsignal-2.11.8 lib/appsignal/integrations/que.rb
appsignal-2.11.7 lib/appsignal/integrations/que.rb
appsignal-2.11.7-java lib/appsignal/integrations/que.rb
appsignal-2.11.6 lib/appsignal/integrations/que.rb
appsignal-2.11.6-java lib/appsignal/integrations/que.rb
appsignal-2.11.5-java lib/appsignal/integrations/que.rb
appsignal-2.11.5 lib/appsignal/integrations/que.rb
appsignal-2.11.4-java lib/appsignal/integrations/que.rb
appsignal-2.11.4 lib/appsignal/integrations/que.rb
appsignal-2.11.3-java lib/appsignal/integrations/que.rb
appsignal-2.11.3 lib/appsignal/integrations/que.rb
appsignal-2.11.2-java lib/appsignal/integrations/que.rb
appsignal-2.11.2 lib/appsignal/integrations/que.rb
appsignal-2.11.1-java lib/appsignal/integrations/que.rb
appsignal-2.11.1 lib/appsignal/integrations/que.rb