Skip to content

Class swarmauri_core.tracing.ITracer.ITracer

swarmauri_core.tracing.ITracer.ITracer

Bases: ABC

Interface for implementing distributed tracing across different components of the system.

start_trace abstractmethod

start_trace(name, initial_attributes=None)

Starts a new trace with a given name and optional initial attributes.

PARAMETER DESCRIPTION
name

Name of the trace, usually represents the operation being traced.

TYPE: str

initial_attributes

Key-value pairs to be attached to the trace initially.

TYPE: Optional[Dict[str, Any]] DEFAULT: None

RETURNS DESCRIPTION
ITraceContext

A context object representing this particular trace instance.

TYPE: ITraceContext

Source code in swarmauri_core/tracing/ITracer.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
@abstractmethod
def start_trace(
    self, name: str, initial_attributes: Optional[Dict[str, Any]] = None
) -> ITraceContext:
    """
    Starts a new trace with a given name and optional initial attributes.

    Args:
        name (str): Name of the trace, usually represents the operation being traced.
        initial_attributes (Optional[Dict[str, Any]]): Key-value pairs to be attached to the trace initially.

    Returns:
        ITraceContext: A context object representing this particular trace instance.
    """
    pass

end_trace abstractmethod

end_trace(trace_context)

Marks the end of a trace, completing its lifecycle and recording its details.

PARAMETER DESCRIPTION
trace_context

The trace context to be ended.

TYPE: ITraceContext

Source code in swarmauri_core/tracing/ITracer.py
27
28
29
30
31
32
33
34
35
@abstractmethod
def end_trace(self, trace_context: ITraceContext):
    """
    Marks the end of a trace, completing its lifecycle and recording its details.

    Args:
        trace_context (ITraceContext): The trace context to be ended.
    """
    pass

annotate_trace abstractmethod

annotate_trace(trace_context, key, value)

Adds an annotation to an existing trace, enriching it with more detailed information.

PARAMETER DESCRIPTION
trace_context

The trace context to annotate.

TYPE: ITraceContext

key

The key or name of the annotation.

TYPE: str

value

The value of the annotation.

TYPE: Any

Source code in swarmauri_core/tracing/ITracer.py
37
38
39
40
41
42
43
44
45
46
47
@abstractmethod
def annotate_trace(self, trace_context: ITraceContext, key: str, value: Any):
    """
    Adds an annotation to an existing trace, enriching it with more detailed information.

    Args:
        trace_context (ITraceContext): The trace context to annotate.
        key (str): The key or name of the annotation.
        value (Any): The value of the annotation.
    """
    pass