code: def _setup_stats(self):
          '''
          Sets up the stats collection
          '''
          self.stats_dict = {}
  
          redis_conn = redis.Redis(host=self.settings['REDIS_HOST'],
                                   port=self.settings['REDIS_PORT'],
                                   db=self.settings.get('REDIS_DB'))
  
          try:
              redis_conn.info()
              self.logger.debug("Connected to Redis in StatsCollector Setup")
              self.redis_conn = redis_conn
          except ConnectionError:
              self.logger.warn("Failed to connect to Redis in StatsCollector"
                               " Setup, no stats will be collected")
              return
  
          if self.settings['STATS_TOTAL']:
              self._setup_stats_total(redis_conn)
  
          if self.settings['STATS_PLUGINS']:
              self._setup_stats_plugins(redis_connf _setup_stats(self):
          '''
          Sets up the stats collection
          '''
          self.stats_dict = {}
  
          redis_conn = redis.Redis(host=self.settings['REDIS_HOST'],
                                   port=self.settings['REDIS_PORT'],
                                   db=self.settings.get('REDIS_DB'))
  
          try:
              redis_conn.info()
              self.logger.debug("Connected to Redis in StatsCollector Setup")
              self.redis_conn = redis_conn
          except ConnectionError:
              self.logger.warn("Failed to connect to Redis in StatsCollector"
                               " Setup, no stats will be collected")
              return
  
          if self.settings['STATS_TOTAL']:
              self._setup_stats_total(redis_conn)
  
          if self.settings['STATS_PLUGINS']:
              self._setup_stats_plugins(redis_conn)
docs: Sets up the stats collection