Пример #1
0
  def testCreateNewOoid(self):
    ooid = oo.createNewOoid()
    ndate = oo.dateFromOoid(ooid)
    ndepth = oo.depthFromOoid(ooid)
    assert self.nowstamp == ndate, 'Expect date of %s, got %s' %(self.nowstamp,ndate)
    assert oo.defaultDepth == ndepth, 'Expect default depth (%d) got %d' % (oo.defaultDepth,ndepth)

    ooid = oo.createNewOoid(timestamp=self.xmas05)
    ndate = oo.dateFromOoid(ooid)
    ndepth = oo.depthFromOoid(ooid)
    assert self.xmas05 == ndate, 'Expect date of %s, got %s' %(self.xmas05,ndate)
    assert oo.defaultDepth == ndepth, 'Expect default depth (%d) got %d' % (oo.defaultDepth,ndepth)

    for d in range(1,5):
      ooid0 = oo.createNewOoid(depth=d)
      ooid1 = oo.createNewOoid(timestamp=self.xmas05,depth=d)
      ndate0 = oo.dateFromOoid(ooid0)
      ndepth0 = oo.depthFromOoid(ooid0)
      ndate1 = oo.dateFromOoid(ooid1)
      ndepth1 = oo.depthFromOoid(ooid1)
      assert self.nowstamp == ndate0, 'Expect date of %s, got %s' %(self.nowstamp,ndate0)
      assert self.xmas05 == ndate1, 'Expect date of %s, got %s' %(self.xmas05,ndate1)
      assert ndepth0 == ndepth1, 'Expect depth0(%d) == depth1(%d)' %(ndepth0,ndepth1)
      assert d == ndepth0, 'Expect depth %d, got %d' % (d,ndepth0)
    assert None == oo.depthFromOoid(self.badooid0)
    assert None == oo.depthFromOoid(self.badooid1)
Пример #2
0
  def testCreateNewOoid(self):
    ooid = oo.createNewOoid()
    ndate = oo.dateFromOoid(ooid)
    ndepth = oo.depthFromOoid(ooid)
    assert self.nowstamp == ndate, 'Expect date of %s, got %s' %(self.nowstamp,ndate)
    assert oo.defaultDepth == ndepth, 'Expect default depth (%d) got %d' % (oo.defaultDepth,ndepth)

    ooid = oo.createNewOoid(timestamp=self.xmas05)
    ndate = oo.dateFromOoid(ooid)
    ndepth = oo.depthFromOoid(ooid)
    assert self.xmas05 == ndate, 'Expect date of %s, got %s' %(self.xmas05,ndate)
    assert oo.defaultDepth == ndepth, 'Expect default depth (%d) got %d' % (oo.defaultDepth,ndepth)

    for d in range(1,5):
      ooid0 = oo.createNewOoid(depth=d)
      ooid1 = oo.createNewOoid(timestamp=self.xmas05,depth=d)
      ndate0 = oo.dateFromOoid(ooid0)
      ndepth0 = oo.depthFromOoid(ooid0)
      ndate1 = oo.dateFromOoid(ooid1)
      ndepth1 = oo.depthFromOoid(ooid1)
      assert self.nowstamp == ndate0, 'Expect date of %s, got %s' %(self.nowstamp,ndate0)
      assert self.xmas05 == ndate1, 'Expect date of %s, got %s' %(self.xmas05,ndate1)
      assert ndepth0 == ndepth1, 'Expect depth0(%d) == depth1(%d)' %(ndepth0,ndepth1)
      assert d == ndepth0, 'Expect depth %d, got %d' % (d,ndepth0)
    assert None == oo.depthFromOoid(self.badooid0)
    assert None == oo.depthFromOoid(self.badooid1)
