def test_basic_log_parsing(self): metric_name, timestamp, request_time, attrs = parse_couch_logs(logging, SIMPLE) self.assertEqual(metric_name, 'couch.timings') self.assertEqual(timestamp, 1446309123.0) self.assertEqual(request_time, 0.191515) self.assertEqual(attrs['metric_type'], 'gauge') self.assertEqual(attrs['url'], '/a/*/receiver/*/') self.assertEqual(attrs['domain'], 'mvp-pampaida') self.assertEqual(attrs['couch_url'], '*') self.assertEqual(attrs['status_code'], 'None') self.assertEqual(attrs['http_method'], 'PUT')
def _test_log_parsing(self, line, expected_timestamp, expected_request_time, expected_attrs): metric_name, timestamp, request_time, attrs = parse_couch_logs( logging, line) expected_attrs.update({ 'metric_type': 'gauge', }) self.assertEqual(metric_name, 'couch.timings') self.assert_timestamp_equal(timestamp, *expected_timestamp) self.assertEqual(expected_request_time, request_time) self.assertEqual(expected_attrs, attrs)
def test_borked_log_line(self): self.assertIsNone(parse_couch_logs(logging, BORKED))