Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix opentracing and Prometheus metrics for replication requests #10996

Merged
merged 5 commits into from
Oct 12, 2021

Commits on Oct 5, 2021

  1. Fix opentracing and Prometheus metrics for replication requests

    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.
    Sean Quah committed Oct 5, 2021
    Configuration menu
    Copy the full SHA
    53d3650 View commit details
    Browse the repository at this point in the history

Commits on Oct 6, 2021

  1. Log an error when @trace does not work correctly

    Sean Quah committed Oct 6, 2021
    Configuration menu
    Copy the full SHA
    bc60c6d View commit details
    Browse the repository at this point in the history
  2. Assert instead of logging an error

    Sean Quah committed Oct 6, 2021
    Configuration menu
    Copy the full SHA
    af7fda0 View commit details
    Browse the repository at this point in the history
  3. Revert "Assert instead of logging an error"

    This reverts commit af7fda0.
    Sean Quah committed Oct 6, 2021
    Configuration menu
    Copy the full SHA
    0d71a85 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    255820c View commit details
    Browse the repository at this point in the history