Exemplo n.º 1
0
def create_span(zipkin_attrs,
                span_name,
                annotations,
                binary_annotations,
                is_client=False):
    """
    Creates a zipkin span object based on a request

    :param request: pyramid request object
    :param annotations: list of zipkin annotation objects
    :param binary_annotations: list of zipkin binary annotation objects
    :returns: zipkin span object
    """

    span_id = generate_span_id() if is_client else zipkin_attrs.span_id
    parent_span_id = (zipkin_attrs.span_id
                      if is_client else zipkin_attrs.parent_span_id)

    return zipkin_core.Span(
        **{
            "trace_id": get_id(zipkin_attrs.trace_id),
            "name": span_name,
            "id": get_id(span_id),
            "parent_id": get_id(parent_span_id),
            "annotations": annotations,
            "binary_annotations": binary_annotations,
        })
Exemplo n.º 2
0
def create_span(zipkin_attrs, span_name, annotations, binary_annotations,
                is_client=False):
    """
    Creates a zipkin span object based on a request

    :param request: pyramid request object
    :param annotations: list of zipkin annotation objects
    :param binary_annotations: list of zipkin binary annotation objects
    :returns: zipkin span object
    """

    span_id = generate_span_id() if is_client else zipkin_attrs.span_id
    parent_span_id = (
        zipkin_attrs.span_id if is_client else zipkin_attrs.parent_span_id)

    return zipkin_core.Span(**{
        "trace_id": get_id(zipkin_attrs.trace_id),
        "name": span_name,
        "id": get_id(span_id),
        "parent_id": get_id(parent_span_id),
        "annotations": annotations,
        "binary_annotations": binary_annotations,
    })
def test_generate_span_id(rand):
    rand.return_value = '42'
    assert request_helper.generate_span_id() == '0x42'
Exemplo n.º 4
0
def test_generate_span_id(rand):
    rand.return_value = '42'
    assert request_helper.generate_span_id() == '0x42'