From 725ce9dfa32f2beb1f44dc21841bceed0bc10e13 Mon Sep 17 00:00:00 2001 From: Boris Pavlovic Date: Mon, 18 Aug 2014 14:59:05 +0400 Subject: [PATCH] Improve Glance profiling Put osprofiler middleware as a almost first middleware. This allows us to: 1) Get more preciese duration. We are measuring duration of all middlewares. 2) authenticate middleware is requesting keystone, so if we init osprofiler before this middleware, we will get trace infomration from keystone as well. Change-Id: I11c5d21e6e6b0bd514dee295da410b208d7c798c --- etc/glance-api-paste.ini | 16 ++++++++-------- etc/glance-registry-paste.ini | 6 +++--- glance/tests/unit/common/test_config.py | 5 +++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/etc/glance-api-paste.ini b/etc/glance-api-paste.ini index cf66c03340..86a4cdb188 100644 --- a/etc/glance-api-paste.ini +++ b/etc/glance-api-paste.ini @@ -1,38 +1,38 @@ # Use this pipeline for no auth or image caching - DEFAULT [pipeline:glance-api] -pipeline = versionnegotiation unauthenticated-context osprofiler rootapp +pipeline = versionnegotiation osprofiler unauthenticated-context rootapp # Use this pipeline for image caching and no auth [pipeline:glance-api-caching] -pipeline = versionnegotiation unauthenticated-context osprofiler cache rootapp +pipeline = versionnegotiation osprofiler unauthenticated-context cache rootapp # Use this pipeline for caching w/ management interface but no auth [pipeline:glance-api-cachemanagement] -pipeline = versionnegotiation unauthenticated-context osprofiler cache cachemanage rootapp +pipeline = versionnegotiation osprofiler unauthenticated-context cache cachemanage rootapp # Use this pipeline for keystone auth [pipeline:glance-api-keystone] -pipeline = versionnegotiation authtoken context osprofiler rootapp +pipeline = versionnegotiation osprofiler authtoken context rootapp # Use this pipeline for keystone auth with image caching [pipeline:glance-api-keystone+caching] -pipeline = versionnegotiation authtoken context osprofiler cache rootapp +pipeline = versionnegotiation osprofiler authtoken context cache rootapp # Use this pipeline for keystone auth with caching and cache management [pipeline:glance-api-keystone+cachemanagement] -pipeline = versionnegotiation authtoken context osprofiler cache cachemanage rootapp +pipeline = versionnegotiation osprofiler authtoken context cache cachemanage rootapp # Use this pipeline for authZ only. This means that the registry will treat a # user as authenticated without making requests to keystone to reauthenticate # the user. [pipeline:glance-api-trusted-auth] -pipeline = versionnegotiation context osprofiler rootapp +pipeline = versionnegotiation osprofiler context rootapp # Use this pipeline for authZ only. This means that the registry will treat a # user as authenticated without making requests to keystone to reauthenticate # the user and uses cache management [pipeline:glance-api-trusted-auth+cachemanagement] -pipeline = versionnegotiation context osprofiler cache cachemanage rootapp +pipeline = versionnegotiation osprofiler context cache cachemanage rootapp [composite:rootapp] paste.composite_factory = glance.api:root_app_factory diff --git a/etc/glance-registry-paste.ini b/etc/glance-registry-paste.ini index 2749566682..df403f6e04 100644 --- a/etc/glance-registry-paste.ini +++ b/etc/glance-registry-paste.ini @@ -1,16 +1,16 @@ # Use this pipeline for no auth - DEFAULT [pipeline:glance-registry] -pipeline = unauthenticated-context osprofiler registryapp +pipeline = osprofiler unauthenticated-context registryapp # Use this pipeline for keystone auth [pipeline:glance-registry-keystone] -pipeline = authtoken context osprofiler registryapp +pipeline = osprofiler authtoken context registryapp # Use this pipeline for authZ only. This means that the registry will treat a # user as authenticated without making requests to keystone to reauthenticate # the user. [pipeline:glance-registry-trusted-auth] -pipeline = context osprofiler registryapp +pipeline = osprofiler context registryapp [app:registryapp] paste.app_factory = glance.registry.api:API.factory diff --git a/glance/tests/unit/common/test_config.py b/glance/tests/unit/common/test_config.py index e1c772253b..b7baee21f0 100644 --- a/glance/tests/unit/common/test_config.py +++ b/glance/tests/unit/common/test_config.py @@ -17,6 +17,7 @@ import os.path import shutil import fixtures +import osprofiler.web import stubout from glance.api.middleware import context @@ -71,7 +72,7 @@ class TestPasteApp(test_utils.BaseTestCase): self.assertIsInstance(app, expected_app_type) def test_load_paste_app(self): - expected_middleware = context.UnauthenticatedContextMiddleware + expected_middleware = osprofiler.web.WsgiMiddleware self._do_test_load_paste_app(expected_middleware) def test_load_paste_app_paste_config_not_found(self): @@ -90,7 +91,7 @@ class TestPasteApp(test_utils.BaseTestCase): def test_load_paste_app_with_paste_config_file(self): paste_config_file = os.path.join(os.getcwd(), 'etc/glance-registry-paste.ini') - expected_middleware = context.UnauthenticatedContextMiddleware + expected_middleware = osprofiler.web.WsgiMiddleware self._do_test_load_paste_app(expected_middleware, paste_config_file=paste_config_file)