rally/openstack-patches/master/nova/0002-Added-SQL-queries-trace.patch
Alexei Kornienko 6d44c4930d Added python clients patches
Moved nova patches to corresponding folder

Change-Id: I97ea96b720460d3c28875bc0637aa5dfd00bcac6
2013-10-18 14:20:51 +03:00

89 lines
3.0 KiB
Diff

From 8a4337a1647aa0b668ff3be52fbdeebc30bda502 Mon Sep 17 00:00:00 2001
From: Alexei Kornienko <akornienko@mirantis.com>
Date: Fri, 23 Aug 2013 15:14:23 +0300
Subject: [PATCH 2/3] Added SQL queries trace
Change-Id: I3b64de08d5760f0a69b4a3c5abc020f4420755b0
---
nova/db/sqlalchemy/migration.py | 33 ++++++++++++++++----------
nova/openstack/common/db/sqlalchemy/session.py | 5 ++++
2 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/nova/db/sqlalchemy/migration.py b/nova/db/sqlalchemy/migration.py
index 4170c93..a452b2f 100644
--- a/nova/db/sqlalchemy/migration.py
+++ b/nova/db/sqlalchemy/migration.py
@@ -18,6 +18,7 @@
import distutils.version as dist_version
import os
+import tomograph.config
from nova.db import migration
from nova import exception
@@ -63,19 +64,25 @@ get_engine = db_session.get_engine
def db_sync(version=None):
- if version is not None:
- try:
- version = int(version)
- except ValueError:
- raise exception.NovaException(_("version should be an integer"))
-
- current_version = db_version()
- repository = _find_migrate_repo()
- if version is None or version > current_version:
- return versioning_api.upgrade(get_engine(), repository, version)
- else:
- return versioning_api.downgrade(get_engine(), repository,
- version)
+ try:
+ tomograph.config.db_tracing_enabled = False
+
+ if version is not None:
+ try:
+ version = int(version)
+ except ValueError:
+ msg = _("version should be an integer")
+ raise exception.NovaException(msg)
+
+ current_version = db_version()
+ repository = _find_migrate_repo()
+ if version is None or version > current_version:
+ return versioning_api.upgrade(get_engine(), repository, version)
+ else:
+ return versioning_api.downgrade(get_engine(), repository,
+ version)
+ finally:
+ tomograph.config.db_tracing_enabled = True
def db_version():
diff --git a/nova/openstack/common/db/sqlalchemy/session.py b/nova/openstack/common/db/sqlalchemy/session.py
index be1a78a..7dd9758 100644
--- a/nova/openstack/common/db/sqlalchemy/session.py
+++ b/nova/openstack/common/db/sqlalchemy/session.py
@@ -244,6 +244,8 @@ Efficient use of soft deletes:
import os.path
import re
import time
+import tomograph
+import tomograph.config
from eventlet import greenthread
from oslo.config import cfg
@@ -559,6 +561,9 @@ def get_engine(sqlite_fk=False, slave_engine=False):
if engine is None:
engine = create_engine(db_uri,
sqlite_fk=sqlite_fk)
+ if engine.name != 'sqlite':
+ sqlalchemy.event.listen(engine, 'before_execute', tomograph.before_execute('nova'))
+ sqlalchemy.event.listen(engine, 'after_execute', tomograph.after_execute('nova'))
if slave_engine:
_SLAVE_ENGINE = engine
else:
--
1.8.1.2