This repository was archived by the owner on Apr 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change
1
+ Tag traces with the instance name to be able to easily jump into the right logs and filter traces by instance.
Original file line number Diff line number Diff line change 32
32
from synapse .http import get_request_user_agent
33
33
from synapse .http .site import SynapseRequest
34
34
from synapse .logging .opentracing import (
35
+ SynapseTags ,
35
36
active_span ,
36
37
force_tracing ,
37
38
start_active_span ,
@@ -161,6 +162,12 @@ async def get_user_by_req(
161
162
parent_span .set_tag (
162
163
"authenticated_entity" , requester .authenticated_entity
163
164
)
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
+ )
164
171
parent_span .set_tag ("user_id" , requester .user .to_string ())
165
172
if requester .device_id is not None :
166
173
parent_span .set_tag ("device_id" , requester .device_id )
Original file line number Diff line number Diff line change @@ -298,6 +298,8 @@ class SynapseTags:
298
298
# Whether the sync response has new data to be returned to the client.
299
299
SYNC_RESULT = "sync.new_data"
300
300
301
+ INSTANCE_NAME = "instance_name"
302
+
301
303
# incoming HTTP request ID (as written in the logs)
302
304
REQUEST_ID = "request_id"
303
305
@@ -1043,11 +1045,11 @@ def trace_servlet(
1043
1045
# with JsonResource).
1044
1046
scope .span .set_operation_name (request .request_metrics .name )
1045
1047
1046
- # set the tags *after* the servlet completes, in case it decided to
1047
- # prioritise the span (tags will get dropped on unprioritised spans)
1048
1048
request_tags [
1049
1049
SynapseTags .REQUEST_TAG
1050
1050
] = request .request_metrics .start_context .tag
1051
1051
1052
+ # set the tags *after* the servlet completes, in case it decided to
1053
+ # prioritise the span (tags will get dropped on unprioritised spans)
1052
1054
for k , v in request_tags .items ():
1053
1055
scope .span .set_tag (k , v )
You can’t perform that action at this time.
0 commit comments