Пример #3
0
  def POST(self, *args):
    crashStorage = self.context.crashStoragePool.crashStorage()
    theform = web.input()

    dump = theform[self.context.dumpField]

    # Remove other submitted files from the input form, which are an indication
    # of a multi-dump hang submission we aren't yet prepared to handle.
    for (key, value) in web.webapi.rawinput().iteritems():
      if hasattr(value, 'file') and hasattr(value, 'value'):
        del theform[key]

    currentTimestamp = utc_now()
    jsonDataDictionary = crashStorage.makeJsonDictFromForm(theform)
    jsonDataDictionary.submitted_timestamp = currentTimestamp.isoformat()
    #for future use when we start sunsetting products
    #if crashStorage.terminated(jsonDataDictionary):
      #return "Terminated=%s" % jsonDataDictionary.Version
    ooid = sooid.createNewOoid(currentTimestamp)
    jsonDataDictionary.legacy_processing = \
        self.legacyThrottler.throttle(jsonDataDictionary)
    self.logger.info('%s received', ooid)
    result = crashStorage.save_raw(ooid,
                                   jsonDataDictionary,
                                   dump,
                                   currentTimestamp)
    if result == cstore.CrashStorageSystem.DISCARDED:
      return "Discarded=1\n"
    elif result == cstore.CrashStorageSystem.ERROR:
      raise Exception("CrashStorageSystem ERROR")
    return "CrashID=%s%s\n" % (self.dumpIDPrefix, ooid)
Пример #4
0
    def POST(self, *args):
        raw_crash, dumps = \
            self._make_raw_crash_and_dumps(web.webapi.rawinput())

        current_timestamp = utc_now()
        raw_crash.submitted_timestamp = current_timestamp.isoformat()
        # legacy - ought to be removed someday
        raw_crash.timestamp = time.time()

        crash_id = createNewOoid(current_timestamp)
        self.logger.info('%s received', crash_id)

        raw_crash.legacy_processing, raw_crash.throttle_rate = (
            self.throttler.throttle(raw_crash)
        )
        if raw_crash.legacy_processing == DISCARD:
            self.logger.info('%s discarded', crash_id)
            return "Discarded=1\n"
        if raw_crash.legacy_processing == IGNORE:
            self.logger.info('%s ignored', crash_id)
            return "Unsupported=1\n"

        self.config.crash_storage.save_raw_crash(
          raw_crash,
          dumps,
          crash_id
        )
        self.logger.info('%s accepted', crash_id)
        return "CrashID=%s%s\n" % (self.dump_id_prefix, crash_id)
def handler(req):
  global persistentStorage
  try:
    x = persistentStorage
  except NameError:
    persistentStorage = socorro.collector.initializer.createPersistentInitialization(configModule)

  logger = persistentStorage["logger"]
  config = persistentStorage["config"]
  collectObject = persistentStorage["collectObject"]

  logger.debug("handler invoked using subinterpreter: %s", req.interpreter)

  if req.method == "POST":
    try:
      req.content_type = "text/plain"

      theform = util.FieldStorage(req)
      dump = theform[config.dumpField]
      if not dump.file:
        return apache.HTTP_BAD_REQUEST

      currentTimestamp = dt.datetime.now()

      jsonDataDictionary = collectObject.makeJsonDictFromForm(theform)
      jsonDataDictionary["submitted_timestamp"] = currentTimestamp.isoformat()
      try:
        throttleable = int(jsonDataDictionary["Throttleable"])
      except KeyError:
        throttleable = 2
      if not throttleable or (throttleable and not collectObject.throttle(jsonDataDictionary)):
        fileSystemStorage = persistentStorage["standardFileSystemStorage"]
      elif throttleable == 2:
        fileSystemStorage = persistentStorage["deferredFileSystemStorage"]
      else:
        req.write("Discarded=1\n")
        return apache.OK

      uuid = ooid.createNewOoid(currentTimestamp, persistentStorage["config"].storageDepth)

      jsonFileHandle, dumpFileHandle = fileSystemStorage.newEntry(uuid, persistentStorage["hostname"], dt.datetime.now())
      try:
        collectObject.storeDump(dump.file, dumpFileHandle)
        collectObject.storeJson(jsonDataDictionary, jsonFileHandle)
      finally:
        dumpFileHandle.close()
        jsonFileHandle.close()

      req.write("CrashID=%s%s\n" % (config.dumpIDPrefix, uuid))
      return apache.OK
    except:
      logger.info("mod-python subinterpreter name: %s", req.interpreter)
      sutil.reportExceptionAndContinue(logger)
      #print >>sys.stderr, "Exception: %s" % sys.exc_info()[0]
      #print >>sys.stderr, sys.exc_info()[1]
      #print >>sys.stderr
      #sys.stderr.flush()
      return apache.HTTP_INTERNAL_SERVER_ERROR
  else:
    return apache.HTTP_METHOD_NOT_ALLOWED
