Sha256: 61974571a28eecc6725b9ada143b5737f2d8f3eea8dd4c26ec36e679dbd5091d

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

# encoding: utf-8

module OneApm
  module Configuration
    module Autostart
      extend self

      def agent_should_start?
          !blacklisted_constants? &&
          !blacklisted_executables? &&
          !in_blacklisted_rake_task?
      end

      def blacklisted_constants?
        blacklisted?(OneApm::Agent.config[:'autostart.blacklisted_constants']) do |name|
          OneApm::LanguageSupport.constant_is_defined?(name)
        end
      end

      def blacklisted_executables?
        blacklisted?(OneApm::Agent.config[:'autostart.blacklisted_executables']) do |bin|
          File.basename($0) == bin
        end
      end

      def blacklisted?(value, &block)
        value.split(/\s*,\s*/).any?(&block)
      end

      def in_blacklisted_rake_task?
        tasks = begin
                  ::Rake.application.top_level_tasks
                rescue => e
                  ::OneApm::Agent.logger.debug("Not in Rake environment so skipping blacklisted_rake_tasks check: #{e}")
                  []
                end
        !(tasks & ::OneApm::Agent.config[:'autostart.blacklisted_rake_tasks'].split(/\s*,\s*/)).empty?
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
oneapm_rpm-1.1.2 lib/one_apm/configuration/autostart.rb
oneapm_rpm-1.1.1 lib/one_apm/configuration/autostart.rb
oneapm_rpm-1.1.0 lib/one_apm/configuration/autostart.rb