Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.
This repository was archived by the owner on May 23, 2023. It is now read-only.

MockTracer cannot start span with a parent span #132

Open

Description

@moonshine-fish

if parent_ctx._baggage is not None:

If I want to test with MockTracer, and in my business code it calls start_span with child_of parameter, an error will occur as original SpanContext doesn't have _baggage property

        # Assemble the child ctx
        ctx = SpanContext(span_id=self._generate_id())
        if parent_ctx is not None:
>           if parent_ctx._baggage is not None:
E           AttributeError: 'SpanContext' object has no attribute '_baggage'

opentracing.mocktracer.SpanContext has _baggage property, but how can I use it in my business code?

Activity

  1. yurishkuro commented on May 20, 2020

    @yurishkuro
    Member

    Please refer to the API and not to private fields of implementation classes.

    def set_baggage_item(self, key, value):
    """Stores a Baggage item in the :class:`Span` as a key/value pair.
    Enables powerful distributed context propagation functionality where
    arbitrary application data can be carried along the full path of
    request execution throughout the system.
    Note 1: Baggage is only propagated to the future (recursive) children
    of this :class:`Span`.
    Note 2: Baggage is sent in-band with every subsequent local and remote
    calls, so this feature must be used with care.
    :param key: Baggage item key
    :type key: str
    :param value: Baggage item value
    :type value: str
    :rtype: Span
    :return: itself, for chaining the calls.
    """
    return self

    def get_baggage_item(self, key):
    """Retrieves value of the baggage item with the given key.
    :param key: key of the baggage item
    :type key: str
    :rtype: str
    :return: value of the baggage item with given key, or ``None``.
    """
    return None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions