Esempio n. 1
0
  def main(self, opts):  # pragma: no cover
    status = 0

    try:
      if opts.build_event_type:
        success_metric.set(common.send_build_event(opts))

      elif opts.service_event_type:
        success_metric.set(common.send_service_event(opts))

      elif opts.events_from_file:
        success_metric.set(common.send_events_from_file(opts))

      else:
        print >> sys.stderr, ('At least one of the --*-event-type options or '
                              '--events-from-file should be provided. Nothing '
                              'was sent.')
        status = 2
        success_metric.set(False)
    except Exception:
      success_metric.set(False)
      traceback.print_exc()  # helps with debugging locally.
    finally:
      event_mon.close()
      try:
        ts_mon.flush()
      except ts_mon.MonitoringNoConfiguredMonitorError:
        logging.error("Unable to flush ts_mon because it's not configured.")
      except Exception:
        logging.exception("Flushing ts_mon metrics failed.")
    return status
Esempio n. 2
0
 def setUp(self):
   super(EventMonUploaderTest, self).setUp()
   tmp_handle, self.event_mon_file = tempfile.mkstemp()
   os.close(tmp_handle)
   event_mon.close()
   event_mon.setup_monitoring(
       run_type='file', hostname='test_host', output_file=self.event_mon_file)
def main(argv):
    parser = argparse.ArgumentParser()
    parser.add_argument('--master-name', help='Buildbot master name')
    parser.add_argument('--builder-name', help='Buildbot builder name')
    parser.add_argument('--build-id', help='Build ID (buildnumber)')
    parser.add_argument('--analyze-input',
                        help='JSON input passed to analyze',
                        type=argparse.FileType('r'))
    parser.add_argument('--analyze-output',
                        help='JSON output from analyze',
                        type=argparse.FileType('r'))
    event_mon.add_argparse_options(parser)
    args = parser.parse_args(argv)
    event_mon.process_argparse_options(args)

    try:
        return inner_main(args)
    finally:
        event_mon.close()
Esempio n. 4
0
def main(argv):  # pragma: no cover
    # Does nothing when no arguments are passed, to make it safe to import this
    # module (main() is executed on import, because this file is called __main__).
    status = 0

    if len(argv) == 0:
        return status

    success_metric = ts_mon.BooleanMetric('send_monitoring_event/success')

    try:
        args = send_event.get_arguments(argv)

        send_event.process_argparse_options(args)

        if args.build_event_type:
            success_metric.set(send_event.send_build_event(args))

        elif args.service_event_type:
            success_metric.set(send_event.send_service_event(args))

        elif args.events_from_file:
            success_metric.set(send_event.send_events_from_file(args))

        else:
            print >> sys.stderr, (
                'At least one of the --*-event-type options or '
                '--events-from-file should be provided. Nothing '
                'was sent.')
            status = 2
            success_metric.set(False)
    except Exception:
        success_metric.set(False)
    finally:
        event_mon.close()
        try:
            ts_mon.flush()
        except ts_mon.MonitoringNoConfiguredMonitorError:
            pass
    return status
Esempio n. 5
0
def main(argv):  # pragma: no cover
  # Does nothing when no arguments are passed, to make it safe to import this
  # module (main() is executed on import, because this file is called __main__).
  status = 0

  if len(argv) == 0:
    return status

  try:
    args = send_event.get_arguments(argv)
    send_event.process_argparse_options(args)

    if args.build_event_type:
      success_metric.set(send_event.send_build_event(args))

    elif args.service_event_type:
      success_metric.set(send_event.send_service_event(args))

    elif args.events_from_file:
      success_metric.set(send_event.send_events_from_file(args))

    else:
      print >> sys.stderr, ('At least one of the --*-event-type options or '
                            '--events-from-file should be provided. Nothing '
                            'was sent.')
      status = 2
      success_metric.set(False)
  except Exception:
    success_metric.set(False)
    traceback.print_exc()  # helps with debugging locally.
  finally:
    event_mon.close()
    try:
      ts_mon.flush()
    except ts_mon.MonitoringNoConfiguredMonitorError:
      logging.error("Unable to flush ts_mon because it's not configured.")
    except Exception:
      logging.exception("Flushing ts_mon metrics failed.")
  return status
Esempio n. 6
0
def main(argv):  # pragma: no cover
  # Does nothing when no arguments are passed, to make it safe to import this
  # module (main() is executed on import, because this file is called __main__).
  status = 0

  if len(argv) == 0:
    return status

  success_metric = ts_mon.BooleanMetric('send_monitoring_event/success')

  try:
    args = send_event.get_arguments(argv)

    send_event.process_argparse_options(args)

    if args.build_event_type:
      success_metric.set(send_event.send_build_event(args))

    elif args.service_event_type:
      success_metric.set(send_event.send_service_event(args))

    elif args.events_from_file:
      success_metric.set(send_event.send_events_from_file(args))

    else:
      print >> sys.stderr, ('At least one of the --*-event-type options or '
                            '--events-from-file should be provided. Nothing '
                            'was sent.')
      status = 2
      success_metric.set(False)
  except Exception:
    success_metric.set(False)
  finally:
    event_mon.close()
    try:
      ts_mon.flush()
    except ts_mon.MonitoringNoConfiguredMonitorError:
      pass
  return status
Esempio n. 7
0
 def tearDown(self):
   event_mon.close()
Esempio n. 8
0
 def _close(self):
     self.assertTrue(event_mon.close())
     self.assertFalse(config._cache)
     # Test that calling it twice does not raise an exception.
     self.assertTrue(event_mon.close())
Esempio n. 9
0
 def _close(self):
   self.assertTrue(event_mon.close())
   self.assertFalse(config._cache)
   # Test that calling it twice does not raise an exception.
   self.assertTrue(event_mon.close())
Esempio n. 10
0
 def tearDown(self):
   event_mon.close()
   os.remove(self.event_mon_file)
   super(EventMonUploaderTest, self).tearDown()