mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 23:34:56 -04:00
Improve opentracing support for ResponseCache
(#11607)
This adds some opentracing annotations to ResponseCache, to make it easier to see what's going on; in particular, it adds a link back to the initial trace which is actually doing the work of generating the response.
This commit is contained in:
parent
60fa4935b5
commit
c3e38b88f2
5 changed files with 150 additions and 49 deletions
|
@ -13,6 +13,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import abc
|
||||
import collections
|
||||
import inspect
|
||||
import itertools
|
||||
|
@ -57,7 +58,26 @@ logger = logging.getLogger(__name__)
|
|||
_T = TypeVar("_T")
|
||||
|
||||
|
||||
class ObservableDeferred(Generic[_T]):
|
||||
class AbstractObservableDeferred(Generic[_T], metaclass=abc.ABCMeta):
|
||||
"""Abstract base class defining the consumer interface of ObservableDeferred"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
@abc.abstractmethod
|
||||
def observe(self) -> "defer.Deferred[_T]":
|
||||
"""Add a new observer for this ObservableDeferred
|
||||
|
||||
This returns a brand new deferred that is resolved when the underlying
|
||||
deferred is resolved. Interacting with the returned deferred does not
|
||||
effect the underlying deferred.
|
||||
|
||||
Note that the returned Deferred doesn't follow the Synapse logcontext rules -
|
||||
you will probably want to `make_deferred_yieldable` it.
|
||||
"""
|
||||
...
|
||||
|
||||
|
||||
class ObservableDeferred(Generic[_T], AbstractObservableDeferred[_T]):
|
||||
"""Wraps a deferred object so that we can add observer deferreds. These
|
||||
observer deferreds do not affect the callback chain of the original
|
||||
deferred.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue