forked from MirrorHub/synapse
Start an opentracing span for background processes. (#8567)
This should reduce the number of `There was no active span` errors we see. Fixes #8510.
This commit is contained in:
parent
97647b33c2
commit
1fcdbeb3ab
2 changed files with 7 additions and 5 deletions
1
changelog.d/8567.bugfix
Normal file
1
changelog.d/8567.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
Fix increase in the number of `There was no active span...` errors logged when using OpenTracing.
|
|
@ -24,6 +24,7 @@ from prometheus_client.core import REGISTRY, Counter, Gauge
|
|||
from twisted.internet import defer
|
||||
|
||||
from synapse.logging.context import LoggingContext, PreserveLoggingContext
|
||||
from synapse.logging.opentracing import start_active_span
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import resource
|
||||
|
@ -197,8 +198,8 @@ def run_as_background_process(desc: str, func, *args, **kwargs):
|
|||
|
||||
with BackgroundProcessLoggingContext(desc) as context:
|
||||
context.request = "%s-%i" % (desc, count)
|
||||
|
||||
try:
|
||||
with start_active_span(desc, tags={"request_id": context.request}):
|
||||
result = func(*args, **kwargs)
|
||||
|
||||
if inspect.isawaitable(result):
|
||||
|
|
Loading…
Reference in a new issue