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

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

Issue 2465423002: Roll infra_libs to 564aaf7480f24c90687df79d9cef910cc342a54d (Closed)
Patch Set: update readmes Created 4 years, 1 month 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 6
7 from google.protobuf.message import DecodeError 7 from google.protobuf.message import DecodeError
8 from infra_libs.event_mon.protos.chrome_infra_log_pb2 import ( 8 from infra_libs.event_mon.protos.chrome_infra_log_pb2 import (
9 ChromeInfraEvent, ServiceEvent, BuildEvent) 9 ChromeInfraEvent, ServiceEvent, BuildEvent)
10 from infra_libs.event_mon.protos.goma_stats_pb2 import GomaStats 10 from infra_libs.event_mon.protos.goma_stats_pb2 import GomaStats
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 176
177 for version_d in code_version: 177 for version_d in code_version:
178 try: 178 try:
179 if 'source_url' not in version_d: 179 if 'source_url' not in version_d:
180 logging.error('source_url missing in %s', version_d) 180 logging.error('source_url missing in %s', version_d)
181 continue 181 continue
182 182
183 version = event.service_event.code_version.add() 183 version = event.service_event.code_version.add()
184 version.source_url = version_d['source_url'] 184 version.source_url = version_d['source_url']
185 if 'revision' in version_d: 185 if 'revision' in version_d:
186 # Rely on the url to switch between svn and git because an
187 # abbreviated sha1 can sometimes be confused with an int.
188 if version.source_url.startswith('svn://'):
189 version.svn_revision = int(version_d['revision'])
190 else:
191 version.git_hash = version_d['revision'] 186 version.git_hash = version_d['revision']
192 187
193 if 'version' in version_d: 188 if 'version' in version_d:
194 version.version = version_d['version'] 189 version.version = version_d['version']
195 if 'dirty' in version_d: 190 if 'dirty' in version_d:
196 version.dirty = version_d['dirty'] 191 version.dirty = version_d['dirty']
197 192
198 except TypeError: 193 except TypeError:
199 logging.exception('Invalid type provided to code_version argument in ' 194 logging.exception('Invalid type provided to code_version argument in '
200 '_get_service_event. Please fix the calling code.') 195 '_get_service_event. Please fix the calling code.')
(...skipping 25 matching lines...) Expand all
226 221
227 Keyword Args: 222 Keyword Args:
228 timestamp_kind (string): any of ('POINT', 'BEGIN', 'END'). 223 timestamp_kind (string): any of ('POINT', 'BEGIN', 'END').
229 224
230 event_timestamp (int or float): timestamp of when the event happened 225 event_timestamp (int or float): timestamp of when the event happened
231 as a number of milliseconds since the epoch. If not provided, the 226 as a number of milliseconds since the epoch. If not provided, the
232 current time is used. 227 current time is used.
233 228
234 code_version (list/tuple of dict or None): required keys are 229 code_version (list/tuple of dict or None): required keys are
235 'source_url' -> full url to the repository 230 'source_url' -> full url to the repository
236 'revision' -> (string) git sha1 or svn revision number. 231 'revision' -> (string) git sha1
237 optional keys are 232 optional keys are
238 'dirty' -> boolean. True if the local source tree has local 233 'dirty' -> boolean. True if the local source tree has local
239 modification. 234 modification.
240 'version' -> manually-set version number (like 'v2.6.0') 235 'version' -> manually-set version number (like 'v2.6.0')
241 236
242 stack_trace (str): when event_type is 'CRASH', stack trace of the crash 237 stack_trace (str): when event_type is 'CRASH', stack trace of the crash
243 as a string. String is truncated to 1000 characters (the last ones 238 as a string. String is truncated to 1000 characters (the last ones
244 are kept). Use traceback.format_exc() to get the stack trace from an 239 are kept). Use traceback.format_exc() to get the stack trace from an
245 exception handler. 240 exception handler.
246 241
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 344
350 if category: 345 if category:
351 event.build_event.category = { 346 event.build_event.category = {
352 'cq': BuildEvent.CATEGORY_CQ, 347 'cq': BuildEvent.CATEGORY_CQ,
353 'cq_experimental': BuildEvent.CATEGORY_CQ_EXPERIMENTAL, 348 'cq_experimental': BuildEvent.CATEGORY_CQ_EXPERIMENTAL,
354 'git_cl_try': BuildEvent.CATEGORY_GIT_CL_TRY, 349 'git_cl_try': BuildEvent.CATEGORY_GIT_CL_TRY,
355 }.get(category.lower(), BuildEvent.CATEGORY_UNKNOWN) 350 }.get(category.lower(), BuildEvent.CATEGORY_UNKNOWN)
356 351
357 if head_revision_git_hash: 352 if head_revision_git_hash:
358 event.build_event.head_revision.git_hash = head_revision_git_hash 353 event.build_event.head_revision.git_hash = head_revision_git_hash
359
360 354
361 if event.build_event.step_name: 355 if event.build_event.step_name:
362 if event_type != 'STEP': 356 if event_type != 'STEP':
363 logging.error('step_name should be provided only for type "STEP", ' 357 logging.error('step_name should be provided only for type "STEP", '
364 'got %s', event_type) 358 'got %s', event_type)
365 if not event.build_event.HasField('step_number'): 359 if not event.build_event.HasField('step_number'):
366 logging.error('step_number was not provided, but got a value for ' 360 logging.error('step_number was not provided, but got a value for '
367 'step_name (%s). Provide either both or none', 361 'step_name (%s). Provide either both or none',
368 step_name) 362 step_name)
369 if (not event.build_event.HasField('build_number') 363 if (not event.build_event.HasField('build_number')
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 def send_events(events): 507 def send_events(events):
514 """Send several events at once to the endpoint. 508 """Send several events at once to the endpoint.
515 509
516 Args: 510 Args:
517 events (iterable of Event): events to send 511 events (iterable of Event): events to send
518 512
519 Return: 513 Return:
520 success (bool): True if data was successfully received by the endpoint. 514 success (bool): True if data was successfully received by the endpoint.
521 """ 515 """
522 return config._router.push_event(tuple(e.log_event() for e in events)) 516 return config._router.push_event(tuple(e.log_event() for e in events))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698