# File lib/new_relic/control/instance_methods.rb, line 50
      def init_plugin(options={})
        env = determine_env(options)

        configure_agent(env, options)

        # Be sure to only create once! RUBY-1020
        if ::NewRelic::Agent.logger.is_startup_logger?
          ::NewRelic::Agent.logger = NewRelic::Agent::AgentLogger.new(root, options.delete(:log))
        end

        # Merge the stringified options into the config as overrides:
        environment_name = options.delete(:env) and self.env = environment_name

        NewRelic::Agent::PipeChannelManager.listener.start if options.delete(:start_channel_listener)

        # An artifact of earlier implementation, we put both #add_method_tracer and #trace_execution
        # methods in the module methods.
        Module.send :include, NewRelic::Agent::MethodTracer::ClassMethods
        Module.send :include, NewRelic::Agent::MethodTracer
        init_config(options)
        NewRelic::Agent.agent = NewRelic::Agent::Agent.instance
        if Agent.config[:agent_enabled] && !NewRelic::Agent.instance.started?
          start_agent
          install_instrumentation
        elsif !Agent.config[:agent_enabled]
          install_shim
        else
          DependencyDetection.detect!
        end
      end