def call_downstream_http(self, span, downstream): url = 'http://%s:%s/join_trace' % (downstream.host, downstream.port) body = serializer.join_trace_request_to_json(downstream.downstream, downstream.serverRole) req = tornado.httpclient.HTTPRequest(url=url, method='POST', headers={'Content-Type': 'application/json'}, body=body) http_client.before_http_request(tornado_http.TornadoRequestWrapper(request=req), lambda: span) client = tornado.httpclient.AsyncHTTPClient() http_result = yield client.fetch(req) raise tornado.gen.Return(serializer.traceresponse_from_json(http_result.body))
def do_open(self, req, conn): request_wrapper = Urllib2RequestWrapper(request=req) span = before_http_request( request=request_wrapper, current_span_extractor=get_current_span) with span: resp = urllib2.AbstractHTTPHandler.do_open(self, conn, req) if resp.code is not None: span.set_tag('status_code', resp.code) return resp
def do_open(self, req, conn): request_wrapper = Urllib2RequestWrapper(request=req) span = before_http_request( request=request_wrapper, current_span_extractor=get_current_span) with span: resp = urllib2.AbstractHTTPHandler.do_open(self, conn, req) if resp.code is not None: span.set_tag('http.status_code', resp.code) return resp
def call_downstream_http(self, span, trace_request, trace_response, response_writer): def handle_response(response): tr = serializer.traceresponse_from_json(response.body) if tr.notImplementedError: response_writer.write(serializer.obj_to_json(tr)) else: trace_response.downstream = tr response_writer.write(serializer.obj_to_json(trace_response)) response_writer.finish() downstream = trace_request.downstream url = "http://%s:%s/join_trace" % (downstream.host, downstream.port) body = serializer.downstream_to_json(downstream.downstream) req = tornado.httpclient.HTTPRequest(url=url, method="POST", headers={"Content-Type": "application/json"}, body=body) http_client.before_http_request(tornado_http.TornadoRequestWrapper(request=req), lambda: span) client = tornado.httpclient.AsyncHTTPClient() client.fetch(req, handle_response)
def do_open(self, req, conn): request_wrapper = Urllib2RequestWrapper(request=req) span = before_http_request( request=request_wrapper, current_span_extractor=get_current_span) with span: if base_cls: # urllib2.AbstractHTTPHandler doesn't support super() resp = base_cls.do_open(self, conn, req) else: resp = super(DerivedHandler, self).do_open(conn, req) if resp.code is not None: span.set_tag('http.status_code', resp.code) return resp
def new_fetch_impl(self, request, callback): request_wrapper = TornadoRequestWrapper(request=request) span = before_http_request(request=request_wrapper, current_span_extractor=get_current_span) def new_callback(response): if hasattr(response, 'code') and response.code: span.set_tag('http.status_code', '%s' % response.code) if hasattr(response, 'error') and response.error: span.log(event='error', payload='%s' % response.error) span.finish() return callback(response) real_fetch_impl(self, request, new_callback)