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

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

Issue 2573343002: Roll infra_libs and its dependencies to 066f135 (Closed)
Patch Set: Created 4 years 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 credentials_json = json.load(credentials_file) 77 credentials_json = json.load(credentials_file)
78 if credentials_json.get('type', None): 78 if credentials_json.get('type', None):
79 credentials = GoogleCredentials.from_stream(credentials_file_path) 79 credentials = GoogleCredentials.from_stream(credentials_file_path)
80 credentials = credentials.create_scoped(self._SCOPES) 80 credentials = credentials.create_scoped(self._SCOPES)
81 return credentials 81 return credentials
82 return Storage(credentials_file_path).get() 82 return Storage(credentials_file_path).get()
83 83
84 def send(self, metric_pb): 84 def send(self, metric_pb):
85 raise NotImplementedError() 85 raise NotImplementedError()
86 86
87
87 class HttpsMonitor(Monitor): 88 class HttpsMonitor(Monitor):
88 89
89 _SCOPES = [ 90 _SCOPES = [
90 'https://www.googleapis.com/auth/prodxmon' 91 'https://www.googleapis.com/auth/prodxmon'
91 ] 92 ]
92 93
93 def __init__(self, endpoint, credentials_file_path, http=None): 94 def __init__(self, endpoint, credentials_file_path, http=None):
94 self._endpoint = endpoint 95 self._endpoint = endpoint
95 credentials = self._load_credentials(credentials_file_path) 96 credentials = self._load_credentials(credentials_file_path)
96 if http is None: 97 if http is None:
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 logging.info('Flushing monitoring metrics:\n%s', text) 235 logging.info('Flushing monitoring metrics:\n%s', text)
235 if self._fh is not None: 236 if self._fh is not None:
236 self._fh.write(text + '\n\n') 237 self._fh.write(text + '\n\n')
237 self._fh.flush() 238 self._fh.flush()
238 239
239 240
240 class NullMonitor(Monitor): 241 class NullMonitor(Monitor):
241 """Class that doesn't send metrics anywhere.""" 242 """Class that doesn't send metrics anywhere."""
242 def send(self, metric_pb): 243 def send(self, metric_pb):
243 pass 244 pass
OLDNEW
« no previous file with comments | « client/third_party/infra_libs/ts_mon/common/metrics.py ('k') | client/third_party/infra_libs/ts_mon/common/pb_to_popo.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698