Example #1
0
 def handler(conn, cursor, statement, params, context, executemany):
     if not hide_result:
         # Add SQL result to trace info in *-stop phase
         info = {"db": {"result": str(cursor._rows)}}
         profiler.stop(info=info)
     else:
         profiler.stop()
Example #2
0
 def handler(conn, cursor, statement, params, context, executemany):
     if not hide_result:
         # Add SQL result to trace info in *-stop phase
         info = {
             "db": {
                 "result": str(cursor._rows)
             }
         }
         profiler.stop(info=info)
     else:
         profiler.stop()
Example #3
0
def handle_error(exception_context):
    """Handle SQLAlchemy errors"""
    exception_class_name = reflection.get_class_name(
        exception_context.original_exception)
    original_exception = str(exception_context.original_exception)
    chained_exception = str(exception_context.chained_exception)

    info = {
        "etype": exception_class_name,
        "message": original_exception,
        "db": {
            "original_exception": original_exception,
            "chained_exception": chained_exception
        }
    }
    profiler.stop(info=info)
    LOG.debug("OSProfiler has handled SQLAlchemy error: %s",
              original_exception)
Example #4
0
def handle_error(exception_context):
    """Handle SQLAlchemy errors"""
    exception_class_name = reflection.get_class_name(
        exception_context.original_exception)
    original_exception = str(exception_context.original_exception)
    chained_exception = str(exception_context.chained_exception)

    info = {
        "etype": exception_class_name,
        "message": original_exception,
        "db": {
            "original_exception": original_exception,
            "chained_exception": chained_exception
        }
    }
    profiler.stop(info=info)
    LOG.debug("OSProfiler has handled SQLAlchemy error: %s",
              original_exception)
Example #5
0
 def test_stop(self):
     p = profiler.init("secret", base_id="1", parent_id="2")
     p.stop = mock.MagicMock()
     profiler.stop(info="info")
     p.stop.assert_called_once_with(info="info")
Example #6
0
 def test_stop_not_inited(self):
     profiler._clean()
     profiler.stop()
Example #7
0
 def handler(conn, cursor, statement, params, context, executemany):
     profiler.stop()
Example #8
0
 def handler(conn, cursor, statement, params, context, executemany):
     profiler.stop()