Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

More database opentracing #10136

Merged
merged 1 commit into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/10136.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Report OpenTracing spans for database activity.
7 changes: 5 additions & 2 deletions synapse/storage/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ def new_transaction(
},
):
r = func(cursor, *args, **kwargs)
opentracing.log_kv({"message": "commit"})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the idea that we can now time how long the function vs commit takes? I think start_active span should tag the span with error if any of this fails?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, yes, I was mystified why my transaction did all of its queries in 50ms and then took another 120ms before it finished. Turns out commit can be slow, at least for sqlite.

conn.commit()
return r
except self.engine.module.OperationalError as e:
Expand All @@ -556,7 +557,8 @@ def new_transaction(
if i < N:
i += 1
try:
conn.rollback()
with opentracing.start_active_span("db.rollback"):
conn.rollback()
except self.engine.module.Error as e1:
transaction_logger.warning("[TXN EROLL] {%s} %s", name, e1)
continue
Expand All @@ -569,7 +571,8 @@ def new_transaction(
if i < N:
i += 1
try:
conn.rollback()
with opentracing.start_active_span("db.rollback"):
conn.rollback()
except self.engine.module.Error as e1:
transaction_logger.warning(
"[TXN EROLL] {%s} %s",
Expand Down