Sha256: daa747884fc2c93e15f3db80026e327bc1022ae812b667326ff9e8e0edd7bccb

Contents?: true

Size: 1.13 KB

Versions: 24

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module ElasticAPM
  # @api private
  module Spies
    # @api private
    class RakeSpy
      # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
      def install
        ::Rake::Task.class_eval do
          alias execute_without_apm execute

          def execute(*args)
            agent = ElasticAPM.start

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

            transaction =
              ElasticAPM.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
              ElasticAPM.report(e)

              raise
            ensure
              ElasticAPM.end_transaction
              ElasticAPM.stop
            end

            result
          end
        end
      end
      # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
    end
    register 'Rake::Task', 'rake', RakeSpy.new
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
elastic-apm-3.2.0 lib/elastic_apm/spies/rake.rb
elastic-apm-3.1.0 lib/elastic_apm/spies/rake.rb
elastic-apm-3.0.0 lib/elastic_apm/spies/rake.rb
elastic-apm-2.12.0 lib/elastic_apm/spies/rake.rb
elastic-apm-2.11.0 lib/elastic_apm/spies/rake.rb
elastic-apm-2.10.1 lib/elastic_apm/spies/rake.rb
elastic-apm-2.10.0 lib/elastic_apm/spies/rake.rb
elastic-apm-2.9.1 lib/elastic_apm/spies/rake.rb
elastic-apm-2.9.0 lib/elastic_apm/spies/rake.rb
elastic-apm-2.8.1 lib/elastic_apm/spies/rake.rb
elastic-apm-2.8.0 lib/elastic_apm/spies/rake.rb
elastic-apm-2.7.0 lib/elastic_apm/spies/rake.rb
elastic-apm-2.6.1 lib/elastic_apm/spies/rake.rb
elastic-apm-2.6.0 lib/elastic_apm/spies/rake.rb
elastic-apm-2.5.0 lib/elastic_apm/spies/rake.rb
elastic-apm-2.4.0 lib/elastic_apm/spies/rake.rb
elastic-apm-2.3.1 lib/elastic_apm/spies/rake.rb
elastic-apm-2.3.0 lib/elastic_apm/spies/rake.rb
elastic-apm-2.2.0 lib/elastic_apm/spies/rake.rb
elastic-apm-2.1.2 lib/elastic_apm/spies/rake.rb