diff options
author | Hubert Chathi <hubert@uhoreg.ca> | 2019-09-07 13:14:45 -0400 |
---|---|---|
committer | Hubert Chathi <hubert@uhoreg.ca> | 2019-09-07 13:14:45 -0400 |
commit | 0d61d1d7351a8d2e2512dbcaf149e1f19f2271ec (patch) | |
tree | 9dccb1711608f8c0b3a6dcd22eaa6f100c7a4e17 /synapse/http/server.py | |
parent | use something that's the right type for user_id (diff) | |
parent | Servers-known-about statistic (#5981) (diff) | |
download | synapse-0d61d1d7351a8d2e2512dbcaf149e1f19f2271ec.tar.xz |
Merge branch 'develop' into cross-signing_sig_upload
Diffstat (limited to 'synapse/http/server.py')
-rw-r--r-- | synapse/http/server.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/synapse/http/server.py b/synapse/http/server.py index e6f351ba3b..cb9158fe1b 100644 --- a/synapse/http/server.py +++ b/synapse/http/server.py @@ -40,6 +40,7 @@ from synapse.api.errors import ( UnrecognizedRequestError, ) from synapse.logging.context import preserve_fn +from synapse.logging.opentracing import trace_servlet from synapse.util.caches import intern_dict logger = logging.getLogger(__name__) @@ -257,7 +258,9 @@ class JsonResource(HttpServer, resource.Resource): self.path_regexs = {} self.hs = hs - def register_paths(self, method, path_patterns, callback, servlet_classname): + def register_paths( + self, method, path_patterns, callback, servlet_classname, trace=True + ): """ Registers a request handler against a regular expression. Later request URLs are checked against these regular expressions in order to identify an appropriate @@ -273,8 +276,16 @@ class JsonResource(HttpServer, resource.Resource): servlet_classname (str): The name of the handler to be used in prometheus and opentracing logs. + + trace (bool): Whether we should start a span to trace the servlet. """ method = method.encode("utf-8") # method is bytes on py3 + + if trace: + # We don't extract the context from the servlet because we can't + # trust the sender + callback = trace_servlet(servlet_classname)(callback) + for path_pattern in path_patterns: logger.debug("Registering for %s %s", method, path_pattern.pattern) self.path_regexs.setdefault(method, []).append( |