コード例 #1
0
 def send_host(self, connection, host):
     ret = self.__origin.send_host(self, connection, host)
     try:
         forward = self.trace.child_noref("subservice")
         connection.putheader('X-B3-TraceId', hex_str(forward.trace_id))
         connection.putheader('X-B3-SpanId', hex_str(forward.span_id))
         if forward.parent_span_id is not None:
             connection.putheader('X-B3-ParentSpanId',
                                  hex_str(forward.parent_span_id))
     finally:
         return ret
コード例 #2
0
ファイル: events.py プロジェクト: Gandi/python-zipkin
def task_send_handler(body, exchange, routing_key, headers, **kwargs):
    trace = local().current

    if not trace:
        logger.warn("No zipkin parent trace found, ignoring tracing task.")
        return

    forwarded_trace = trace.child_noref("subservice")
    headers["X-B3-TraceId"] = hex_str(forwarded_trace.trace_id)
    headers["X-B3-SpanId"] = hex_str(forwarded_trace.span_id)
    forwarded_trace.record(Annotation.client_send())

    if forwarded_trace.parent_span_id is not None:
        headers["X-B3-ParentSpanId"] = hex_str(forwarded_trace.parent_span_id)
コード例 #3
0
ファイル: events.py プロジェクト: hack-viet/python-zipkin
def pre_request(request):
    parent_trace = local().current
    if not parent_trace:
        return request

    request.trace = parent_trace.child("requests:%s %s" %
                                       (request.method, request.url))
    forwarded_trace = request.trace.child_noref("subservice")

    request.headers['X-B3-TraceId'] = hex_str(forwarded_trace.trace_id)
    request.headers['X-B3-SpanId'] = hex_str(forwarded_trace.span_id)
    if forwarded_trace.parent_span_id is not None:
        request.headers['X-B3-ParentSpanId'] = \
            hex_str(forwarded_trace.parent_span_id)

    request.trace.record(Annotation.string('http.method', request.method))
    request.trace.record(Annotation.string('http.url', request.url))
    request.trace.record(Annotation.string('span.kind', 'client'))
    request.trace.record(Annotation.server_recv())

    return request
コード例 #4
0
ファイル: events.py プロジェクト: Gandi/python-zipkin
def pre_request(request):
    parent_trace = local().current
    if not parent_trace:
        return request

    url = filter_url_path(request.url)
    request.trace = parent_trace.child("requests:%s %s" %
                                       (request.method, url))
    forwarded_trace = request.trace.child_noref("subservice")

    request.headers["X-B3-TraceId"] = hex_str(forwarded_trace.trace_id)
    request.headers["X-B3-SpanId"] = hex_str(forwarded_trace.span_id)
    if forwarded_trace.parent_span_id is not None:
        request.headers["X-B3-ParentSpanId"] = hex_str(
            forwarded_trace.parent_span_id)

    request.trace.record(Annotation.string("http.method", request.method))
    request.trace.record(Annotation.string("http.url", request.url))
    request.trace.record(Annotation.string("span.kind", "client"))
    request.trace.record(Annotation.server_recv())

    return request