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

Commit a5a7997

Browse files
author
David Robertson
authored
Tag federation request spans with the worker name (#15042)
* Systematically include worker name as process info * Changelog * don't bother with inner setdefault
1 parent 03bccd5 commit a5a7997

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

changelog.d/15042.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Tag opentracing spans for federation requests with the name of the worker serving the request.

synapse/api/auth.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
from synapse.http import get_request_user_agent
3333
from synapse.http.site import SynapseRequest
3434
from synapse.logging.opentracing import (
35-
SynapseTags,
3635
active_span,
3736
force_tracing,
3837
start_active_span,
@@ -162,12 +161,6 @@ async def get_user_by_req(
162161
parent_span.set_tag(
163162
"authenticated_entity", requester.authenticated_entity
164163
)
165-
# We tag the Synapse instance name so that it's an easy jumping
166-
# off point into the logs. Can also be used to filter for an
167-
# instance that is under load.
168-
parent_span.set_tag(
169-
SynapseTags.INSTANCE_NAME, self.hs.get_instance_name()
170-
)
171164
parent_span.set_tag("user_id", requester.user.to_string())
172165
if requester.device_id is not None:
173166
parent_span.set_tag("device_id", requester.device_id)

synapse/logging/opentracing.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,16 @@ def init_tracer(hs: "HomeServer") -> None:
466466
STRIP_INSTANCE_NUMBER_SUFFIX_REGEX, "", hs.get_instance_name()
467467
)
468468

469+
jaeger_config = hs.config.tracing.jaeger_config
470+
tags = jaeger_config.setdefault("tags", {})
471+
472+
# tag the Synapse instance name so that it's an easy jumping
473+
# off point into the logs. Can also be used to filter for an
474+
# instance that is under load.
475+
tags[SynapseTags.INSTANCE_NAME] = hs.get_instance_name()
476+
469477
config = JaegerConfig(
470-
config=hs.config.tracing.jaeger_config,
478+
config=jaeger_config,
471479
service_name=f"{hs.config.server.server_name} {instance_name_by_type}",
472480
scope_manager=LogContextScopeManager(),
473481
metrics_factory=PrometheusMetricsFactory(),

0 commit comments

Comments
 (0)