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

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

Issue 1894593004: luci-py: roll infra_libs / gae_ts_mon to 4d74a66 (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@master
Patch Set: Created 4 years, 8 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 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 code_version=code_version, 254 code_version=code_version,
255 stack_trace=stack_trace).send() 255 stack_trace=stack_trace).send()
256 256
257 257
258 def get_build_event(event_type, 258 def get_build_event(event_type,
259 hostname, 259 hostname,
260 build_name, 260 build_name,
261 build_number=None, 261 build_number=None,
262 build_scheduling_time=None, 262 build_scheduling_time=None,
263 step_name=None, 263 step_name=None,
264 step_text=None,
264 step_number=None, 265 step_number=None,
265 result=None, 266 result=None,
266 extra_result_code=None, 267 extra_result_code=None,
267 timestamp_kind=None, 268 timestamp_kind=None,
268 event_timestamp=None, 269 event_timestamp=None,
269 service_name=None, 270 service_name=None,
270 goma_stats=None, 271 goma_stats=None,
271 goma_error=None, 272 goma_error=None,
272 goma_crash_report_id=None, 273 goma_crash_report_id=None,
273 patch_url=None): 274 patch_url=None):
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 event.build_event.build_number) 324 event.build_event.build_number)
324 else: # no 'build_number' field 325 else: # no 'build_number' field
325 if event.build_event.HasField('build_scheduling_time_ms'): 326 if event.build_event.HasField('build_scheduling_time_ms'):
326 logging.error('build_number has not been provided, ' 327 logging.error('build_number has not been provided, '
327 'build_scheduling_time was provided (%s). ' 328 'build_scheduling_time was provided (%s). '
328 'Both must be present or missing.', 329 'Both must be present or missing.',
329 event.build_event.build_scheduling_time_ms) 330 event.build_event.build_scheduling_time_ms)
330 331
331 if step_name: 332 if step_name:
332 event.build_event.step_name = step_name 333 event.build_event.step_name = step_name
334 if step_text:
335 event.build_event.step_text = step_text
333 if step_number is not None: 336 if step_number is not None:
334 event.build_event.step_number = step_number 337 event.build_event.step_number = step_number
335 if patch_url is not None: 338 if patch_url is not None:
336 event.build_event.patch_url = patch_url 339 event.build_event.patch_url = patch_url
337 340
338 if event.build_event.step_name: 341 if event.build_event.step_name:
339 if event_type != 'STEP': 342 if event_type != 'STEP':
340 logging.error('step_name should be provided only for type "STEP", ' 343 logging.error('step_name should be provided only for type "STEP", '
341 'got %s', event_type) 344 'got %s', event_type)
342 if not event.build_event.HasField('step_number'): 345 if not event.build_event.HasField('step_number'):
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 415
413 return event_wrapper 416 return event_wrapper
414 417
415 418
416 def send_build_event(event_type, 419 def send_build_event(event_type,
417 hostname, 420 hostname,
418 build_name, 421 build_name,
419 build_number=None, 422 build_number=None,
420 build_scheduling_time=None, 423 build_scheduling_time=None,
421 step_name=None, 424 step_name=None,
425 step_text=None,
422 step_number=None, 426 step_number=None,
423 result=None, 427 result=None,
424 extra_result_code=None, 428 extra_result_code=None,
425 timestamp_kind=None, 429 timestamp_kind=None,
426 event_timestamp=None, 430 event_timestamp=None,
427 goma_stats=None, 431 goma_stats=None,
428 goma_error=None, 432 goma_error=None,
429 goma_crash_report_id=None, 433 goma_crash_report_id=None,
430 patch_url=None): 434 patch_url=None):
431 """Send a ChromeInfraEvent filled with a BuildEvent 435 """Send a ChromeInfraEvent filled with a BuildEvent
432 436
433 Args: 437 Args:
434 event_type (string): any name of enum BuildEvent.BuildEventType. 438 event_type (string): any name of enum BuildEvent.BuildEventType.
435 (listed in infra_libs.event_mon.monitoring.BUILD_EVENT_TYPES) 439 (listed in infra_libs.event_mon.monitoring.BUILD_EVENT_TYPES)
436 hostname (string): fqdn of the machine that is running the build / step. 440 hostname (string): fqdn of the machine that is running the build / step.
437 aka the bot name. 441 aka the bot name.
438 build_name (string): name of the builder. 442 build_name (string): name of the builder.
439 443
440 Keyword args: 444 Keyword args:
441 build_number (int): as the name says. 445 build_number (int): as the name says.
442 build_scheduling_time (int): timestamp telling when the build was 446 build_scheduling_time (int): timestamp telling when the build was
443 scheduled. This is required when build_number is provided to make it 447 scheduled. This is required when build_number is provided to make it
444 possibly to distinguish two builds with the same build number. 448 possibly to distinguish two builds with the same build number.
445 step_name (str): name of the step. 449 step_name (str): name of the step.
450 step_text (str): text of the step.
446 step_number (int): rank of the step in the build. This is mandatory 451 step_number (int): rank of the step in the build. This is mandatory
447 if step_name is provided, because step_name is not enough to tell the 452 if step_name is provided, because step_name is not enough to tell the
448 order. 453 order.
449 result (string): any name of enum BuildEvent.BuildResult. 454 result (string): any name of enum BuildEvent.BuildResult.
450 (listed in infra_libs.event_mon.monitoring.BUILD_RESULTS) 455 (listed in infra_libs.event_mon.monitoring.BUILD_RESULTS)
451 extra_result_code (string or list of): arbitrary strings intended to provide 456 extra_result_code (string or list of): arbitrary strings intended to provide
452 more fine-grained information about the result. 457 more fine-grained information about the result.
453 goma_stats (goma_stats_pb2.GomaStats): statistics output by the Goma proxy. 458 goma_stats (goma_stats_pb2.GomaStats): statistics output by the Goma proxy.
454 goma_error (string): goma error type defined as GomaErrorType. 459 goma_error (string): goma error type defined as GomaErrorType.
455 goma_crash_report_id (string): id of goma crash report. 460 goma_crash_report_id (string): id of goma crash report.
456 patch_url (string): URL of the patch that triggered build 461 patch_url (string): URL of the patch that triggered build
457 462
458 Returns: 463 Returns:
459 success (bool): False if some error happened. 464 success (bool): False if some error happened.
460 """ 465 """
461 return get_build_event(event_type, 466 return get_build_event(event_type,
462 hostname, 467 hostname,
463 build_name, 468 build_name,
464 build_number=build_number, 469 build_number=build_number,
465 build_scheduling_time=build_scheduling_time, 470 build_scheduling_time=build_scheduling_time,
466 step_name=step_name, 471 step_name=step_name,
472 step_text=step_text,
467 step_number=step_number, 473 step_number=step_number,
468 result=result, 474 result=result,
469 extra_result_code=extra_result_code, 475 extra_result_code=extra_result_code,
470 timestamp_kind=timestamp_kind, 476 timestamp_kind=timestamp_kind,
471 event_timestamp=event_timestamp, 477 event_timestamp=event_timestamp,
472 goma_stats=goma_stats, 478 goma_stats=goma_stats,
473 goma_error=goma_error, 479 goma_error=goma_error,
474 goma_crash_report_id=goma_crash_report_id, 480 goma_crash_report_id=goma_crash_report_id,
475 patch_url=patch_url).send() 481 patch_url=patch_url).send()
476 482
477 483
478 def send_events(events): 484 def send_events(events):
479 """Send several events at once to the endpoint. 485 """Send several events at once to the endpoint.
480 486
481 Args: 487 Args:
482 events (iterable of Event): events to send 488 events (iterable of Event): events to send
483 489
484 Return: 490 Return:
485 success (bool): True if data was successfully received by the endpoint. 491 success (bool): True if data was successfully received by the endpoint.
486 """ 492 """
487 return config._router.push_event(tuple(e.log_event() for e in events)) 493 return config._router.push_event(tuple(e.log_event() for e in events))
OLDNEW
« no previous file with comments | « client/third_party/infra_libs/README.swarming ('k') | client/third_party/infra_libs/event_mon/protos/chrome_infra_log_pb2.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698