def setUpClass(cls):
     id_generator = ids_generator.RandomIdsGenerator()
     cls.trace_id = id_generator.generate_trace_id()
     cls.span_id = id_generator.generate_span_id()
     cls.parent_span_id = id_generator.generate_span_id()
     cls.serialized_uber_trace_id = _format_uber_trace_id(
         cls.trace_id, cls.span_id, cls.parent_span_id, 11)
def get_context_new_carrier(old_carrier, carrier_baggage=None):

    ctx = FORMAT.extract(carrier_getter, old_carrier)
    if carrier_baggage:
        for key, value in carrier_baggage.items():
            ctx = baggage.set_baggage(key, value, ctx)
    parent_span_context = trace_api.get_current_span(ctx).get_span_context()

    parent = trace._Span("parent", parent_span_context)
    child = trace._Span(
        "child",
        trace_api.SpanContext(
            parent_span_context.trace_id,
            ids_generator.RandomIdsGenerator().generate_span_id(),
            is_remote=False,
            trace_flags=parent_span_context.trace_flags,
            trace_state=parent_span_context.trace_state,
        ),
        parent=parent.get_span_context(),
    )

    new_carrier = {}
    ctx = trace_api.set_span_in_context(child, ctx)

    FORMAT.inject(dict.__setitem__, new_carrier, context=ctx)

    return ctx, new_carrier
Ejemplo n.º 3
0
 def setUpClass(cls):
     id_generator = ids_generator.RandomIdsGenerator()
     cls.serialized_trace_id = b3_format.format_trace_id(
         id_generator.generate_trace_id())
     cls.serialized_span_id = b3_format.format_span_id(
         id_generator.generate_span_id())
     cls.serialized_parent_id = b3_format.format_span_id(
         id_generator.generate_span_id())
Ejemplo n.º 4
0
def get_child_parent_new_carrier(old_carrier):

    ctx = FORMAT.extract(carrier_getter, old_carrier)
    parent_span_context = trace_api.get_current_span(ctx).get_span_context()

    parent = trace._Span("parent", parent_span_context)
    child = trace._Span(
        "child",
        trace_api.SpanContext(
            parent_span_context.trace_id,
            ids_generator.RandomIdsGenerator().generate_span_id(),
            is_remote=False,
            trace_flags=parent_span_context.trace_flags,
            trace_state=parent_span_context.trace_state,
        ),
        parent=parent.get_span_context(),
    )

    new_carrier = {}
    ctx = trace_api.set_span_in_context(child)
    FORMAT.inject(dict.__setitem__, new_carrier, context=ctx)

    return child, parent, new_carrier