def _report(self):
     logger.verbose('HealthService: report observations')
     try:
         restutil.http_post(self.endpoint, self.as_json, headers={'Content-Type': 'application/json'})
         logger.verbose('HealthService: Reported observations to {0}: {1}', self.endpoint, self.as_json)
     except HttpError as e:
         logger.warn("HealthService: could not report observations: {0}", ustr(e))
     finally:
         # these signals are not timestamped, so there is no value in persisting data
         del self.observations[:]
 def _report(self):
     logger.verbose('HealthService: report observations')
     try:
         restutil.http_post(self.endpoint, self.as_json, headers={'Content-Type': 'application/json'})
         logger.verbose('HealthService: Reported observations to {0}: {1}', self.endpoint, self.as_json)
     except HttpError as e:
         logger.warn("HealthService: could not report observations: {0}", ustr(e))
     finally:
         # report any failures via telemetry
         self._report_failures()
         # these signals are not timestamped, so there is no value in persisting data
         del self.observations[:]
Exemple #3
0
 def _post_data(self, url, data, headers=None):
     headers = _add_content_type(headers) 
     try:
         resp = restutil.http_post(url, json.dumps(data), headers=headers)
     except HttpError as e:
         raise ProtocolError(ustr(e))
     if resp.status != httpclient.CREATED:
         raise ProtocolError("{0} - POST: {1}".format(resp.status, url))
Exemple #4
0
 def _post_data(self, url, data, headers=None):
     headers = _add_content_type(headers)
     try:
         resp = restutil.http_post(url, json.dumps(data), headers=headers)
     except HttpError as e:
         raise ProtocolError(ustr(e))
     if resp.status != httpclient.CREATED:
         logger.warn("{0} for POST {1}".format(resp.status, url))