Skip to content

Commit b2557cb

Browse files
authored
opentracing: use a consistent name for background processes (matrix-org#10135)
... otherwise we tend to get a namespace clash between the bg process and the functions that it calls.
1 parent beb251e commit b2557cb

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

changelog.d/10135.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
OpenTracing: use a consistent name for background processes.

synapse/logging/opentracing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ def ensure_active_span_inner_2(*args, **kwargs):
337337
@contextlib.contextmanager
338338
def noop_context_manager(*args, **kwargs):
339339
"""Does exactly what it says on the tin"""
340+
# TODO: replace with contextlib.nullcontext once we drop support for Python 3.6
340341
yield
341342

342343

synapse/metrics/background_process_metrics.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,12 @@ async def run():
204204

205205
with BackgroundProcessLoggingContext(desc, count) as context:
206206
try:
207-
ctx = noop_context_manager()
208207
if bg_start_span:
209208
ctx = start_active_span(
210-
desc, tags={SynapseTags.REQUEST_ID: str(context)}
209+
f"bgproc.{desc}", tags={SynapseTags.REQUEST_ID: str(context)}
211210
)
211+
else:
212+
ctx = noop_context_manager()
212213
with ctx:
213214
return await maybe_awaitable(func(*args, **kwargs))
214215
except Exception:

0 commit comments

Comments
 (0)