Sha256: bc67ee3b5303d97d7c921998ac8b216fa664e1061ab0ec8cbf0844343206002e

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 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, 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_exception?(exception)
              Appsignal::Transaction.current.add_exception(exception)
            end
            raise exception
          ensure
            Appsignal::Transaction.current.complete!
          end
        end

      end
    end
  end

  app_settings = ::Sinatra::Application.settings
  Appsignal.config = Appsignal::Config.new(
    app_settings.root,
    app_settings.environment
  )

  Appsignal.start_logger(app_settings.root)

  if Appsignal.active?
    Appsignal.start

    DispatchRider.config do |config|

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

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

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