Sha256: dbe21dcc9f11dc1835f0fd43d0ac9cbd91416f5cc0c7de5cccbf5da4abf17860

Contents?: true

Size: 1.2 KB

Versions: 25

Compression:

Stored size: 1.2 KB

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
  .select do |f|
  # :nocov:
  if ENV['INSTANA_ACTIVATE_SET']
    base = File.basename(f, '.rb')
    ENV.fetch('INSTANA_ACTIVATE_SET', '').split(',').include?(base)
  else
    true
  end
  # :nocov:
end
  .each { |f| require(f) }

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
instana-1.210.1 lib/instana/activator.rb
instana-1.210.0 lib/instana/activator.rb
instana-1.209.8 lib/instana/activator.rb
instana-1.209.7 lib/instana/activator.rb
instana-1.209.6 lib/instana/activator.rb
instana-1.209.5 lib/instana/activator.rb
instana-1.209.4 lib/instana/activator.rb
instana-1.209.3 lib/instana/activator.rb
instana-1.209.2 lib/instana/activator.rb
instana-1.209.1 lib/instana/activator.rb
instana-1.209.0.pre3 lib/instana/activator.rb
instana-1.209.0.pre2 lib/instana/activator.rb
instana-1.209.0.pre1 lib/instana/activator.rb
instana-1.208.0 lib/instana/activator.rb
instana-1.207.0 lib/instana/activator.rb
instana-1.206.0 lib/instana/activator.rb
instana-1.205.0 lib/instana/activator.rb
instana-1.204.0 lib/instana/activator.rb
instana-1.204.0.pre3 lib/instana/activator.rb
instana-1.204.0.pre2 lib/instana/activator.rb