Пример #6
0
  def POST(self, *args):
    crashStorage = self.context.crashStoragePool.crashStorage()
    theform = web.input()

    dump = theform[self.context.dumpField]
    #currentTimestamp = dt.datetime.now(utctz)
    currentTimestamp = dt.datetime.now()
    jsonDataDictionary = crashStorage.makeJsonDictFromForm(theform)
    jsonDataDictionary.submitted_timestamp = currentTimestamp.isoformat()
    #for future use when we start sunsetting products
    #if crashStorage.terminated(jsonDataDictionary):
      #return "Terminated=%s" % jsonDataDictionary.Version
    ooid = sooid.createNewOoid(currentTimestamp)
    jsonDataDictionary.legacy_processing = \
        self.legacyThrottler.throttle(jsonDataDictionary)
    self.logger.info('%s received', ooid)
    result = crashStorage.save_raw(ooid,
                                   jsonDataDictionary,
                                   dump,
                                   currentTimestamp)
    if result == cstore.CrashStorageSystem.DISCARDED:
      return "Discarded=1\n"
    elif result == cstore.CrashStorageSystem.ERROR:
      raise Exception("CrashStorageSystem ERROR")
    return "CrashID=%s%s\n" % (self.dumpIDPrefix, ooid)
Пример #7
0
    def POST(self, *args):
        raw_crash, dumps = self._get_raw_crash_from_form()

        current_timestamp = utc_now()
        raw_crash.submitted_timestamp = current_timestamp.isoformat()
        # legacy - ought to be removed someday
        raw_crash.timestamp = time.time()

        if (not self.config.accept_submitted_crash_id
            or 'crash_id' not in raw_crash
        ):
            crash_id = createNewOoid(current_timestamp)
            raw_crash.crash_id = crash_id
            self.logger.info('%s received', crash_id)
        else:
            crash_id = raw_crash.crash_id
            self.logger.info('%s received with existing crash_id:', crash_id)

        raw_crash.type_tag = self.type_tag

        self.crash_storage.save_raw_crash(
            raw_crash,
            dumps,
            crash_id
        )
        self.logger.info('%s accepted', crash_id)
        return "CrashID=%s%s\n" % (self.type_tag, crash_id)
Пример #8
0
    def POST(self, *args):
        crashStorage = self.context.crashStoragePool.crashStorage()
        theform = web.input()

        dump = theform[self.context.dumpField]

        # Remove other submitted files from the input form, which are an indication
        # of a multi-dump hang submission we aren't yet prepared to handle.
        for (key, value) in web.webapi.rawinput().iteritems():
            if hasattr(value, 'file') and hasattr(value, 'value'):
                del theform[key]

        currentTimestamp = utc_now()
        jsonDataDictionary = crashStorage.makeJsonDictFromForm(theform)
        jsonDataDictionary.submitted_timestamp = currentTimestamp.isoformat()
        #for future use when we start sunsetting products
        #if crashStorage.terminated(jsonDataDictionary):
        #return "Terminated=%s" % jsonDataDictionary.Version
        ooid = sooid.createNewOoid(currentTimestamp)
        jsonDataDictionary.legacy_processing = \
            self.legacyThrottler.throttle(jsonDataDictionary)
        self.logger.info('%s received', ooid)
        result = crashStorage.save_raw(ooid, jsonDataDictionary, dump,
                                       currentTimestamp)
        if result == cstore.CrashStorageSystem.DISCARDED:
            return "Discarded=1\n"
        elif result == cstore.CrashStorageSystem.ERROR:
            raise Exception("CrashStorageSystem ERROR")
        return "CrashID=%s%s\n" % (self.dumpIDPrefix, ooid)
