proxy-logging: emit stats more consistently

Change-Id: I526bbcc59c9eb5923c3784d5d06bc38998cb48db
This commit is contained in:
Clay Gerrard 2024-04-03 18:44:35 -05:00
parent 3c449e78e4
commit d4435e1229
2 changed files with 7 additions and 5 deletions

View File

@ -356,7 +356,7 @@ class ProxyLoggingMiddleware(object):
except IndexError:
stat_type = 'object'
else:
stat_type = req.environ.get('swift.source')
stat_type = req.environ.get('swift.source') or 'UNKNOWN'
return stat_type
def statsd_metric_name(self, req, status_int, method):

View File

@ -454,8 +454,9 @@ class TestProxyLogging(unittest.TestCase):
self.assertEqual(log_parts[4], '/path')
self.assertEqual(log_parts[5], 'HTTP/1.0')
self.assertEqual(log_parts[6], '503')
# but we don't get metrics!?
self.assertFalse(app.access_logger.statsd_client.calls)
# we can also expect error metrics
self.assertTiming('UNKNOWN.GET.503.timing', app,
exp_timing=700.0)
def test_middleware_exception(self):
self.logger = debug_logger()
@ -473,8 +474,9 @@ class TestProxyLogging(unittest.TestCase):
self.assertEqual(log_parts[4], '/path')
self.assertEqual(log_parts[5], 'HTTP/1.0')
self.assertEqual(log_parts[6], '500')
# but we don't get metrics!?
self.assertFalse(app.access_logger.statsd_client.calls)
# we can also expect error metrics
self.assertTiming('UNKNOWN.GET.500.timing', app,
exp_timing=200.0)
def test_middleware_error(self):
class ErrorFakeApp(object):