Sha256: 1c77f076d2f6194c95e1f2a3f76d10ff5dc27720886ff6688db88543e6ed456c

Contents?: true

Size: 918 Bytes

Versions: 1

Compression:

Stored size: 918 Bytes

Contents

# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

module OpenTelemetry
  module Instrumentation
    module Rake
      # The Instrumentation class contains logic to detect and install the Rake instrumentation
      class Instrumentation < OpenTelemetry::Instrumentation::Base
        MINIMUM_VERSION = Gem::Version.new('0.9.0')

        install do |_config|
          require_dependencies
          patch_rake
        end

        present do
          defined?(::Rake::Task)
        end

        compatible do
          gem_version >= MINIMUM_VERSION
        end

        private

        def gem_version
          Gem::Version.new(::Rake::VERSION)
        end

        def require_dependencies
          require_relative 'patches/task'
        end

        def patch_rake
          ::Rake::Task.prepend(Patches::Task)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-rake-0.2.2 lib/opentelemetry/instrumentation/rake/instrumentation.rb