Пример #9
0
    def POST(self, *args):
        raw_crash, dumps = self._get_raw_crash_from_form()

        current_timestamp = utc_now()
        raw_crash.submitted_timestamp = current_timestamp.isoformat()
        # legacy - ought to be removed someday
        raw_crash.timestamp = time.time()

        if (not self.config.collector.accept_submitted_crash_id
                or 'uuid' not in raw_crash):
            crash_id = createNewOoid(current_timestamp)
            raw_crash.uuid = crash_id
            self.logger.info('%s received', crash_id)
        else:
            crash_id = raw_crash.uuid
            self.logger.info('%s received with existing crash_id:', crash_id)

        if ('legacy_processing' not in raw_crash or
                not self.config.collector.accept_submitted_legacy_processing):
            raw_crash.legacy_processing, raw_crash.throttle_rate = (
                self.throttler.throttle(raw_crash))
        else:
            raw_crash.legacy_processing = int(raw_crash.legacy_processing)

        if raw_crash.legacy_processing == DISCARD:
            self.logger.info('%s discarded', crash_id)
            return "Discarded=1\n"
        if raw_crash.legacy_processing == IGNORE:
            self.logger.info('%s ignored', crash_id)
            return "Unsupported=1\n"

        self.config.crash_storage.save_raw_crash(raw_crash, dumps, crash_id)
        self.logger.info('%s accepted', crash_id)
        return "CrashID=%s%s\n" % (self.dump_id_prefix, crash_id)
Пример #10
0
    def POST(self, *args):
        raw_crash, dumps = \
            self._make_raw_crash_and_dumps(web.webapi.rawinput())

        current_timestamp = utc_now()
        raw_crash.submitted_timestamp = current_timestamp.isoformat()
        # legacy - ought to be removed someday
        raw_crash.timestamp = time.time()

        crash_id = createNewOoid(current_timestamp)

        raw_crash.legacy_processing = self.legacy_throttler.throttle(raw_crash)
        if raw_crash.legacy_processing == LegacyThrottler.DISCARD:
            self.logger.info('%s discarded', crash_id)
            return "Discarded=1\n"
        if raw_crash.legacy_processing == LegacyThrottler.IGNORE:
            self.logger.info('%s ignored', crash_id)
            return "Unsupported=1\n"

        crash_storage = self.context.crashStoragePool.crashStorage()
        try:
            crash_storage.save_raw(
                crash_id,
                raw_crash,
                dumps
            )
        except PolyStorageError, x:
            self.logger.error('%s storage exception: %s',
                              crash_id,
                              str(x.exceptions),  # log internal error set
                              exc_info=True)
            raise
Пример #11
0
    def POST(self, *args):
        raw_crash, dumps = \
            self._make_raw_crash_and_dumps(web.webapi.rawinput())

        current_timestamp = utc_now()
        raw_crash.submitted_timestamp = current_timestamp.isoformat()
        # legacy - ought to be removed someday
        raw_crash.timestamp = time.time()

        crash_id = createNewOoid(current_timestamp)
        self.logger.info('%s received', crash_id)

        raw_crash.legacy_processing = self.throttler.throttle(raw_crash)
        if raw_crash.legacy_processing == DISCARD:
            self.logger.info('%s discarded', crash_id)
            return "Discarded=1\n"
        if raw_crash.legacy_processing == IGNORE:
            self.logger.info('%s ignored', crash_id)
            return "Unsupported=1\n"

        self.config.crash_storage.save_raw_crash(
          raw_crash,
          dumps,
          crash_id
        )
        self.logger.info('%s accepted', crash_id)
        return "CrashID=%s%s\n" % (self.dump_id_prefix, crash_id)
Пример #12
0
    def POST(self, *args):
        the_form = web.input()
        dump = the_form[self.dump_field]

        # Remove other submitted files from the input form, which are
        # an indication of a multi-dump hang submission we aren't yet
        # prepared to handle.
        for (key, value) in web.webapi.rawinput().iteritems():
            if hasattr(value, 'file') and hasattr(value, 'value'):
                del the_form[key]

        raw_crash = self.make_raw_crash(the_form)

        current_timestamp = utc_now()
        raw_crash.submitted_timestamp = current_timestamp.isoformat()

        crash_id = createNewOoid(current_timestamp)
        self.logger.info('%s received', crash_id)

        raw_crash.legacy_processing = self.throttler.throttle(raw_crash)
        if raw_crash.legacy_processing == DISCARD:
            return "Discarded=1\n"
        if raw_crash.legacy_processing == IGNORE:
            return "Unsupported=1\n"

        self.config.crash_storage.save_raw_crash(raw_crash, dump, crash_id)
        return "CrashID=%s%s\n" % (self.dump_id_prefix, crash_id)
