Sha256: c876f92d1db92777ae82ebe791fd869009411f094ee4ae3cc408054ca9fccd92

Contents?: true

Size: 1.13 KB

Versions: 17

Compression:

Stored size: 1.13 KB

Contents

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

module Datadog
  module Contrib
    module Rake
      # Patcher for Rake instrumentation
      module Patcher
        include Base

        register_as :rake
        option :service_name, default: 'rake'
        option :tracer, default: Datadog.tracer
        option :enabled, default: true
        option :quantize, default: {}

        module_function

        def patch
          return patched? if patched? || !compatible?

          patch_rake

          # Set service info
          configuration[:tracer].set_service_info(
            configuration[:service_name],
            'rake',
            Ext::AppTypes::WORKER
          )

          @patched = true
        end

        def patched?
          return @patched if defined?(@patched)
          @patched = false
        end

        def patch_rake
          ::Rake::Task.send(:include, Instrumentation)
        end

        def compatible?
          RUBY_VERSION >= '2.0.0' && defined?(::Rake)
        end

        def configuration
          Datadog.configuration[:rake]
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ddtrace-0.16.1 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.15.0.internaltracinfeature1 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.16.0 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.14.2.disableprotocolversion4 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.15.0 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.14.2.withoutpriorityparsing1 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.14.2 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.14.1 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.15.0.beta1 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.14.0 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.14.0.rc1 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.13.2 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.14.0.beta2 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.14.0.beta1 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.13.1 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.13.0 lib/ddtrace/contrib/rake/patcher.rb
ddtrace-0.13.0.beta1 lib/ddtrace/contrib/rake/patcher.rb