synapse-old/synapse/logging
Sean Quah 6b18eb4430
Fix opentracing and Prometheus metrics for replication requests (#10996)
This commit fixes two bugs to do with decorators not instrumenting
`ReplicationEndpoint`'s `send_request` correctly. There are two
decorators on `send_request`: Prometheus' `Gauge.track_inprogress()`
and Synapse's `opentracing.trace`.

`Gauge.track_inprogress()` does not have any support for async
functions when used as a decorator. Since async functions behave like
regular functions that return coroutines, only the creation of the
coroutine was covered by the metric and none of the actual body of
`send_request`.

`Gauge.track_inprogress()` returns a regular, non-async function
wrapping `send_request`, which is the source of the next bug.
The `opentracing.trace` decorator would normally handle async functions
correctly, but since the wrapped `send_request` is a non-async function,
the decorator ends up suffering from the same issue as
`Gauge.track_inprogress()`: the opentracing span only measures the
creation of the coroutine and none of the actual function body.

Using `Gauge.track_inprogress()` as a context manager instead of a
decorator resolves both bugs.
2021-10-12 11:23:46 +01:00
..
__init__.py Add debug logging for issue #9533 (#9959) 2021-05-11 11:04:03 +01:00
_remote.py Use inline type hints in various other places (in `synapse/`) (#10380) 2021-07-15 11:02:43 +01:00
_structured.py Use inline type hints in various other places (in `synapse/`) (#10380) 2021-07-15 11:02:43 +01:00
_terse_json.py Include exception in json logging (#11028) 2021-10-08 13:08:25 +02:00
context.py Relax `ignore-missing-imports` for modules that have stubs now and update mypy (#11006) 2021-10-08 14:49:41 +01:00
filter.py Remove redundant "coding: utf-8" lines (#9786) 2021-04-14 15:34:27 +01:00
formatter.py Remove redundant "coding: utf-8" lines (#9786) 2021-04-14 15:34:27 +01:00
handlers.py Fix PeriodicallyFlushingMemoryHandler inhibiting application shutdown (#10517) 2021-08-03 14:28:30 +01:00
opentracing.py Fix opentracing and Prometheus metrics for replication requests (#10996) 2021-10-12 11:23:46 +01:00
scopecontextmanager.py Remove redundant "coding: utf-8" lines (#9786) 2021-04-14 15:34:27 +01:00
utils.py Remove redundant "coding: utf-8" lines (#9786) 2021-04-14 15:34:27 +01:00