Пример #13
0
    def POST(self, *args):
        the_form = web.input()
        dump = the_form[self.dump_field]

        # Remove other submitted files from the input form, which are
        # an indication of a multi-dump hang submission we aren't yet
        # prepared to handle.
        for (key, value) in web.webapi.rawinput().iteritems():
            if hasattr(value, 'file') and hasattr(value, 'value'):
                del the_form[key]

        raw_crash = self.make_raw_crash(the_form)

        current_timestamp = utc_now()
        raw_crash.submitted_timestamp = current_timestamp.isoformat()

        crash_id = createNewOoid(current_timestamp)
        self.logger.info('%s received', crash_id)

        raw_crash.legacy_processing = self.throttler.throttle(raw_crash)
        if raw_crash.legacy_processing == DISCARD:
            return "Discarded=1\n"
        if raw_crash.legacy_processing == IGNORE:
            return "Unsupported=1\n"

        self.config.crash_storage.save_raw_crash(
          raw_crash,
          dump,
          crash_id
        )
        return "CrashID=%s%s\n" % (self.dump_id_prefix, crash_id)
Пример #14
0
    def POST(self, *args):
        raw_crash, dumps = self._get_raw_crash_from_form()

        current_timestamp = utc_now()
        raw_crash.submitted_timestamp = current_timestamp.isoformat()
        # legacy - ought to be removed someday
        raw_crash.timestamp = time.time()

        if (not self.accept_submitted_crash_id or 'uuid' not in raw_crash):
            crash_id = createNewOoid(current_timestamp)
            raw_crash.uuid = crash_id
            self.logger.info('%s received', crash_id)
        else:
            crash_id = raw_crash.uuid
            self.logger.info('%s received with existing crash_id:', crash_id)

        if ('legacy_processing' not in raw_crash
                or not self.accept_submitted_legacy_processing):
            raw_crash.legacy_processing, raw_crash.throttle_rate = (
                self.throttler.throttle(raw_crash))
        else:
            raw_crash.legacy_processing = int(raw_crash.legacy_processing)

        try:
            # We want to capture the crash report size, but need to
            # differentiate between compressed vs. uncompressed data as well as
            # accepted vs. rejected data.
            crash_report_size = self._get_content_length()
            is_compressed = self._is_content_gzipped()
            is_accepted = (raw_crash.legacy_processing in (ACCEPT, DEFER))

            metrics_data = {}
            size_key = '_'.join([
                'crash_report_size',
                'accepted' if is_accepted else 'rejected',
                'compressed' if is_compressed else 'uncompressed',
            ])
            metrics_data = {'collector.' + size_key: crash_report_size}
            self.metrics.capture_stats(metrics_data)
        except Exception:
            # We *never* want metrics reporting to prevent saving a crash, so
            # we catch everything and log an error.
            self.logger.error('metrics kicked up exception', exc_info=True)

        if raw_crash.legacy_processing == DISCARD:
            self.logger.info('%s discarded', crash_id)
            return "Discarded=1\n"
        if raw_crash.legacy_processing == IGNORE:
            self.logger.info('%s ignored', crash_id)
            return "Unsupported=1\n"

        raw_crash.type_tag = self.dump_id_prefix.strip('-')

        # Save crash to storage.
        self.crash_storage.save_raw_crash(raw_crash, dumps, crash_id)

        # Return crash id to http client.
        self.logger.info('%s accepted', crash_id)
        return "CrashID=%s%s\n" % (self.dump_id_prefix, crash_id)
