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

Commit f694bb7

Browse files
Strip number suffix from instance name to consolidate services that traces are spread over (#13729)
The problem with many services is that it makes it hard to find which service has the trace you want, see jaegertracing/jaeger-ui#985 Previously, we split traces out into services based on their instance name like `matrix.org client_reader-1`, etc but there are many worker instances of the same `client_reader` so there is a lot to click through. With this PR, all of the traces are just collected under the worker type like `client_reader`, `event_persister` 😇 Note: A Synapse worker instance name is an opaque string with the number convention only being our own thing for the `matrix.org` deployment. But seems pretty sensible to group things this way.
1 parent 3d9f82e commit f694bb7

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

changelog.d/13729.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Strip number suffix from instance name to consolidate services that traces are spread over.

synapse/logging/opentracing.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ def set_fates(clotho, lachesis, atropos, father="Zues", mother="Themis"):
203203

204204
# Helper class
205205

206+
# Matches the number suffix in an instance name like "matrix.org client_reader-8"
207+
STRIP_INSTANCE_NUMBER_SUFFIX_REGEX = re.compile(r"[_-]?\d+$")
208+
206209

207210
class _DummyTagNames:
208211
"""wrapper of opentracings tags. We need to have them if we
@@ -441,9 +444,17 @@ def init_tracer(hs: "HomeServer") -> None:
441444

442445
from jaeger_client.metrics.prometheus import PrometheusMetricsFactory
443446

447+
# Instance names are opaque strings but by stripping off the number suffix,
448+
# we can get something that looks like a "worker type", e.g.
449+
# "client_reader-1" -> "client_reader" so we don't spread the traces across
450+
# so many services.
451+
instance_name_by_type = re.sub(
452+
STRIP_INSTANCE_NUMBER_SUFFIX_REGEX, "", hs.get_instance_name()
453+
)
454+
444455
config = JaegerConfig(
445456
config=hs.config.tracing.jaeger_config,
446-
service_name=f"{hs.config.server.server_name} {hs.get_instance_name()}",
457+
service_name=f"{hs.config.server.server_name} {instance_name_by_type}",
447458
scope_manager=LogContextScopeManager(),
448459
metrics_factory=PrometheusMetricsFactory(),
449460
)

0 commit comments

Comments
 (0)