diff options
author | Erik Johnston <erik@matrix.org> | 2021-04-27 14:15:35 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2021-04-27 14:15:35 +0100 |
commit | ef9e926e552260042ac855fbeae9b4ef396254e2 (patch) | |
tree | 6397717471ef5e5d965d1b82c8c12ec5034aee3e /synapse/storage | |
parent | Remove various bits of compatibility code for Python <3.6 (#9879) (diff) | |
download | synapse-ef9e926e552260042ac855fbeae9b4ef396254e2.tar.xz |
Add opentracing spans to DB calls and measure blocks github/erikj/opentracing_db_measure erikj/opentracing_db_measure
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/database.py | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/synapse/storage/database.py b/synapse/storage/database.py index bd39c095af..f496ab35ed 100644 --- a/synapse/storage/database.py +++ b/synapse/storage/database.py @@ -45,6 +45,7 @@ from synapse.logging.context import ( current_context, make_deferred_yieldable, ) +from synapse.logging.opentracing import start_active_span from synapse.metrics.background_process_metrics import run_as_background_process from synapse.storage.background_updates import BackgroundUpdater from synapse.storage.engines import BaseDatabaseEngine, PostgresEngine, Sqlite3Engine @@ -653,19 +654,20 @@ class DatabasePool: logger.warning("Starting db txn '%s' from sentinel context", desc) try: - result = await self.runWithConnection( - self.new_transaction, - desc, - after_callbacks, - exception_callbacks, - func, - *args, - db_autocommit=db_autocommit, - **kwargs, - ) + with start_active_span(f"txn.{desc}"): + result = await self.runWithConnection( + self.new_transaction, + desc, + after_callbacks, + exception_callbacks, + func, + *args, + db_autocommit=db_autocommit, + **kwargs, + ) - for after_callback, after_args, after_kwargs in after_callbacks: - after_callback(*after_args, **after_kwargs) + for after_callback, after_args, after_kwargs in after_callbacks: + after_callback(*after_args, **after_kwargs) except Exception: for after_callback, after_args, after_kwargs in exception_callbacks: after_callback(*after_args, **after_kwargs) |