Пример #15
0
def handler(req):
  global persistentStorage
  try:
    x = persistentStorage
  except NameError:
    persistentStorage = init.createPersistentInitialization(configModule)

  logger = persistentStorage.logger
  config = persistentStorage.config
  crashStorage = persistentStorage.crashStorage

  #logger.debug("handler invoked using subinterpreter: %s", req.interpreter)
  if req.method == "POST":
    try:
      req.content_type = "text/plain"

      theform = util.FieldStorage(req)
      dump = theform[config.dumpField]
      if not dump.file:
        return apache.HTTP_BAD_REQUEST
      dump = dump.file.read()
      #dump = cstore.RepeatableStreamReader(dump.file)

      currentTimestamp = utc_now()

      jsonDataDictionary = crashStorage.makeJsonDictFromForm(theform)
      jsonDataDictionary.submitted_timestamp = currentTimestamp.isoformat()

      #for future use when we start sunsetting products
      #if crashStorage.terminated(jsonDataDictionary):
        #req.write("Terminated=%s" % jsonDataDictionary.Version)
        #return apache.OK

      uuid = ooid.createNewOoid(currentTimestamp, config.storageDepth)
      logger.debug("    %s", uuid)

      jsonDataDictionary.legacy_processing = persistentStorage.legacyThrottler.throttle(jsonDataDictionary)

      result = crashStorage.save_raw(uuid, jsonDataDictionary, dump, currentTimestamp)

      if result == cstore.CrashStorageSystem.DISCARDED:
        req.write("Discarded=1\n")
        return apache.OK
      elif result == cstore.CrashStorageSystem.ERROR:
        return apache.HTTP_INTERNAL_SERVER_ERROR
      req.write("CrashID=%s%s\n" % (config.dumpIDPrefix, uuid))
      return apache.OK
    except:
      logger.info("mod-python subinterpreter name: %s", req.interpreter)
      sutil.reportExceptionAndContinue(logger)

      return apache.HTTP_INTERNAL_SERVER_ERROR
  else:
    return apache.HTTP_METHOD_NOT_ALLOWED
Пример #16
0
    def GET(self, *args):
        current_timestamp = utc_now()
        base_uri, project_id = args

        raw_crash = DotDict(web.input())
        raw_crash.base_uri = base_uri
        raw_crash.project_id = project_id
        raw_crash.sentry_data = json.loads(raw_crash.sentry_data)
        raw_crash.submitted_timestamp = current_timestamp.isoformat()
        raw_crash.crash_id = createNewOoid(current_timestamp)
        # raw_crash.throttle = self.throttler.throttle(raw_crash)

        self.config.crash_storage.save_raw_crash(raw_crash, {}, raw_crash.crash_id)
        self.logger.info("%s accepted", raw_crash.crash_id)

        return "ok"
Пример #17
0
    def GET(self, *args):
        current_timestamp = utc_now()
        base_uri, project_id = args

        raw_crash = DotDict(web.input())
        raw_crash.base_uri = base_uri
        raw_crash.project_id = project_id
        raw_crash.sentry_data = json.loads(raw_crash.sentry_data)
        raw_crash.submitted_timestamp = current_timestamp.isoformat()
        raw_crash.crash_id = createNewOoid(current_timestamp)
        #raw_crash.throttle = self.throttler.throttle(raw_crash)

        self.config.crash_storage.save_raw_crash(raw_crash, {},
                                                 raw_crash.crash_id)
        self.logger.info('%s accepted', raw_crash.crash_id)

        return 'ok'
Пример #18
0
    def POST(self, *args):
        the_form = web.input()
        raw_crash = self.make_raw_crash(the_form)
        dump = the_form[self.dump_field]

        current_timestamp = utc_now()
        raw_crash.submitted_timestamp = current_timestamp.isoformat()

        crash_id = createNewOoid(current_timestamp)
        self.logger.info("%s received", crash_id)

        raw_crash.legacy_processing = self.throttler.throttle(raw_crash)
        if raw_crash.legacy_processing == DISCARD:
            return "Discarded=1\n"

        self.config.crash_storage.save_raw_crash(raw_crash, dump, crash_id)
        return "CrashID=%s%s\n" % (self.dump_id_prefix, crash_id)
    def POST(self, *args):
        raw_crash, dumps = self._get_raw_crash_from_form()

        current_timestamp = utc_now()
        raw_crash.submitted_timestamp = current_timestamp.isoformat()
        # legacy - ought to be removed someday
        raw_crash.timestamp = time.time()

        if (not self.config.collector.accept_submitted_crash_id
            or 'uuid' not in raw_crash
        ):
            crash_id = createNewOoid(current_timestamp)
            raw_crash.uuid = crash_id
            self.logger.info('%s received', crash_id)
        else:
            crash_id = raw_crash.uuid
            self.logger.info('%s received with existing crash_id:', crash_id)

        if ('legacy_processing' not in raw_crash
            or not self.config.collector.accept_submitted_legacy_processing
        ):
            raw_crash.legacy_processing, raw_crash.throttle_rate = (
                self.throttler.throttle(raw_crash)
            )
        else:
            raw_crash.legacy_processing = int(raw_crash.legacy_processing)

        if raw_crash.legacy_processing == DISCARD:
            self.logger.info('%s discarded', crash_id)
            return "Discarded=1\n"
        if raw_crash.legacy_processing == IGNORE:
            self.logger.info('%s ignored', crash_id)
            return "Unsupported=1\n"

        self.config.crash_storage.save_raw_crash(
          raw_crash,
          dumps,
          crash_id
        )
        self.logger.info('%s accepted', crash_id)
        return "CrashID=%s%s\n" % (self.dump_id_prefix, crash_id)
