More database opentracing (#10136)

Add a couple of extra logs/spans, to give a bit of a better idea.
This commit is contained in:
Richard van der Hoff 2021-06-07 18:01:32 +01:00 committed by GitHub
parent b2557cbf42
commit 0acb5010ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -0,0 +1 @@
Report OpenTracing spans for database activity.

View File

@ -541,6 +541,7 @@ class DatabasePool:
}, },
): ):
r = func(cursor, *args, **kwargs) r = func(cursor, *args, **kwargs)
opentracing.log_kv({"message": "commit"})
conn.commit() conn.commit()
return r return r
except self.engine.module.OperationalError as e: except self.engine.module.OperationalError as e:
@ -556,7 +557,8 @@ class DatabasePool:
if i < N: if i < N:
i += 1 i += 1
try: try:
conn.rollback() with opentracing.start_active_span("db.rollback"):
conn.rollback()
except self.engine.module.Error as e1: except self.engine.module.Error as e1:
transaction_logger.warning("[TXN EROLL] {%s} %s", name, e1) transaction_logger.warning("[TXN EROLL] {%s} %s", name, e1)
continue continue
@ -569,7 +571,8 @@ class DatabasePool:
if i < N: if i < N:
i += 1 i += 1
try: try:
conn.rollback() with opentracing.start_active_span("db.rollback"):
conn.rollback()
except self.engine.module.Error as e1: except self.engine.module.Error as e1:
transaction_logger.warning( transaction_logger.warning(
"[TXN EROLL] {%s} %s", "[TXN EROLL] {%s} %s",