Sha256: 0258f1ab12a4812c9f169f37879a0735aa58e35e052a642ea309df99fafeb909

Contents?: true

Size: 1.85 KB

Versions: 6

Compression:

Stored size: 1.85 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?
            # Hackety hack around stateful mess of Appsignal gem
            if Appsignal::Transaction.current
              Appsignal::Transaction.current.set_tags(parameters)
              Appsignal::Transaction.current.add_exception(exception)
            else
              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
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
roqua-support-0.1.12 lib/roqua/support/errors.rb
roqua-support-0.1.11 lib/roqua/support/errors.rb
roqua-support-0.1.10 lib/roqua/support/errors.rb
roqua-support-0.1.9 lib/roqua/support/errors.rb
roqua-support-0.1.8 lib/roqua/support/errors.rb
roqua-support-0.1.7 lib/roqua/support/errors.rb