Sha256: 3cb539497ede2a3a26b8ad2f6a13637d36fd6a1a3ebf90daf5cf5e825a047ace

Contents?: true

Size: 1.05 KB

Versions: 15

Compression:

Stored size: 1.05 KB

Contents

require 'ddtrace/contrib/patcher'
require 'ddtrace/ext/app_types'
require 'ddtrace/contrib/rake/ext'
require 'ddtrace/contrib/rake/instrumentation'

module Datadog
  module Contrib
    module Rake
      # Patcher enables patching of 'rake' module.
      module Patcher
        include Contrib::Patcher

        module_function

        def patched?
          done?(:rake)
        end

        def patch
          do_once(:rake) do
            begin
              # Add instrumentation patch to Rake task
              ::Rake::Task.send(:include, Instrumentation)

              # Set service info
              get_option(:tracer).set_service_info(
                get_option(:service_name),
                Ext::APP,
                Datadog::Ext::AppTypes::WORKER
              )
            rescue StandardError => e
              Datadog::Tracer.log.error("Unable to apply Rake integration: #{e}")
            end
          end
        end

        def get_option(option)
          Datadog.configuration[:rake].get_option(option)
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ddtrace-0.22.0 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.21.2 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.21.1 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.21.0 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.20.0 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.19.1 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.19.0 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.18.3 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.18.2 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.18.1 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.18.0 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.17.3 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.17.2 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.17.1 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.17.0 lib/ddtrace/contrib/rake/patcher.rb