in skywalking/plugins/__init__.py [0:0]
def install():
disable_patterns = config.agent_disable_plugins
if isinstance(disable_patterns, str):
disable_patterns = [re.compile(p.strip()) for p in disable_patterns.split(',') if p.strip()]
else:
disable_patterns = [re.compile(p.strip()) for p in disable_patterns if p.strip()]
for importer, modname, _ispkg in pkgutil.iter_modules(skywalking.plugins.__path__):
if any(pattern.match(modname) for pattern in disable_patterns):
logger.info("plugin %s is disabled and thus won't be installed", modname)
continue
logger.debug('installing plugin %s', modname)
plugin = importer.find_module(modname).load_module(modname)
# todo: refactor the version checker, currently it doesn't really work as intended
supported = pkg_version_check(plugin)
if not supported:
logger.debug("check version for plugin %s's corresponding package failed, thus "
"won't be installed", modname)
continue
if not hasattr(plugin, 'install') or inspect.ismethod(plugin.install):
logger.warning("no `install` method in plugin %s, thus the plugin won't be installed", modname)
continue
# noinspection PyBroadException
try:
plugin.install()
logger.debug('Successfully installed plugin %s', modname)
except Exception:
logger.warning(
'Plugin %s failed to install, please ignore this warning '
'if the package is not used in your application.',
modname
)
traceback.print_exc() if logger.isEnabledFor(logging.DEBUG) else None