Sha256: 489405f2daa44a45b835601bdb5a2be1a22508eb8b4b8dc70bd399d9983a0c43

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

if defined? Appsignal
  ::Appsignal.logger.info('Loading Dispatch Rider integration')

  module DispatchRider
    module Integrations
      module Appsignal

        def self.wrap_message(job, message)
          begin
            ::Appsignal::Transaction.create(
              SecureRandom.uuid,
              ::Appsignal::Transaction::BACKGROUND_JOB,
              ::Appsignal::Transaction::GenericRequest.new(ENV.to_hash)
            )

            ::ActiveSupport::Notifications.instrument(
              'perform_job.dispatch-rider',
              :class => message.subject,
              :method => 'handle',
              :attempts => message.receive_count,
              :queue => message.queue_name,
              :queue_time => (Time.now.to_f - message.sent_at.to_f) * 1000
            ) do
              job.call
            end
          rescue Exception => exception
            unless ::Appsignal.is_ignored_error?(exception)
              ::Appsignal::Transaction.current.add_error(exception)
            end
            raise exception
          ensure
            ::Appsignal::Transaction.complete_current!
          end
        end

      end
    end
  end

  DispatchRider.configure do |config|

    config.around(:dispatch_message) do |job, message|
      DispatchRider::Integrations::Appsignal.wrap_message(job, message)
    end

  end

  if ::Appsignal.active?
    ::Appsignal.start
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dispatch-rider-1.8.2 lib/dispatch-rider/integrations/appsignal.rb