Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: infra_libs/ts_mon/common/monitors.py

Issue 2127373005: Fix RetriableHttp (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fix RetriableHttp Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « infra_libs/test/httplib2_utils_test.py ('k') | infra_libs/ts_mon/common/test/monitors_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Classes representing the monitoring interface for tasks or devices.""" 5 """Classes representing the monitoring interface for tasks or devices."""
6 6
7 7
8 import base64 8 import base64
9 import httplib2 9 import httplib2
10 import json 10 import json
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 def encodeToJson(self, metric_pb): 97 def encodeToJson(self, metric_pb):
98 return json.dumps({ 'resource': pb_to_popo.convert(metric_pb) }) 98 return json.dumps({ 'resource': pb_to_popo.convert(metric_pb) })
99 99
100 def send(self, metric_pb): 100 def send(self, metric_pb):
101 body = self.encodeToJson(self._wrap_proto(metric_pb)) 101 body = self.encodeToJson(self._wrap_proto(metric_pb))
102 102
103 try: 103 try:
104 resp, content = self._http.request(self._endpoint, method='POST', 104 resp, content = self._http.request(self._endpoint, method='POST',
105 body=body) 105 body=body)
106 if resp.status != 200: 106 if resp.status != 200:
107 logging.warning('HttpsMonitor.send received status %d: %s', resp, 107 logging.warning('HttpsMonitor.send received status %d: %s', resp.status,
108 content) 108 content)
109 except (ValueError, errors.Error, 109 except (ValueError, errors.Error,
110 socket.timeout, socket.error, socket.herror, socket.gaierror, 110 socket.timeout, socket.error, socket.herror, socket.gaierror,
111 httplib2.HttpLib2Error): 111 httplib2.HttpLib2Error):
112 logging.warning('HttpsMonitor.send failed: %s\n', 112 logging.warning('HttpsMonitor.send failed: %s\n',
113 traceback.format_exc()) 113 traceback.format_exc())
114 114
115 115
116 class PubSubMonitor(Monitor): 116 class PubSubMonitor(Monitor):
117 """Class which publishes metrics to a Cloud Pub/Sub topic.""" 117 """Class which publishes metrics to a Cloud Pub/Sub topic."""
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 logging.info('Flushing monitoring metrics:\n%s', text) 220 logging.info('Flushing monitoring metrics:\n%s', text)
221 if self._fh is not None: 221 if self._fh is not None:
222 self._fh.write(text + '\n\n') 222 self._fh.write(text + '\n\n')
223 self._fh.flush() 223 self._fh.flush()
224 224
225 225
226 class NullMonitor(Monitor): 226 class NullMonitor(Monitor):
227 """Class that doesn't send metrics anywhere.""" 227 """Class that doesn't send metrics anywhere."""
228 def send(self, metric_pb): 228 def send(self, metric_pb):
229 pass 229 pass
OLDNEW
« no previous file with comments | « infra_libs/test/httplib2_utils_test.py ('k') | infra_libs/ts_mon/common/test/monitors_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698