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

Side by Side Diff: client/third_party/infra_libs/event_mon/router.py

Issue 2991803002: Update infra_libs to 1.1.15 / 0b44aba87c1c6538439df6d24a409870810747ab (Closed)
Patch Set: fix Created 3 years, 4 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 import logging 5 import logging
6 import os 6 import os
7 import random 7 import random
8 import sys 8 import sys
9 import time 9 import time
10 10
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 HTTP_IDENTIFIER = 'event_mon' 195 HTTP_IDENTIFIER = 'event_mon'
196 _Router.__init__(self) 196 _Router.__init__(self)
197 self.endpoint = endpoint 197 self.endpoint = endpoint
198 self.try_num = try_num 198 self.try_num = try_num
199 self.retry_backoff = retry_backoff 199 self.retry_backoff = retry_backoff
200 self._cache = cache 200 self._cache = cache
201 self._http = infra_libs.InstrumentedHttp(HTTP_IDENTIFIER, timeout=timeout) 201 self._http = infra_libs.InstrumentedHttp(HTTP_IDENTIFIER, timeout=timeout)
202 self._dry_run = dry_run 202 self._dry_run = dry_run
203 self._sleep_fn = _sleep_fn 203 self._sleep_fn = _sleep_fn
204 204
205 # TODO(pgervais) pass this as parameters instead.
206 if self._cache.get('service_account_creds'):
207 try:
208 logging.debug('Activating OAuth2 authentication.')
209 self._http = infra_libs.get_authenticated_http(
210 self._cache['service_account_creds'],
211 service_accounts_creds_root=
212 self._cache['service_accounts_creds_root'],
213 scope='https://www.googleapis.com/auth/cclog',
214 http_identifier=HTTP_IDENTIFIER,
215 timeout=timeout
216 )
217 except IOError:
218 logging.error('Unable to read credentials, requests will be '
219 'unauthenticated. File: %s',
220 self._cache.get('service_account_creds'))
221
222 def _send_to_endpoint(self, events): 205 def _send_to_endpoint(self, events):
223 """Send protobuf to endpoint 206 """Send protobuf to endpoint
224 207
225 Args: 208 Args:
226 events(LogRequestLite): the protobuf to send. 209 events(LogRequestLite): the protobuf to send.
227 210
228 Returns: 211 Returns:
229 success(bool): whether POSTing/writing succeeded or not. 212 success(bool): whether POSTing/writing succeeded or not.
230 """ 213 """
231 if not self.endpoint.startswith('https://'): 214 if not self.endpoint.startswith('https://'):
(...skipping 30 matching lines...) Expand all
262 self.endpoint, response.status, attempt) 245 self.endpoint, response.status, attempt)
263 246
264 if attempt == 0: 247 if attempt == 0:
265 logging.error('data: %s', str(events)[:2000]) 248 logging.error('data: %s', str(events)[:2000])
266 249
267 self._sleep_fn(backoff_time(attempt, retry_backoff=self.retry_backoff)) 250 self._sleep_fn(backoff_time(attempt, retry_backoff=self.retry_backoff))
268 251
269 logging.error('failed to POST data after %d attempts, giving up.', 252 logging.error('failed to POST data after %d attempts, giving up.',
270 attempt+1) 253 attempt+1)
271 return False 254 return False
OLDNEW
« no previous file with comments | « client/third_party/infra_libs/event_mon/protos/goma_stats_pb2.py ('k') | client/third_party/infra_libs/httplib2_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698