From 9df947488df7a11b701f456b43285a5cab5f36b4 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Thu, 9 Feb 2023 18:47:15 +0000 Subject: [PATCH 1/3] Systematically include worker name as process info --- synapse/api/auth.py | 7 ------- synapse/logging/opentracing.py | 10 +++++++++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/synapse/api/auth.py b/synapse/api/auth.py index 3d7f986ac74a..66e869bc2db2 100644 --- a/synapse/api/auth.py +++ b/synapse/api/auth.py @@ -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, @@ -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) diff --git a/synapse/logging/opentracing.py b/synapse/logging/opentracing.py index 8ef9a0dda8e5..a2f8dc965377 100644 --- a/synapse/logging/opentracing.py +++ b/synapse/logging/opentracing.py @@ -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.setdefault(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(), From 9be0fa3b8e654625b643ba3b305b8b7a03571b45 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Thu, 9 Feb 2023 17:58:12 +0000 Subject: [PATCH 2/3] Changelog --- changelog.d/15042.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/15042.feature diff --git a/changelog.d/15042.feature b/changelog.d/15042.feature new file mode 100644 index 000000000000..7a4de89f0070 --- /dev/null +++ b/changelog.d/15042.feature @@ -0,0 +1 @@ +Tag opentracing spans for federation requests with the name of the worker serving the request. From b4980b4f6cfc1fc8be84250e254911194fc12ea3 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Thu, 9 Feb 2023 21:54:10 +0000 Subject: [PATCH 3/3] don't bother with inner setdefault --- synapse/logging/opentracing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/logging/opentracing.py b/synapse/logging/opentracing.py index a2f8dc965377..6c7cf1b29487 100644 --- a/synapse/logging/opentracing.py +++ b/synapse/logging/opentracing.py @@ -472,7 +472,7 @@ def init_tracer(hs: "HomeServer") -> None: # 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.setdefault(SynapseTags.INSTANCE_NAME, hs.get_instance_name()) + tags[SynapseTags.INSTANCE_NAME] = hs.get_instance_name() config = JaegerConfig( config=jaeger_config,