summary refs log tree commit diff
path: root/synapse/util/logcontext.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Improve exception handling for background processesRichard van der Hoff2018-04-271-1/+6
| | | | | | | | | | | | | | | | | | There were a bunch of places where we fire off a process to happen in the background, but don't have any exception handling on it - instead relying on the unhandled error being logged when the relevent deferred gets garbage-collected. This is unsatisfactory for a number of reasons: - logging on garbage collection is best-effort and may happen some time after the error, if at all - it can be hard to figure out where the error actually happened. - it is logged as a scary CRITICAL error which (a) I always forget to grep for and (b) it's not really CRITICAL if a background process we don't care about fails. So this is an attempt to add exception handling to everything we fire off into the background.
* add __bool__ alias to __nonzero__ methodsAdrian Tschira2018-04-151-0/+1
| | | | Signed-off-by: Adrian Tschira <nota@notafile.com>
* Factor run_in_background out from preserve_fnRichard van der Hoff2018-03-081-24/+29
| | | | | It annoys me that we create temporary function objects when there's really no need for it. Let's factor the gubbins out of preserve_fn and start using it.
* Rewrite make_deferred_yieldable avoiding inlineCallbacksRichard van der Hoff2018-03-011-9/+11
| | | | | ... because (a) it's actually simpler (b) it might be marginally more performant?
* Track DB scheduling delay per-requestRichard van der Hoff2018-01-161-1/+17
| | | | | | 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/+6
| | | | ... to reduce the amount of floating-point foo we do.
* Optimise LoggingContext creation and copyingRichard van der Hoff2018-01-161-7/+18
| | | | | | | | It turns out that the only thing we use the __dict__ of LoggingContext for is `request`, and given we create lots of LoggingContexts and then copy them every time we do a db transaction or log line, using the __dict__ seems a bit redundant. Let's try to optimise things by making the request attribute explicit.
* Remove __PreservingContextDeferred tooRichard van der Hoff2017-11-141-30/+0
|
* Remove preserve_context_over_{fn, deferred}Richard van der Hoff2017-11-141-31/+0
| | | | | Both of these functions ae known to leak logcontexts. Replace the remaining calls to them and kill them off.
* replace 'except:' with 'except Exception:'Richard van der Hoff2017-10-231-1/+1
| | | | what could possibly go wrong
* Fix fixme in preserve_fnRichard van der Hoff2017-04-031-5/+1
| | | | | `preserve_fn` is no longer used as a decorator anywhere, so we can safely fix a fixme therein.
* Fix the logcontext handling in the cache wrappers (#2077)Richard van der Hoff2017-03-301-0/+23
| | | | | | | The cache wrappers had a habit of leaking the logcontext into the reactor while the lookup function was running, and then not restoring it correctly when the lookup function had completed. It's all the fault of `preserve_context_over_{fn,deferred}` which are basically a bit broken.
* Merge pull request #2026 from matrix-org/rav/logcontext_docsRichard van der Hoff2017-03-201-0/+10
|\ | | | | Logcontext docs
| * Logcontext docsRichard van der Hoff2017-03-171-0/+10
| |
* | Stop preserve_fn leaking context into the reactorRichard van der Hoff2017-03-181-32/+29
|/ | | | | | | | Fix a bug in ``logcontext.preserve_fn`` which made it leak context into the reactor, and add a test for it. Also, get rid of ``logcontext.reset_context_after_deferred``, which tried to do the same thing but had its own, different, set of bugs.
* Implement reset_context_after_deferredRichard van der Hoff2017-03-151-0/+25
| | | | | to correctly reset the context when we fire off a deferred we aren't going to wait for.
* Preserve some logcontextsErik Johnston2016-08-241-4/+11
|
* Clean up TransactionQueueErik Johnston2016-08-101-1/+0
|
* Remove commentErik Johnston2016-02-101-1/+1
|
* s/parent_context/previous_context/Erik Johnston2016-02-101-9/+9
|
* Set parent context on instansiationErik Johnston2016-02-101-2/+7
|
* Don't bother copying records on parent contextErik Johnston2016-02-091-8/+0
|
* Change logcontext warns to debugErik Johnston2016-02-091-3/+3
|
* Fix up logcontextsErik Johnston2016-02-081-4/+94
|
* Allowing tagging log contextsErik Johnston2016-02-031-1/+6
|
* copyrightsMatthew Hodgson2016-01-071-1/+1
|
* Track the time spent in the database per request.Mark Haines2015-12-071-0/+9
| | | | and track the number of transactions that request started.
* Add a setter for the current log context.Mark Haines2015-12-071-16/+24
| | | | | | Move the resource tracking inside that setter so that it is easier to make sure that the resource tracking isn't double counting the resource usage.
* Add comments to explain why we are hardcoding RUSAGE_THREADMark Haines2015-12-041-0/+8
|
* Fix warningsMark Haines2015-12-041-2/+2
|
* Track the cpu used in the main thread by each logging contextMark Haines2015-12-031-6/+70
|
* Fix log context when sending requestsErik Johnston2015-06-191-19/+33
|
* Fix up leak. Add warnings.Erik Johnston2015-05-081-1/+10
|
* Add some docsErik Johnston2015-05-081-2/+14
|
* Change the way we do logging contexts so that they survive divergencesErik Johnston2015-05-081-0/+31
|
* Update copyright noticesMark Haines2015-01-061-0/+14
|
* Drop log level for incorrect logging contexts to WARN if the context is ↵Mark Haines2014-11-251-5/+8
| | | | wrong and DEBUG if the context is missing
* Use module loggers rather than the root logger. Exceptions caused by bad ↵Mark Haines2014-11-201-1/+3
| | | | clients shouldn't cause ERROR level logging. Fix sql logging to use 'repr' rather than 'str'
* Preserve logging context in a few more places, drop the logging context ↵Mark Haines2014-11-191-0/+4
| | | | after it has been stashed to reduce potential for confusion
* Pep8 and a few doc stringsMark Haines2014-10-301-14/+37
|
* Add a request-id to each log lineMark Haines2014-10-301-0/+85