summary refs log tree commit diff
path: root/synapse/http/site.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Move logging utilities out of the side drawer of util/ and into logging/ (#5606)Amber Brown2019-07-041-1/+1
|
* Run Black. (#5482)Amber Brown2019-06-201-17/+31
|
* Fix error when logging incomplete requestsErik Johnston2018-10-021-6/+21
| | | | | | | | | | If a connection is lost before a request is read from Request, Twisted sets `method` (and `uri`) attributes to dummy values. These dummy values have incorrect types (i.e. they're not bytes), and so things like `__repr__` would raise an exception. To fix this we had a helper method to return the method with a consistent type.
* Fix client IPs being broken on Python 3 (#3908)Amber Brown2018-09-201-1/+1
|
* Add a regression test for logging on failed connections (#3912)Amber Brown2018-09-201-2/+2
|
* Fix more b'abcd' noise in metricsRichard van der Hoff2018-09-171-1/+1
|
* Fix some b'abcd' noise in logs and metricsRichard van der Hoff2018-09-171-4/+4
| | | | | Python 3 compatibility: make sure that we decode some byte sequences before we use them to create log lines and metrics labels.
* fixAmber Brown2018-09-141-1/+4
|
* fixAmber Brown2018-09-141-1/+1
|
* Port http/ to Python 3 (#3771)Amber Brown2018-09-061-2/+2
|
* Fix exceptions when a connection is closed before we read the headersRichard van der Hoff2018-08-201-1/+7
| | | | | This fixes bugs introduced in #3700, by making sure that we behave sanely when an incoming connection is closed before the headers are read.
* Port over enough to get some sytests running on Python 3 (#3668)Amber Brown2018-08-201-2/+2
|
* Refactor request logging codeRichard van der Hoff2018-08-151-45/+156
| | | | | | | | | | | | | | | This commit moves a bunch of the logic for deciding when to log the receipt and completion of HTTP requests into SynapseRequest, rather than in the request handling wrappers. Advantages of this are: * we get logs for *all* requests (including OPTIONS and HEADs), rather than just those that end up hitting handlers we've remembered to decorate correctly. * when a request handler wires up a Producer (as the media stuff does currently, and as other things will do soon), we log at the point that all of the traffic has been sent to the client.
* Refactor REST API tests to use explicit reactors (#3351)Amber Brown2018-07-171-2/+3
|
* check isort by travisKrombel2018-07-161-1/+1
|
* Refactor logcontext resource usage tracking (#3501)Richard van der Hoff2018-07-101-15/+9
| | | | | Factor out the resource usage tracking out to a separate object, which can be passed around and copied independently of the logcontext itself.
* run isortAmber Brown2018-07-091-1/+1
|
* replace invalid utf8 with \ufffdMatthew Hodgson2018-07-021-2/+2
|
* a fix which doesn't NPE everywhereMatthew Hodgson2018-07-011-9/+17
|
* don't mix unicode strings with utf8-in-byte-stringsMatthew Hodgson2018-07-011-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | otherwise we explode with: ``` Traceback (most recent call last): File /usr/lib/python2.7/logging/handlers.py, line 78, in emit logging.FileHandler.emit(self, record) File /usr/lib/python2.7/logging/__init__.py, line 950, in emit StreamHandler.emit(self, record) File /usr/lib/python2.7/logging/__init__.py, line 887, in emit self.handleError(record) File /usr/lib/python2.7/logging/__init__.py, line 810, in handleError None, sys.stderr) File /usr/lib/python2.7/traceback.py, line 124, in print_exception _print(file, 'Traceback (most recent call last):') File /usr/lib/python2.7/traceback.py, line 13, in _print file.write(str+terminator) File /home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/logger/_io.py, line 170, in write self.log.emit(self.level, format=u{log_io}, log_io=line) File /home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/logger/_logger.py, line 144, in emit self.observer(event) File /home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/logger/_observer.py, line 136, in __call__ errorLogger = self._errorLoggerForObserver(brokenObserver) File /home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/logger/_observer.py, line 156, in _errorLoggerForObserver if obs is not observer File /home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/logger/_observer.py, line 81, in __init__ self.log = Logger(observer=self) File /home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/logger/_logger.py, line 64, in __init__ namespace = self._namespaceFromCallingContext() File /home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/logger/_logger.py, line 42, in _namespaceFromCallingContext return currentframe(2).f_globals[__name__] File /home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/python/compat.py, line 93, in currentframe for x in range(n + 1): RuntimeError: maximum recursion depth exceeded while calling a Python object Logged from file site.py, line 129 File /usr/lib/python2.7/logging/__init__.py, line 859, in emit msg = self.format(record) File /usr/lib/python2.7/logging/__init__.py, line 732, in format return fmt.format(record) File /usr/lib/python2.7/logging/__init__.py, line 471, in format record.message = record.getMessage() File /usr/lib/python2.7/logging/__init__.py, line 335, in getMessage msg = msg % self.args UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 4: ordinal not in range(128) Logged from file site.py, line 129 ``` ...where the logger apparently recurses whilst trying to log the error, hitting the maximum recursion depth and killing everything badly.
* Log number of events fetched from DBRichard van der Hoff2018-06-211-1/+4
| | | | | | | | | | When we finish processing a request, log the number of events we fetched from the database to handle it. [I'm trying to figure out which requests are responsible for large amounts of event cache churn. It may turn out to be more helpful to add counts to the prometheus per-request/block metrics, but that is an extension to this code anyway.]
* factor out uri redaction into a method on httpMichael Telatynski2018-06-051-7/+2
|
* update metrics to be in secondsAmber Brown2018-05-281-10/+10
|
* Merge pull request #3246 from NotAFile/py3-repr-stringAmber Brown2018-05-241-1/+1
|\ | | | | use repr, not str
| * use repr, not strAdrian Tschira2018-05-191-1/+1
| | | | | | | | Signed-off-by: Adrian Tschira <nota@notafile.com>
* | Add in flight request metricsErik Johnston2018-05-211-1/+3
|/ | | | | This tracks CPU and DB usage while requests are in flight, rather than when we write the response.
* Set Server header in SynapseRequestRichard van der Hoff2018-05-101-1/+10
| | | | | | | | | | | | (instead of everywhere that writes a response. Or rather, the subset of places which write responses where we haven't forgotten it). This also means that we don't have to have the mysterious version_string attribute in anything with a request handler. Unfortunately it does mean that we have to pass the version string wherever we instantiate a SynapseSite, which has been c&ped 150 times, but that is code that ought to be cleaned up anyway really.
* Move RequestMetrics handling into SynapseRequest.processing()Richard van der Hoff2018-05-101-11/+58
| | | | | It fits quite nicely here, and opens the path to getting rid of the "include_metrics" mess.
* Move request_id management into SynapseRequestRichard van der Hoff2018-05-101-0/+9
|
* Add b prefixes to some strings that are bytes in py3Adrian Tschira2018-04-041-3/+3
| | | | | | This has no effect on python2 Signed-off-by: Adrian Tschira <nota@notafile.com>
* Track DB scheduling delay per-requestRichard van der Hoff2018-01-161-1/+3
| | | | | | For each request, track the amount of time spent waiting for a db connection. This entails adding it to the LoggingContext and we may as well add metrics for it while we are passing.
* Track db txn time in millisecsRichard van der Hoff2018-01-161-3/+3
| | | | ... to reduce the amount of floating-point foo we do.
* replace 'except:' with 'except Exception:'Richard van der Hoff2017-10-231-1/+1
| | | | what could possibly go wrong
* Move SynapseSite to its own fileMark Haines2016-04-221-0/+146