Set opentracing priority before setting other tags (#10092)

... because tags on spans which aren't being sampled get thrown away.
This commit is contained in:
Richard van der Hoff 2021-05-28 16:14:08 +01:00 committed by GitHub
parent 3f96dbbda7
commit ed53bf314f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 11 deletions

View file

@ -22,7 +22,11 @@ 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 noop_context_manager, start_active_span
from synapse.logging.opentracing import (
SynapseTags,
noop_context_manager,
start_active_span,
)
from synapse.util.async_helpers import maybe_awaitable
if TYPE_CHECKING:
@ -202,7 +206,9 @@ def run_as_background_process(desc: str, func, *args, bg_start_span=True, **kwar
try:
ctx = noop_context_manager()
if bg_start_span:
ctx = start_active_span(desc, tags={"request_id": str(context)})
ctx = start_active_span(
desc, tags={SynapseTags.REQUEST_ID: str(context)}
)
with ctx:
return await maybe_awaitable(func(*args, **kwargs))
except Exception: