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

Commit

Permalink
opentracing: use a consistent name for background processes (#10135)
Browse files Browse the repository at this point in the history
... otherwise we tend to get a namespace clash between the bg process and the
functions that it calls.
  • Loading branch information
richvdh authored Jun 7, 2021
1 parent beb251e commit b2557cb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/10135.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
OpenTracing: use a consistent name for background processes.
1 change: 1 addition & 0 deletions synapse/logging/opentracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ def ensure_active_span_inner_2(*args, **kwargs):
@contextlib.contextmanager
def noop_context_manager(*args, **kwargs):
"""Does exactly what it says on the tin"""
# TODO: replace with contextlib.nullcontext once we drop support for Python 3.6
yield


Expand Down
5 changes: 3 additions & 2 deletions synapse/metrics/background_process_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,12 @@ async def run():

with BackgroundProcessLoggingContext(desc, count) as context:
try:
ctx = noop_context_manager()
if bg_start_span:
ctx = start_active_span(
desc, tags={SynapseTags.REQUEST_ID: str(context)}
f"bgproc.{desc}", tags={SynapseTags.REQUEST_ID: str(context)}
)
else:
ctx = noop_context_manager()
with ctx:
return await maybe_awaitable(func(*args, **kwargs))
except Exception:
Expand Down

0 comments on commit b2557cb

Please sign in to comment.