def _SendStatistics(self):
    try:
      stat = self.handler_cls.GetStatistics()
      body = stat.SerializeToString()
      headers = {"Content-Length": len(body)}
      res = self.pool.urlopen("POST", "/server/state", headers=headers,
                              body=body)
      if res.status == constants.RESPONSE_SERVER_NOT_REGISTERED:
        # The connection has probably been dropped and we need to register
        # again.
        self.Register()
        return True
      if res.status != constants.RESPONSE_OK:
        logging.warning("Could not send statistics to data master.")
        return False
      # Also receive the new mapping with new statistics.
      mapping = rdf_data_server.DataServerMapping(res.data)
      self.handler_cls.SERVICE.SaveServerMapping(mapping)
      return True
    except (urllib3.exceptions.MaxRetryError, errors.DataServerError):
      logging.warning("Could not send statistics to data master.")
      return False
Send statistics to server.
dataset/ETHPy150Open google/grr/grr/server/data_server/data_server.py/StandardDataServer._SendStatistics