Пример #20
0
    def POST(self, *args):
        raw_crash, dumps = self._get_raw_crash_from_form()

        current_timestamp = utc_now()
        raw_crash.submitted_timestamp = current_timestamp.isoformat()
        # legacy - ought to be removed someday
        raw_crash.timestamp = time.time()

        if (not self.config.accept_submitted_crash_id
                or 'crash_id' not in raw_crash):
            crash_id = createNewOoid(current_timestamp)
            raw_crash.crash_id = crash_id
            self.logger.info('%s received', crash_id)
        else:
            crash_id = raw_crash.crash_id
            self.logger.info('%s received with existing crash_id:', crash_id)

        raw_crash.type_tag = self.type_tag

        self.crash_storage.save_raw_crash(raw_crash, dumps, crash_id)
        self.logger.info('%s accepted', crash_id)
        return "CrashID=%s%s\n" % (self.type_tag, crash_id)
Пример #21
0
    def POST(self, *args):
        raw_crash, dumps = self._get_raw_crash_from_form()

        current_timestamp = utc_now()
        raw_crash.submitted_timestamp = current_timestamp.isoformat()
        # legacy - ought to be removed someday
        raw_crash.timestamp = time.time()

        if (not self.accept_submitted_crash_id or 'uuid' not in raw_crash):
            crash_id = createNewOoid(current_timestamp)
            raw_crash.uuid = crash_id
            self.logger.info('%s received', crash_id)
        else:
            crash_id = raw_crash.uuid
            self.logger.info('%s received with existing crash_id:', crash_id)

        if ('legacy_processing' not in raw_crash
            or not self.accept_submitted_legacy_processing
        ):
            raw_crash.legacy_processing, raw_crash.throttle_rate = (
                self.throttler.throttle(raw_crash)
            )
        else:
            raw_crash.legacy_processing = int(raw_crash.legacy_processing)

        try:
            # We want to capture the crash report size, but need to
            # differentiate between compressed vs. uncompressed data as well as
            # accepted vs. rejected data.
            crash_report_size = self._get_content_length()
            is_compressed = self._is_content_gzipped()
            is_accepted = (raw_crash.legacy_processing in (ACCEPT, DEFER))

            metrics_data = {}
            size_key = '_'.join([
                'crash_report_size',
                'accepted' if is_accepted else 'rejected',
                'compressed' if is_compressed else 'uncompressed',
            ])
            metrics_data = {
                'collector.' + size_key: crash_report_size
            }
            self.metrics.capture_stats(metrics_data)
        except Exception:
            # We *never* want metrics reporting to prevent saving a crash, so
            # we catch everything and log an error.
            self.logger.error(
                'metrics kicked up exception',
                exc_info=True
            )

        if raw_crash.legacy_processing == DISCARD:
            self.logger.info('%s discarded', crash_id)
            return "Discarded=1\n"
        if raw_crash.legacy_processing == IGNORE:
            self.logger.info('%s ignored', crash_id)
            return "Unsupported=1\n"

        raw_crash.type_tag = self.dump_id_prefix.strip('-')

        # Save crash to storage.
        self.crash_storage.save_raw_crash(
            raw_crash,
            dumps,
            crash_id
        )

        # Return crash id to http client.
        self.logger.info('%s accepted', crash_id)
        return "CrashID=%s%s\n" % (self.dump_id_prefix, crash_id)