Span Node

class ibm_watsonx_gov.traces.span_node.SpanNode(service_name: str, agentic_app: AgenticApp | None, span)

Bases: object

Class to represent the structure of a single span and its children.

add_child(child: SpanNode)
find_nodes_with_name(name: str) list[SpanNode]

Depth First Search to find the nodes with span name provided.

Parameters:

name (str) – The span name to find

Returns:

The list of nodes matching the criteria.

Return type:

list[SpanNode]

get_conversation_id() str

Returns the conversation id from this span

Returns:

The conversation id

Return type:

str

get_mapping_value(mapping_item: MappingItem) Any | None

Gets the mapping value specified by a single mapping item from the span.

Parameters:

mapping_item (MappingItem) – The mapping item containing the json path etc.

Raises:

ValueError

  1. If the mapping item is not correct. 2. When mapping item type is span, and more than one spans OR no spans match the criteria.

Returns:

If found, the value from the span corresponding to the mapping item provided.

Return type:

Any | None

get_message_id() str

Returns the message id from this span

Returns:

The message id

Return type:

str

get_message_status() str

Get the final status of the message from this span node (i.e. this trace)

This looks at all the spans (including the children) and returns the status like so: 1. If there is a single span with an error status, mark the message as failure 2. If the root span status is ok, mark the message as successful 3. Default status of the message is unknown

Returns:

The status.

Return type:

str

get_nodes_configuration() dict
get_values(mapping: Mapping) Dict[str, Any]

Get the values according to the mapping provided from this span node.

Parameters:

mapping (Mapping) – The mapping

Returns:

A single dictionary containing the input/output etc extracted from the trace.

Return type:

Dict[str, Any]