Merge branch 'main' into avm99963-monorail
Merged commit 3779da353b36d43cf778e7d4f468097714dd4540
GitOrigin-RevId: 6451a5c6b75afb0fd1f37b3f14521148d0722ea8
diff --git a/framework/sql.py b/framework/sql.py
index 1d7573d..0fb8043 100644
--- a/framework/sql.py
+++ b/framework/sql.py
@@ -23,6 +23,7 @@
from framework import exceptions
from framework import framework_helpers
+from framework import logger
from infra_libs import ts_mon
@@ -258,12 +259,20 @@
DB_RESULT_ROWS.add(cursor.rowcount)
if stmt_str.startswith('INSERT') or stmt_str.startswith('REPLACE'):
- formatted_statement = '%s %s' % (stmt_str, stmt_args)
+ formatted_statement = ('%s %s' % (stmt_str, stmt_args)).replace('\n', ' ')
else:
- formatted_statement = stmt_str % tuple(stmt_args)
+ formatted_statement = (stmt_str % tuple(stmt_args)).replace('\n', ' ')
logging.info(
'%d rows in %d ms: %s', cursor.rowcount, int(duration),
- formatted_statement.replace('\n', ' '))
+ formatted_statement)
+ if duration >= 2000:
+ logger.log({
+ 'log_type': 'database/query',
+ 'statement': formatted_statement,
+ 'type': formatted_statement.split(' ')[0],
+ 'duration': duration / 1000,
+ 'row_count': cursor.rowcount,
+ })
if commit and not stmt_str.startswith('SELECT'):
try: