Sha256: f4f1c1fad5876bb7674b274c8267828efcc5efc672f7d141a20791661d9c5cbd

Contents?: true

Size: 1.57 KB

Versions: 5

Compression:

Stored size: 1.57 KB

Contents

module Roqua
  module Support
    module Errors
      def self.extra_parameters
        @extra_parameters || {}
      end

      def self.extra_parameters=(hash)
        @extra_parameters = hash
      end

      def self.report(exception, extra_params = {})
        return if const_defined?(:Rails) and Rails.env.test?
        parameters = extra_parameters.merge(extra_params)

        # Notify Roqua logging
        if Roqua.respond_to?(:logger)
          Roqua.logger.error('roqua.exception',
                             class_name: exception.class.to_s,
                             message: exception.message,
                             backtrace: exception.backtrace,
                             parameters: parameters)
        end

        # Notify Airbrake
        if const_defined?(:Airbrake)
          Airbrake.notify_or_ignore(exception, parameters: parameters)
        end

        # Notify AppSignal
        if const_defined?(:Appsignal) and
           not Appsignal.is_ignored_exception?(exception)
          # TODO: If and when https://github.com/appsignal/appsignal/pull/9 is merged,
          # this functionality should be supported directly by Appsignal.send_exception.
          # Appsignal.send_exception(exception, parameters: parameters)

          if Appsignal.active?
            transaction = Appsignal::Transaction.create(SecureRandom.uuid, ENV.to_hash)
            transaction.set_tags(parameters)
            transaction.add_exception(exception)
            transaction.complete!
            Appsignal.agent.send_queue
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
roqua-support-0.1.6 lib/roqua/support/errors.rb
roqua-support-0.1.5 lib/roqua/support/errors.rb
roqua-support-0.1.4 lib/roqua/support/errors.rb
roqua-support-0.1.3 lib/roqua/support/errors.rb
roqua-support-0.1.2.2 lib/roqua/support/errors.rb