def setUp(self) -> None:
     set_logger_level("DEBUG")
     logger_enable_console()
     starttime = str(int(time.time() * 1000))
     self.agent_meta = [('agentid', 'test-id'),
                        ('applicationname', 'test-name'),
                        ('starttime', starttime)]
    def __init__(self, config):
        '''

        :param ConfigParser config:
        '''

        self.CollectorSpanIp = ''
        self.CollectorSpanPort = ''
        self.CollectorStatIp = ''
        self.CollectorStatPort = ''
        self.CollectorAgentIp = ''
        self.CollectorAgentPort = ''
        self.max_pending_size = ''
        self.collector_type = -1

        self.collector_implement = None
        self.startTimestamp = int(time.time() * 1000)
        self.config = config
        if config.has_option('Collector', 'collector.grpc.agent.ip') and \
                config.has_option('Collector', 'collector.grpc.stat.ip') and \
                config.has_option('Collector', 'collector.grpc.span.ip'):
            self.CollectorSpanIp = config.get('Collector',
                                              'collector.grpc.span.ip')
            self.CollectorSpanPort = config.getint('Collector',
                                                   'collector.grpc.span.port')
            self.CollectorStatIp = config.get('Collector',
                                              'collector.grpc.stat.ip')
            self.CollectorStatPort = config.getint('Collector',
                                                   'collector.grpc.stat.port')
            self.CollectorAgentIp = config.get('Collector',
                                               'collector.grpc.agent.ip')
            self.CollectorAgentPort = config.getint(
                'Collector', 'collector.grpc.agent.port')
            self.max_pending_size = config.getint(
                'Collector',
                'collector.grpc.discardpolicy.maxpendingthreshold',
                fallback=10000)
            self.collector_type = SUPPORT_GRPC
            self.collector_implement = GrpcAgentImplement
        else:
            self.CollectorSpanIp = config.get('Collector', 'CollectorSpanIp')
            self.CollectorSpanPort = config.getint('Collector',
                                                   'CollectorSpanPort')
            self.CollectorStatIp = config.get('Collector', 'CollectorStatIp')
            self.CollectorStatPort = config.getint('Collector',
                                                   'CollectorStatPort')
            self.CollectorAgentIp = config.get('Collector', 'CollectorTcpIp')
            self.CollectorAgentPort = config.getint('Collector',
                                                    'CollectorTcpPort')
            self.collector_type = SUPPORT_THRIFT
            self.collector_implement = ThriftAgentImplement

        self.version = AGENT_VERSION

        log_dir = config.get('Common', 'LOG_DIR', fallback=None)
        log_level = config.get('Common', 'Log_Level', fallback='DEBUG')
        if log_dir is not None:
            set_logger_file(log_dir)
        else:
            logger_enable_console()
        set_logger_level(log_level)
 def _setLog(self, dir, level):
     if dir is not None:
         set_logger_file(dir)
     else:
         logger_enable_console()
     set_logger_level(level)