def load_plugins(config, plugin_kwargs):
installed_plugins = _gather_installed_plugins()<EOL>metrics_plugin = _get_metrics_plugin(config, installed_plugins)<EOL>if metrics_plugin:<EOL><INDENT>plugin_kwargs['<STR_LIT>'] = metrics_plugin<EOL><DEDENT>active_plugins = _get_activated_plugins(config, installed_plugins)<EOL>if not active_plugins:<EOL><INDENT>return [], [], [], None<EOL><DEDENT>plugin_namespaces = _get_plugin_config_keys(active_plugins)<EOL>plugin_configs = _load_plugin_configs(plugin_namespaces, config)<EOL>plugin_names, plugins, errors = _init_plugins(<EOL>active_plugins, installed_plugins, plugin_configs, plugin_kwargs)<EOL>return plugin_names, plugins, errors, plugin_kwargs<EOL>
Discover and instantiate plugins.

Args:
    config (dict): loaded configuration for the Gordon service.
    plugin_kwargs (dict): keyword arguments to give to plugins
        during instantiation.
Returns:
    Tuple of 3 lists: list of names of plugins, list of
    instantiated plugin objects, and any errors encountered while
    loading/instantiating plugins. A tuple of three empty lists is
    returned if there are no plugins found or activated in gordon
    config.