add option to config.py to toggle db tracing

This commit is contained in:
Tim Daly, Jr
2013-04-16 21:49:33 +00:00
parent 024b4ecb1c
commit 115654c9ab
2 changed files with 5 additions and 0 deletions

View File

@@ -29,6 +29,7 @@ zipkin_max_queue_length = 50000
zipkin_target_write_size = 1000
debug = False
db_tracing_enabled = True
def set_backends(backends):
"""

View File

@@ -93,6 +93,8 @@ def traced(service_name, name, host='0.0.0.0', port=0):
## sqlalchemy event listeners
def before_execute(name):
def handler(conn, clauseelement, multiparams, params):
if not config.db_tracing_enabled:
return
h = str(conn.connection.connection)
a = h.find("'")
b = h.find("'", a+1)
@@ -110,6 +112,8 @@ def before_execute(name):
def after_execute(name):
# name isn't used, at least not yet...
def handler(conn, clauseelement, multiparams, params, result):
if not config.db_tracing_enabled:
return
stop('execute')
pass
return handler