def getAggregatedError(self, project, environment, server, backtraceText, errorHash, message, timestamp): """Gets (and updates) the error matching the given report, or None if no matching error is found.""" error = None key = '%s|%s' % (project, errorHash) serialized = memcache.get(key) if serialized: error = db.model_from_protobuf(serialized) else: q = LoggedError.all() q.filter('project =', project) q.filter('hash =', errorHash) q.filter('active =', True) for possibility in q: if backtrace.normalizeBacktrace(possibility.backtrace) == backtrace.normalizeBacktrace(backtraceText): error = possibility break if error: error.count += 1 error.firstOccurrence = min(error.firstOccurrence, timestamp) if timestamp > error.lastOccurrence: error.lastOccurrence = timestamp error.backtrace = backtraceText error.lastMessage = message[:300] if environment not in error.environments: error.environments.append(environment) if server not in error.servers: error.servers.append(server) error.put() memcache.set(key, db.model_to_protobuf(error)) return error
def testSlightlyDifferentInvokes(self): """Test that slightly different reflection based invocations lead to the same result.""" differentMessage = EXAMPLE.replace('24.invoke', '24.invoke0') self.assertEquals(backtrace.normalizeBacktrace(EXAMPLE), backtrace.normalizeBacktrace(differentMessage)) differentError = EXAMPLE.replace('.method4', '.methodNot4AtAll') self.assertNotEquals(backtrace.normalizeBacktrace(EXAMPLE), backtrace.normalizeBacktrace(differentError))
def testPythonCauseMessage(self): """Test that cause messages are removed for Python.""" differentMessage = PYTHON_EXAMPLE.replace('HTTP 599', 'HTTP 404') self.assertEquals(backtrace.normalizeBacktrace(PYTHON_EXAMPLE), backtrace.normalizeBacktrace(differentMessage)) differentMessage = PYTHON_EXAMPLE.replace('HttpException:', 'OtherException:') self.assertNotEquals(backtrace.normalizeBacktrace(PYTHON_EXAMPLE), backtrace.normalizeBacktrace(differentMessage))
def testRemoveCauseMessage(self): """Test that cause messages are removed.""" differentMessage = EXAMPLE.replace('12345', '23456') self.assertEquals(backtrace.normalizeBacktrace(EXAMPLE), backtrace.normalizeBacktrace(differentMessage)) differentError = EXAMPLE.replace('SomeClass', 'SomeOtherClass') self.assertNotEquals(backtrace.normalizeBacktrace(EXAMPLE), backtrace.normalizeBacktrace(differentError))
def testObjectiveCAddresses(self): """Test that addresses are removed for Objective C.""" self.assertEquals( backtrace.normalizeBacktrace(OBJECTIVE_C_EXAMPLE), backtrace.normalizeBacktrace(OBJECTIVE_C_EXAMPLE_SAME)) self.assertNotEquals( backtrace.normalizeBacktrace(OBJECTIVE_C_EXAMPLE), backtrace.normalizeBacktrace(OBJECTIVE_C_EXAMPLE_NOT_SAME))
def generateHash(exceptionType, backtraceText): """Generates a hash for the given exception type and backtrace.""" hasher = hashlib.md5() if exceptionType: hasher.update(exceptionType.encode('utf-8')) if backtraceText: hasher.update(backtrace.normalizeBacktrace(backtraceText.encode('utf-8'))) return hasher.hexdigest()
def generateHash(exceptionType, backtraceText): """Generates a hash for the given exception type and backtrace.""" hasher = hashlib.md5() if exceptionType: hasher.update(exceptionType.encode("utf-8")) if backtraceText: hasher.update(backtrace.normalizeBacktrace(backtraceText.encode("utf-8"))) return hasher.hexdigest()
def getAggregatedError(project, environment, server, backtraceText, errorHash, message, timestamp): """Gets (and updates) the error matching the given report, or None if no matching error is found.""" error = None project = getProject(project) key = '%s|%s' % (project, errorHash) serialized = memcache.get(key) if serialized: error = db.model_from_protobuf(serialized) else: q = LoggedErrorV2.all().ancestor(project).filter('hash =', errorHash).filter( 'active =', True) for possibility in q: if backtrace.normalizeBacktrace( possibility.backtrace) == backtrace.normalizeBacktrace( backtraceText): error = possibility break if error: error.count += 1 error.firstOccurrence = min(error.firstOccurrence, timestamp) if timestamp > error.lastOccurrence: error.lastOccurrence = timestamp error.backtrace = backtraceText error.lastMessage = message[:300] if environment not in error.environments: error.environments.append(environment) if server not in error.servers: error.servers.append(server) error.put() memcache.set(key, db.model_to_protobuf(error)) return error
def testObjectiveCAddresses(self): """Test that addresses are removed for Objective C.""" self.assertEquals(backtrace.normalizeBacktrace(OBJECTIVE_C_EXAMPLE), backtrace.normalizeBacktrace(OBJECTIVE_C_EXAMPLE_SAME)) self.assertNotEquals(backtrace.normalizeBacktrace(OBJECTIVE_C_EXAMPLE), backtrace.normalizeBacktrace(OBJECTIVE_C_EXAMPLE_NOT_SAME))