136 lines
4.3 KiB
Diff
136 lines
4.3 KiB
Diff
diff --git a/glance/api/middleware/tomo.py b/glance/api/middleware/tomo.py
|
|
new file mode 100644
|
|
index 0000000..c4814bf
|
|
--- /dev/null
|
|
+++ b/glance/api/middleware/tomo.py
|
|
@@ -0,0 +1,16 @@
|
|
+from glance.common import wsgi
|
|
+
|
|
+import tomograph
|
|
+
|
|
+class Tomo(wsgi.Middleware):
|
|
+
|
|
+ def __init__(self, app):
|
|
+ super(Tomo, self).__init__(app)
|
|
+
|
|
+ def process_request(self, req):
|
|
+ """Try to find a version first in the accept header, then the URL"""
|
|
+ tomograph.start_http('glanceregistry', 'WSGI', req)
|
|
+
|
|
+ def process_response(self, resp):
|
|
+ tomograph.stop('WSGI')
|
|
+ return resp
|
|
diff --git a/glance/api/middleware/version_negotiation.py b/glance/api/middleware/version_negotiation.py
|
|
index 74cc3bf..fa54253 100644
|
|
--- a/glance/api/middleware/version_negotiation.py
|
|
+++ b/glance/api/middleware/version_negotiation.py
|
|
@@ -26,6 +26,8 @@ from glance.common import wsgi
|
|
import glance.openstack.common.log as logging
|
|
from glance.openstack.common import cfg
|
|
|
|
+import tomograph
|
|
+
|
|
CONF = cfg.CONF
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
@@ -39,6 +41,8 @@ class VersionNegotiationFilter(wsgi.Middleware):
|
|
|
|
def process_request(self, req):
|
|
"""Try to find a version first in the accept header, then the URL"""
|
|
+ tomograph.start_http('glanceapi', 'WSGI', req)
|
|
+
|
|
msg = _("Determining version of request: %(method)s %(path)s"
|
|
" Accept: %(accept)s")
|
|
args = {'method': req.method, 'path': req.path, 'accept': req.accept}
|
|
@@ -71,6 +75,10 @@ class VersionNegotiationFilter(wsgi.Middleware):
|
|
LOG.debug('new uri %s' % req.path_info)
|
|
return None
|
|
|
|
+ def process_response(self, resp):
|
|
+ tomograph.stop('WSGI')
|
|
+ return resp
|
|
+
|
|
def _match_version_string(self, subject):
|
|
"""
|
|
Given a string, tries to match a major and/or
|
|
diff --git a/glance/common/client.py b/glance/common/client.py
|
|
index 88dbda7..5e03a15 100644
|
|
--- a/glance/common/client.py
|
|
+++ b/glance/common/client.py
|
|
@@ -28,6 +28,8 @@ import re
|
|
import select
|
|
import urllib
|
|
import urlparse
|
|
+import socket
|
|
+import tomograph
|
|
|
|
try:
|
|
from eventlet.green import socket, ssl
|
|
@@ -496,6 +498,9 @@ class BaseClient(object):
|
|
connection_type = self.get_connection_type()
|
|
headers = headers or {}
|
|
|
|
+ tomograph.start('registryclient', 'http', socket.gethostname(), 0)
|
|
+ tomograph.add_trace_info_header(headers)
|
|
+
|
|
if 'x-auth-token' not in headers and self.auth_tok:
|
|
headers['x-auth-token'] = self.auth_tok
|
|
|
|
@@ -557,6 +562,7 @@ class BaseClient(object):
|
|
def _retry(res):
|
|
return res.getheader('Retry-After')
|
|
|
|
+ tomograph.stop('http')
|
|
status_code = self.get_status_code(res)
|
|
if status_code in self.OK_RESPONSE_CODES:
|
|
return res
|
|
diff --git a/glance/common/wsgi.py b/glance/common/wsgi.py
|
|
index d324861..e8bd023 100644
|
|
--- a/glance/common/wsgi.py
|
|
+++ b/glance/common/wsgi.py
|
|
@@ -29,6 +29,7 @@ import os
|
|
import signal
|
|
import sys
|
|
import time
|
|
+import tomograph
|
|
|
|
import eventlet
|
|
from eventlet.green import socket, ssl
|
|
@@ -365,6 +366,14 @@ class Debug(Middleware):
|
|
print
|
|
|
|
|
|
+class Tomo(Middleware):
|
|
+ def process_request(self, req):
|
|
+ tomograph.start_http('glance', 'WSGI', req)
|
|
+
|
|
+ def process_response(self, req):
|
|
+ tomograph.stop('WSGI')
|
|
+
|
|
+
|
|
class Router(object):
|
|
"""
|
|
WSGI middleware that maps incoming requests to WSGI apps.
|
|
diff --git a/glance/db/sqlalchemy/api.py b/glance/db/sqlalchemy/api.py
|
|
index 779a434..1e8b824 100644
|
|
--- a/glance/db/sqlalchemy/api.py
|
|
+++ b/glance/db/sqlalchemy/api.py
|
|
@@ -36,6 +36,7 @@ from glance.openstack.common import cfg
|
|
import glance.openstack.common.log as os_logging
|
|
from glance.openstack.common import timeutils
|
|
|
|
+import tomograph
|
|
|
|
_ENGINE = None
|
|
_MAKER = None
|
|
@@ -100,6 +101,9 @@ def configure_db():
|
|
try:
|
|
_ENGINE = sqlalchemy.create_engine(sql_connection, **engine_args)
|
|
|
|
+ sqlalchemy.event.listen(_ENGINE, 'before_execute', tomograph.before_execute('glance'))
|
|
+ sqlalchemy.event.listen(_ENGINE, 'after_execute', tomograph.after_execute('glance'))
|
|
+
|
|
if 'mysql' in connection_dict.drivername:
|
|
sqlalchemy.event.listen(_ENGINE, 'checkout', ping_listener)
|
|
|