Class: Atatus::Spies::RakeSpy Private

Inherits:
Object
  • Object
show all
Defined in:
lib/atatus/spies/rake.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#installObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/atatus/spies/rake.rb', line 25

def install
  if defined?(::Rake) && defined?(::Rake::Task)

    ::Rake::Task.class_eval do
      alias execute_without_apm execute

      def execute(*args)
        agent = Atatus.start

        unless agent && agent.config.instrumented_rake_tasks.include?(name)
          return execute_without_apm(*args)
        end

        transaction =
          Atatus.start_transaction("Rake::Task[#{name}]", 'Rake')

        begin
          result = execute_without_apm(*args)

          transaction.result = 'success' if transaction
        rescue StandardError => e
          transaction.result = 'error' if transaction
          Atatus.report(e)

          raise
        ensure
          Atatus.end_transaction
          Atatus.stop
        end

        result
      end
    end

  end
end