Beispiel #1
0
def install():
    disable_patterns = config.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)

        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(getattr(plugin, 'install')):
            logger.warning('no `install` method in plugin %s, thus the plugin won\'t be installed', modname)
            continue

        # noinspection PyBroadException
        try:
            plugin.install()
        except Exception:
            logger.warning('failed to install plugin %s', modname)
            traceback.print_exc() if logger.isEnabledFor(logging.DEBUG) else None
Beispiel #2
0
def __fork_before():
    if config.protocol != 'http':
        logger.warning('fork() not currently supported with %s protocol' %
                       config.protocol)

    # TODO: handle __queue and __finished correctly (locks, mutexes, etc...), need to lock before fork and unlock after
    # if possible, or ensure they are not locked in threads (end threads and restart after fork?)

    __protocol.fork_before()
    def add_profile_task(self, task: ProfileTask):
        # update last command create time, which will be used in command query
        if task.create_time > self.__last_command_create_time:
            self.__last_command_create_time = task.create_time

        # check profile task object
        result = self.__check_profile_task(task)
        if not result.success:
            logger.warning(
                "check command error, cannot process this profile task. reason: %s",
                result.error_reason)
            return

        # add task to list
        self.__profile_task_list.put(task)
    def receive_command(self, commands: Commands):
        for command in commands.commands:
            try:
                base_command = CommandDeserializer.deserialize(command)
                logger.debug("Received command [{%s} {%s}]", base_command.command, base_command.serial_number)

                if self.__is_command_executed(base_command):
                    logger.warning("Command[{%s}] is executed, ignored.", base_command.command)
                    continue

                try:
                    self.__commands.put(base_command)
                except queue.Full:
                    logger.warning("Command[{%s}, {%s}] cannot add to command list. because the command list is full.",
                                   base_command.command, base_command.serial_number)
            except UnsupportedCommandException as e:
                logger.warning("Received unsupported command[{%s}].", e.command.command)
Beispiel #5
0
def archive(segment: 'Segment'):
    try:  # unlike checking __queue.full() then inserting, this is atomic
        __queue.put(segment, block=False)
    except Full:
        logger.warning('the queue is full, the segment will be abandoned')
Beispiel #6
0
def archive(segment: 'Segment'):
    if __queue.full():
        logger.warning('the queue is full, the segment will be abandoned')
        return

    __queue.put(segment)