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

Commit

Permalink
Tag federation request spans with the worker name (#15042)
Browse files Browse the repository at this point in the history
* Systematically include worker name as process info

* Changelog

* don't bother with inner setdefault
  • Loading branch information
David Robertson authored Feb 9, 2023
1 parent 03bccd5 commit a5a7997
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions changelog.d/15042.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Tag opentracing spans for federation requests with the name of the worker serving the request.
7 changes: 0 additions & 7 deletions synapse/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
from synapse.http import get_request_user_agent
from synapse.http.site import SynapseRequest
from synapse.logging.opentracing import (
SynapseTags,
active_span,
force_tracing,
start_active_span,
Expand Down Expand Up @@ -162,12 +161,6 @@ async def get_user_by_req(
parent_span.set_tag(
"authenticated_entity", requester.authenticated_entity
)
# We tag the Synapse instance name so that it's an easy jumping
# off point into the logs. Can also be used to filter for an
# instance that is under load.
parent_span.set_tag(
SynapseTags.INSTANCE_NAME, self.hs.get_instance_name()
)
parent_span.set_tag("user_id", requester.user.to_string())
if requester.device_id is not None:
parent_span.set_tag("device_id", requester.device_id)
Expand Down
10 changes: 9 additions & 1 deletion synapse/logging/opentracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,16 @@ def init_tracer(hs: "HomeServer") -> None:
STRIP_INSTANCE_NUMBER_SUFFIX_REGEX, "", hs.get_instance_name()
)

jaeger_config = hs.config.tracing.jaeger_config
tags = jaeger_config.setdefault("tags", {})

# tag the Synapse instance name so that it's an easy jumping
# off point into the logs. Can also be used to filter for an
# instance that is under load.
tags[SynapseTags.INSTANCE_NAME] = hs.get_instance_name()

config = JaegerConfig(
config=hs.config.tracing.jaeger_config,
config=jaeger_config,
service_name=f"{hs.config.server.server_name} {instance_name_by_type}",
scope_manager=LogContextScopeManager(),
metrics_factory=PrometheusMetricsFactory(),
Expand Down

0 comments on commit a5a7997

Please sign in to comment.