Sha256: 5c2737ab43ddc8aa610e01d88b329a0b5e4043a0af4301d82478e77391fba7ef

Contents?: true

Size: 1020 Bytes

Versions: 14

Compression:

Stored size: 1020 Bytes

Contents

# (c) Copyright IBM Corp. 2021
# (c) Copyright Instana Inc. 2021

module Instana
  class Activator
    class << self
      attr_reader :trace_point, :activators

      def start
        # :nocov:
        @trace_point = TracePoint.new(:end) do
          activated = ::Instana::Activator.call
          ::Instana.logger.debug { "Activated #{activated.join(', ')}" } unless activated.empty?
        end

        @trace_point.enable if enabled?
        # :nocov:
      end

      def call
        @activators ||= []
        activated, @activators = @activators.partition(&:call)
        activated
      end

      def inherited(subclass)
        super(subclass)

        @activators ||= []
        @activators << subclass.new
      end

      private

      def enabled?
        ENV.fetch('INSTANA_DISABLE_AUTO_INSTR', 'false').eql?('false') || !ENV.key?('INSTANA_DISABLE')
      end
    end

    def call
      instrument if can_instrument?
    end
  end
end

Dir["#{__dir__}/activators/*.rb"].sort.each { |f| require(f) }

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
instana-1.200.0 lib/instana/activator.rb
instana-1.200.0.pre1 lib/instana/activator.rb
instana-1.199.6 lib/instana/activator.rb
instana-1.199.5 lib/instana/activator.rb
instana-1.199.4 lib/instana/activator.rb
instana-1.199.3 lib/instana/activator.rb
instana-1.199.2 lib/instana/activator.rb
instana-1.199.1 lib/instana/activator.rb
instana-1.199.0 lib/instana/activator.rb
instana-1.198.0 lib/instana/activator.rb
instana-1.198.0.pre1 lib/instana/activator.rb
instana-1.197.0 lib/instana/activator.rb
instana-1.197.0.pre2 lib/instana/activator.rb
instana-1.197.0.pre1 lib/instana/activator.rb