From 72f96b0d37ce870f52a9b6b05fb698fcac062f43 Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Thu, 12 Jan 2012 17:22:11 +0000 Subject: Prefixing the request id with 'req-' to decrease confusion when looking at logs. Change-Id: Ic29b9c6b83c4572d17c0b48fb509063d279d3a78 --- nova/context.py | 2 +- nova/tests/api/openstack/test_wsgi.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/nova/context.py b/nova/context.py index 79ad0934d..b0c0603a8 100644 --- a/nova/context.py +++ b/nova/context.py @@ -59,7 +59,7 @@ class RequestContext(object): timestamp = utils.parse_strtime(timestamp) self.timestamp = timestamp if not request_id: - request_id = unicode(uuid.uuid4()) + request_id = 'req-' + str(utils.gen_uuid()) self.request_id = request_id self.auth_token = auth_token self.strategy = strategy diff --git a/nova/tests/api/openstack/test_wsgi.py b/nova/tests/api/openstack/test_wsgi.py index 2d5f33eee..84c009040 100644 --- a/nova/tests/api/openstack/test_wsgi.py +++ b/nova/tests/api/openstack/test_wsgi.py @@ -225,12 +225,22 @@ class RequestHeadersDeserializerTest(test.TestCase): class ResponseHeadersSerializerTest(test.TestCase): def test_request_id(self): serializer = wsgi.ResponseHeadersSerializer() + context = nova.context.get_admin_context() req = webob.Request.blank('/', environ={'nova.context': context}) res = webob.Response(request=req) serializer.serialize(res, {}, 'foo') - self.assertTrue( - utils.is_uuid_like(res.headers['X-Compute-Request-Id'])) + h1 = res.headers.get('X-Compute-Request-Id') + self.assertTrue(h1) + + context = nova.context.get_admin_context() + req = webob.Request.blank('/', environ={'nova.context': context}) + res = webob.Response(request=req) + serializer.serialize(res, {}, 'foo') + h2 = res.headers.get('X-Compute-Request-Id') + self.assertTrue(h2) + + self.assertNotEqual(h1, h2) class JSONSerializer(object): -- cgit