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

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

Issue 2673613003: luci-py: Roll infra_libs. (Closed)
Patch Set: rolll Created 3 years, 10 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
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 def send(self, metric_pb): 84 def send(self, metric_pb):
85 raise NotImplementedError() 85 raise NotImplementedError()
86 86
87 87
88 class HttpsMonitor(Monitor): 88 class HttpsMonitor(Monitor):
89 89
90 _SCOPES = [ 90 _SCOPES = [
91 'https://www.googleapis.com/auth/prodxmon' 91 'https://www.googleapis.com/auth/prodxmon'
92 ] 92 ]
93 93
94 def __init__(self, endpoint, credentials_file_path, http=None): 94 def __init__(self, endpoint, credentials_file_path, http=None, ca_certs=None):
95 self._endpoint = endpoint 95 self._endpoint = endpoint
96 credentials = self._load_credentials(credentials_file_path) 96 credentials = self._load_credentials(credentials_file_path)
97 if http is None: 97 if http is None:
98 http = httplib2_utils.RetriableHttp( 98 http = httplib2_utils.RetriableHttp(
99 httplib2_utils.InstrumentedHttp('acq-mon-api')) 99 httplib2_utils.InstrumentedHttp('acq-mon-api', ca_certs=ca_certs))
100 self._http = credentials.authorize(http) 100 self._http = credentials.authorize(http)
101 101
102 def encodeToJson(self, metric_pb): 102 def encodeToJson(self, metric_pb):
103 if interface.state.use_new_proto: 103 if interface.state.use_new_proto:
104 return json.dumps({'payload': pb_to_popo.convert(metric_pb)}) 104 return json.dumps({'payload': pb_to_popo.convert(metric_pb)})
105 else: 105 else:
106 return json.dumps({'resource': pb_to_popo.convert(metric_pb)}) 106 return json.dumps({'resource': pb_to_popo.convert(metric_pb)})
107 107
108 def send(self, metric_pb): 108 def send(self, metric_pb):
109 if interface.state.use_new_proto: 109 if interface.state.use_new_proto:
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 logging.info('Flushing monitoring metrics:\n%s', text) 235 logging.info('Flushing monitoring metrics:\n%s', text)
236 if self._fh is not None: 236 if self._fh is not None:
237 self._fh.write(text + '\n\n') 237 self._fh.write(text + '\n\n')
238 self._fh.flush() 238 self._fh.flush()
239 239
240 240
241 class NullMonitor(Monitor): 241 class NullMonitor(Monitor):
242 """Class that doesn't send metrics anywhere.""" 242 """Class that doesn't send metrics anywhere."""
243 def send(self, metric_pb): 243 def send(self, metric_pb):
244 pass 244 pass
OLDNEW
« no previous file with comments | « client/third_party/infra_libs/ts_mon/common/interface.py ('k') | client/third_party/infra_libs/ts_mon/config.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698