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

Commit

Permalink
Trace workers
Browse files Browse the repository at this point in the history
  • Loading branch information
JorikSchellekens committed Jul 25, 2019
1 parent 85924ac commit ffe256d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions synapse/replication/http/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
from six.moves import urllib

from twisted.internet import defer
from twisted.web.http_headers import Headers

import synapse.logging.opentracing as opentracing
from synapse.api.errors import (
CodeMessageException,
HttpResponseException,
Expand Down Expand Up @@ -165,8 +167,12 @@ def send_request(**kwargs):
# have a good idea that the request has either succeeded or failed on
# the master, and so whether we should clean up or not.
while True:
headers = Headers()
opentracing.inject_active_span_twisted_headers(
headers, None, check_destination=False
)
try:
result = yield request_func(uri, data)
result = yield request_func(uri, data, headers=headers)
break
except CodeMessageException as e:
if e.code != 504 or not cls.RETRY_ON_TIMEOUT:
Expand Down Expand Up @@ -205,7 +211,14 @@ def register(self, http_server):
args = "/".join("(?P<%s>[^/]+)" % (arg,) for arg in url_args)
pattern = re.compile("^/_synapse/replication/%s/%s$" % (self.NAME, args))

http_server.register_paths(method, [pattern], handler, self.__class__.__name__)
http_server.register_paths(
method,
[pattern],
opentracing.trace_servlet(self.__class__.__name__, extract_context=True)(
handler
),
self.__class__.__name__,
)

def _cached_handler(self, request, txn_id, **kwargs):
"""Called on new incoming requests when caching is enabled. Checks
Expand Down

0 comments on commit ffe256d

Please sign in to comment.