add option to config.py to toggle db tracing
This commit is contained in:
@@ -29,6 +29,7 @@ zipkin_max_queue_length = 50000
|
|||||||
zipkin_target_write_size = 1000
|
zipkin_target_write_size = 1000
|
||||||
|
|
||||||
debug = False
|
debug = False
|
||||||
|
db_tracing_enabled = True
|
||||||
|
|
||||||
def set_backends(backends):
|
def set_backends(backends):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -93,6 +93,8 @@ def traced(service_name, name, host='0.0.0.0', port=0):
|
|||||||
## sqlalchemy event listeners
|
## sqlalchemy event listeners
|
||||||
def before_execute(name):
|
def before_execute(name):
|
||||||
def handler(conn, clauseelement, multiparams, params):
|
def handler(conn, clauseelement, multiparams, params):
|
||||||
|
if not config.db_tracing_enabled:
|
||||||
|
return
|
||||||
h = str(conn.connection.connection)
|
h = str(conn.connection.connection)
|
||||||
a = h.find("'")
|
a = h.find("'")
|
||||||
b = h.find("'", a+1)
|
b = h.find("'", a+1)
|
||||||
@@ -110,6 +112,8 @@ def before_execute(name):
|
|||||||
def after_execute(name):
|
def after_execute(name):
|
||||||
# name isn't used, at least not yet...
|
# name isn't used, at least not yet...
|
||||||
def handler(conn, clauseelement, multiparams, params, result):
|
def handler(conn, clauseelement, multiparams, params, result):
|
||||||
|
if not config.db_tracing_enabled:
|
||||||
|
return
|
||||||
stop('execute')
|
stop('execute')
|
||||||
pass
|
pass
|
||||||
return handler
|
return handler
|
||||||
|
|||||||
Reference in New Issue
Block a user