summary refs log tree commit diff
path: root/synapse/logging/tracing.py
diff options
context:
space:
mode:
authorEric Eastwood <erice@element.io>2022-09-09 16:28:05 -0500
committerEric Eastwood <erice@element.io>2022-09-09 16:28:05 -0500
commit50f0342594977a57793225d8f6b95e1225dfe308 (patch)
treebb8c94e3316a8623780d37a98e1f55aa2bc19c4a /synapse/logging/tracing.py
parentMerge branch 'develop' into madlittlemods/11850-migrate-to-opentelemetry (diff)
parentConcurrently collect room unread counts for push badges (#13765) (diff)
downloadsynapse-50f0342594977a57793225d8f6b95e1225dfe308.tar.xz
Merge branch 'develop' into madlittlemods/11850-migrate-to-opentelemetry
Conflicts:
	poetry.lock
	synapse/api/auth.py
	synapse/federation/federation_client.py
	synapse/logging/opentracing.py
	synapse/rest/client/keys.py
	synapse/rest/client/sendtodevice.py
	synapse/storage/schema/__init__.py
Diffstat (limited to 'synapse/logging/tracing.py')
-rw-r--r--synapse/logging/tracing.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/synapse/logging/tracing.py b/synapse/logging/tracing.py

index a250bbb204..2fe9875398 100644 --- a/synapse/logging/tracing.py +++ b/synapse/logging/tracing.py
@@ -199,6 +199,9 @@ if TYPE_CHECKING: T = TypeVar("T") +# Matches the number suffix in an instance name like "matrix.org client_reader-8" +STRIP_INSTANCE_NUMBER_SUFFIX_REGEX = re.compile(r"[_-]?\d+$") + class _DummyLookup(object): """This will always returns the fixed value given for any accessed property""" @@ -265,6 +268,9 @@ class SynapseTags: # Whether the sync response has new data to be returned to the client. SYNC_RESULT = "sync.new_data" + # The Synapse instance name + INSTANCE_NAME = "instance_name" + # incoming HTTP request ID (as written in the logs) REQUEST_ID = "request_id" @@ -400,9 +406,17 @@ def init_tracer(hs: "HomeServer") -> None: # Pull out of the config if it was given. Otherwise set it to something sensible. set_homeserver_whitelist(hs.config.tracing.homeserver_whitelist) + # Instance names are opaque strings but by stripping off the number suffix, + # we can get something that looks like a "worker type", e.g. + # "client_reader-1" -> "client_reader" so we don't spread the traces across + # so many services. + instance_name_by_type = re.sub( + STRIP_INSTANCE_NUMBER_SUFFIX_REGEX, "", hs.get_instance_name() + ) + resource = opentelemetry.sdk.resources.Resource( attributes={ - opentelemetry.sdk.resources.SERVICE_NAME: f"{hs.config.server.server_name} {hs.get_instance_name()}" + opentelemetry.sdk.resources.SERVICE_NAME: f"{hs.config.server.server_name} {instance_name_by_type}" } )