Skip to content

deep.api.plugin.span

Definition of span processor.

Span processor gives the ability to generate spans dynamically.

Span

Internal type to wrap spans.

Source code in deep/api/plugin/span/__init__.py
class Span:
    """Internal type to wrap spans."""

    @property
    @abc.abstractmethod
    def name(self):
        """Get the span name."""
        pass

    @property
    @abc.abstractmethod
    def trace_id(self):
        """Get the trace id."""
        pass

    @property
    @abc.abstractmethod
    def span_id(self):
        """Get the span id."""
        pass

    @abc.abstractmethod
    def add_attribute(self, key: str, value: str):
        """
        Add an attribute to the span.

        :param key: the attribute key
        :param value: the attribute value
        """
        pass

    @abc.abstractmethod
    def add_event(self, name, attributes=None):
        """
        Add an event to the span.

        :param name: the event name
        :param attributes: the event attributes
        :return:
        """
        pass

    @abc.abstractmethod
    def close(self):
        """Close the span."""
        pass

name abstractmethod property

Get the span name.

span_id abstractmethod property

Get the span id.

trace_id abstractmethod property

Get the trace id.

add_attribute(key, value) abstractmethod

Add an attribute to the span.

:param key: the attribute key :param value: the attribute value

Source code in deep/api/plugin/span/__init__.py
@abc.abstractmethod
def add_attribute(self, key: str, value: str):
    """
    Add an attribute to the span.

    :param key: the attribute key
    :param value: the attribute value
    """
    pass

add_event(name, attributes=None) abstractmethod

Add an event to the span.

:param name: the event name :param attributes: the event attributes :return:

Source code in deep/api/plugin/span/__init__.py
@abc.abstractmethod
def add_event(self, name, attributes=None):
    """
    Add an event to the span.

    :param name: the event name
    :param attributes: the event attributes
    :return:
    """
    pass

close() abstractmethod

Close the span.

Source code in deep/api/plugin/span/__init__.py
@abc.abstractmethod
def close(self):
    """Close the span."""
    pass

SpanProcessor

Bases: Plugin, ABC

Span processor connects Deep to a span provider.

Source code in deep/api/plugin/span/__init__.py
class SpanProcessor(Plugin, abc.ABC):
    """Span processor connects Deep to a span provider."""

    @abc.abstractmethod
    def create_span(self, name: str, context_id: str, tracepoint_id: str) -> Optional['Span']:
        """
        Create and return a new span.

        :param name: the name of the span to create
        :param context_id: the id of the context
        :param tracepoint_id: the id of thr tracepoint
        :return: the created span
        """
    pass

    @abc.abstractmethod
    def current_span(self) -> Optional['Span']:
        """
        Get the current span from the underlying provider.

        :return: the current span
        """
        pass

create_span(name, context_id, tracepoint_id) abstractmethod

Create and return a new span.

:param name: the name of the span to create :param context_id: the id of the context :param tracepoint_id: the id of thr tracepoint :return: the created span

Source code in deep/api/plugin/span/__init__.py
@abc.abstractmethod
def create_span(self, name: str, context_id: str, tracepoint_id: str) -> Optional['Span']:
    """
    Create and return a new span.

    :param name: the name of the span to create
    :param context_id: the id of the context
    :param tracepoint_id: the id of thr tracepoint
    :return: the created span
    """

current_span() abstractmethod

Get the current span from the underlying provider.

:return: the current span

Source code in deep/api/plugin/span/__init__.py
@abc.abstractmethod
def current_span(self) -> Optional['Span']:
    """
    Get the current span from the underlying provider.

    :return: the current span
    """
    pass