summary refs log tree commit diff
path: root/synapse/http/site.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2018-05-09 23:00:11 +0100
committerRichard van der Hoff <richard@matrix.org>2018-05-10 11:48:17 +0100
commit8460e48d0639a7f575fd3e57dcd5cf263a6d6a19 (patch)
tree3a64c436ec80d1e03c738df9393e3dbd436216ad /synapse/http/site.py
parentMove RequestsMetrics to its own file (diff)
downloadsynapse-8460e48d0639a7f575fd3e57dcd5cf263a6d6a19.tar.xz
Move request_id management into SynapseRequest
Diffstat (limited to 'synapse/http/site.py')
-rw-r--r--synapse/http/site.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/synapse/http/site.py b/synapse/http/site.py
index c8b46e1af2..6af276e69a 100644
--- a/synapse/http/site.py
+++ b/synapse/http/site.py
@@ -22,6 +22,8 @@ import time
 
 ACCESS_TOKEN_RE = re.compile(br'(\?.*access(_|%5[Ff])token=)[^&]*(.*)$')
 
+_next_request_seq = 0
+
 
 class SynapseRequest(Request):
     def __init__(self, site, *args, **kw):
@@ -30,6 +32,10 @@ class SynapseRequest(Request):
         self.authenticated_entity = None
         self.start_time = 0
 
+        global _next_request_seq
+        self.request_seq = _next_request_seq
+        _next_request_seq += 1
+
     def __repr__(self):
         # We overwrite this so that we don't log ``access_token``
         return '<%s at 0x%x method=%s uri=%s clientproto=%s site=%s>' % (
@@ -41,6 +47,9 @@ class SynapseRequest(Request):
             self.site.site_tag,
         )
 
+    def get_request_id(self):
+        return "%s-%i" % (self.method, self.request_seq)
+
     def get_redacted_uri(self):
         return ACCESS_TOKEN_RE.sub(
             br'\1<redacted>\3',