Sha256: 13918d65ef41e7f00198ef6b6ea1bd2b51b73a86f014e8ec2e6d448aac851300

Contents?: true

Size: 1.08 KB

Versions: 23

Compression:

Stored size: 1.08 KB

Contents

module Appsignal
  class Hooks
    # @api private
    class RakeHook < Appsignal::Hooks::Hook
      register :rake

      def dependencies_present?
        defined?(::Rake::Task)
      end

      def install
        ::Rake::Task.class_eval do
          alias :execute_without_appsignal :execute

          def execute(*args)
            execute_without_appsignal(*args)
          rescue Exception => error # rubocop:disable Lint/RescueException
            # Format given arguments and cast to hash if possible
            params, _ = args
            params = params.to_hash if params.respond_to?(:to_hash)

            transaction = Appsignal::Transaction.create(
              SecureRandom.uuid,
              Appsignal::Transaction::BACKGROUND_JOB,
              Appsignal::Transaction::GenericRequest.new(
                :params => params
              )
            )
            transaction.set_action(name)
            transaction.set_error(error)
            transaction.complete
            Appsignal.stop("rake")
            raise error
          end
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
appsignal-2.5.3-java lib/appsignal/hooks/rake.rb
appsignal-2.5.3 lib/appsignal/hooks/rake.rb
appsignal-2.5.3.alpha.2 lib/appsignal/hooks/rake.rb
appsignal-2.5.3.alpha.2-java lib/appsignal/hooks/rake.rb
appsignal-2.5.3.alpha.1 lib/appsignal/hooks/rake.rb
appsignal-2.5.3.alpha.1-java lib/appsignal/hooks/rake.rb
appsignal-2.5.2-java lib/appsignal/hooks/rake.rb
appsignal-2.5.2 lib/appsignal/hooks/rake.rb
appsignal-2.5.1-java lib/appsignal/hooks/rake.rb
appsignal-2.5.1 lib/appsignal/hooks/rake.rb
appsignal-2.5.1.beta.1-java lib/appsignal/hooks/rake.rb
appsignal-2.5.1.beta.1 lib/appsignal/hooks/rake.rb
appsignal-2.5.0-java lib/appsignal/hooks/rake.rb
appsignal-2.5.0 lib/appsignal/hooks/rake.rb
appsignal-2.5.0.beta.1-java lib/appsignal/hooks/rake.rb
appsignal-2.5.0.beta.1 lib/appsignal/hooks/rake.rb
appsignal-2.5.0.alpha.1-java lib/appsignal/hooks/rake.rb
appsignal-2.5.0.alpha.1 lib/appsignal/hooks/rake.rb
appsignal-2.4.3 lib/appsignal/hooks/rake.rb
appsignal-2.4.2 lib/appsignal/hooks/rake.rb