Class: Appsignal::Hooks::RakeHook

Inherits:
Hook
  • Object
show all
Defined in:
lib/appsignal/hooks/rake.rb

Instance Method Summary collapse

Methods inherited from Hook

#installed?, register, #try_to_install

Instance Method Details

#dependencies_present?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/appsignal/hooks/rake.rb', line 6

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

#installObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/appsignal/hooks/rake.rb', line 10

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

    def execute(*args)
      execute_without_appsignal(*args)
    rescue => error
      transaction = Appsignal::Transaction.create(
        SecureRandom.uuid,
        Appsignal::Transaction::BACKGROUND_JOB,
        Appsignal::Transaction::GenericRequest.new(
          :params => args
        )
      )
      transaction.set_action(name)
      transaction.set_error(error)
      transaction.complete
      Appsignal.stop('rake')
      raise error
    end
  end
end