synapse/tests/http
Eric Eastwood 5a9ca1e3d9
Introduce Clock.call_when_running(...) to include logcontext by default (#18944)
Introduce `Clock.call_when_running(...)` to wrap startup code in a
logcontext, ensuring we can identify which server generated the logs.

Background:

>  Ideally, nothing from the Synapse homeserver would be logged against the `sentinel` 
>  logcontext as we want to know which server the logs came from. In practice, this is not 
>  always the case yet especially outside of request handling. 
>   
>  Global things outside of Synapse (e.g. Twisted reactor code) should run in the 
>  `sentinel` logcontext. It's only when it calls into application code that a logcontext 
>  gets activated. This means the reactor should be started in the `sentinel` logcontext, 
>  and any time an awaitable yields control back to the reactor, it should reset the 
>  logcontext to be the `sentinel` logcontext. This is important to avoid leaking the 
>  current logcontext to the reactor (which would then get picked up and associated with 
>  the next thing the reactor does). 
>
> *-- `docs/log_contexts.md`

Also adds a lint to prefer `Clock.call_when_running(...)` over
`reactor.callWhenRunning(...)`

Part of https://github.com/element-hq/synapse/issues/18905
2025-09-22 10:27:59 -05:00
..
federation Configure HTTP proxy in file config (#18686) 2025-07-22 10:33:00 -05:00
server Use twisted.internet.testing module in tests instead of deprecated twisted.test.proto_helpers. (#18728) 2025-07-30 12:32:10 +01:00
__init__.py Update license headers 2023-11-21 15:29:58 -05:00
ca.crt Tests for SSL certs for federation connections 2019-06-10 16:14:20 +01:00
ca.key Tests for SSL certs for federation connections 2019-06-10 16:14:20 +01:00
server.key Tests for SSL certs for federation connections 2019-06-10 16:14:20 +01:00
test_additional_resource.py Update license headers 2023-11-21 15:29:58 -05:00
test_client.py Use twisted.internet.testing module in tests instead of deprecated twisted.test.proto_helpers. (#18728) 2025-07-30 12:32:10 +01:00
test_endpoint.py Update license headers 2023-11-21 15:29:58 -05:00
test_matrixfederationclient.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_proxy.py Remove usage of internal header encoding API (#17894) 2024-11-04 12:20:07 -06:00
test_proxyagent.py Configure HTTP proxy in file config (#18686) 2025-07-22 10:33:00 -05:00
test_servlet.py Format files with Ruff (#17643) 2024-09-02 12:39:04 +01:00
test_simple_client.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00
test_site.py Introduce Clock.call_when_running(...) to include logcontext by default (#18944) 2025-09-22 10:27:59 -05:00