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
 | 
			
		||||
 | 
			
		||||
debug = False
 | 
			
		||||
db_tracing_enabled = True
 | 
			
		||||
 | 
			
		||||
def set_backends(backends):
 | 
			
		||||
    """
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user