Sha256: 4f1a4ab245e1748061f4cc83adc07e842e23f6ffdd99567657edd56dcec11659

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

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

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

        install do |_config|
          require_railtie
          require_dependencies
          patch
        end

        present do
          defined?(::ActionController)
        end

        compatible do
          gem_version >= MINIMUM_VERSION
        end

        option :enable_recognize_route, default: false, validate: :boolean

        private

        def gem_version
          Gem.loaded_specs['actionpack'].version
        end

        def patch
          ::ActionController::Metal.prepend(Patches::ActionController::Metal)
        end

        def require_dependencies
          require_relative 'patches/action_controller/metal'
        end

        def require_railtie
          require_relative 'railtie'
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-action_pack-0.1.3 lib/opentelemetry/instrumentation/action_pack/instrumentation.rb
opentelemetry-instrumentation-action_pack-0.1.2 lib/opentelemetry/instrumentation/action_pack/instrumentation.rb
opentelemetry-instrumentation-action_pack-0.1.1 lib/opentelemetry/instrumentation/action_pack/instrumentation.rb
opentelemetry-instrumentation-action_pack-0.1.0 lib/opentelemetry/instrumentation/action_pack/instrumentation.rb