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_interaction_id() str

Returns the interaction id from this span

Returns:

The interaction 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_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]