proxy-logging: emit stats more consistently
Change-Id: I526bbcc59c9eb5923c3784d5d06bc38998cb48db
This commit is contained in:
@@ -356,7 +356,7 @@ class ProxyLoggingMiddleware(object):
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
stat_type = 'object'
|
stat_type = 'object'
|
||||||
else:
|
else:
|
||||||
stat_type = req.environ.get('swift.source')
|
stat_type = req.environ.get('swift.source') or 'UNKNOWN'
|
||||||
return stat_type
|
return stat_type
|
||||||
|
|
||||||
def statsd_metric_name(self, req, status_int, method):
|
def statsd_metric_name(self, req, status_int, method):
|
||||||
|
@@ -454,8 +454,9 @@ class TestProxyLogging(unittest.TestCase):
|
|||||||
self.assertEqual(log_parts[4], '/path')
|
self.assertEqual(log_parts[4], '/path')
|
||||||
self.assertEqual(log_parts[5], 'HTTP/1.0')
|
self.assertEqual(log_parts[5], 'HTTP/1.0')
|
||||||
self.assertEqual(log_parts[6], '503')
|
self.assertEqual(log_parts[6], '503')
|
||||||
# but we don't get metrics!?
|
# we can also expect error metrics
|
||||||
self.assertFalse(app.access_logger.statsd_client.calls)
|
self.assertTiming('UNKNOWN.GET.503.timing', app,
|
||||||
|
exp_timing=700.0)
|
||||||
|
|
||||||
def test_middleware_exception(self):
|
def test_middleware_exception(self):
|
||||||
self.logger = debug_logger()
|
self.logger = debug_logger()
|
||||||
@@ -473,8 +474,9 @@ class TestProxyLogging(unittest.TestCase):
|
|||||||
self.assertEqual(log_parts[4], '/path')
|
self.assertEqual(log_parts[4], '/path')
|
||||||
self.assertEqual(log_parts[5], 'HTTP/1.0')
|
self.assertEqual(log_parts[5], 'HTTP/1.0')
|
||||||
self.assertEqual(log_parts[6], '500')
|
self.assertEqual(log_parts[6], '500')
|
||||||
# but we don't get metrics!?
|
# we can also expect error metrics
|
||||||
self.assertFalse(app.access_logger.statsd_client.calls)
|
self.assertTiming('UNKNOWN.GET.500.timing', app,
|
||||||
|
exp_timing=200.0)
|
||||||
|
|
||||||
def test_middleware_error(self):
|
def test_middleware_error(self):
|
||||||
class ErrorFakeApp(object):
|
class ErrorFakeApp(object):
|
||||||
|
Reference in New Issue
Block a user