Span Util¶
- ibm_watsonx_gov.traces.span_util.extract_value_from_jsonpath(jsonpath_expr: str, json_data: str | Dict[str, Any]) Any | None ¶
Extract the value from a JSON path expression.
- Parameters:
jsonpath_expr (str) – The JSON path expression.
json_data (str | Dict[str, Any]) – The JSON data.
- Raises:
ValueError – If more than one values found for the expression
- Returns:
The extracted value, if found. Else, None.
- Return type:
Any | None
- ibm_watsonx_gov.traces.span_util.flatten_attributes(attributes, lower_case: bool = True) Dict[str, Any] ¶
Flatten OpenTelemetry span attributes into a simple key-value dictionary.
- Parameters:
attributes (list[KeyValue]) – List of attributes
lower_case (bool, optional) – Should the result contain the keys in lower case. Defaults to True.
- Returns:
The flattened dictionary of key values from attributes
- Return type:
Dict[str, Any]
- ibm_watsonx_gov.traces.span_util.get_attribute_value(attribute: KeyValue) Any ¶
Get the attribute value
- Parameters:
attribute (KeyValue) – The attribute
- Returns:
The value from the attribute
- Return type:
Any
- ibm_watsonx_gov.traces.span_util.get_attributes(attributes, keys: list[str] = []) dict[str, Any] ¶
Get the attribute value for the given keys from a list of attributes.
- ibm_watsonx_gov.traces.span_util.get_span_nodes_from_json(span_json: str, agentic_app: AgenticApp | None = None) dict[str, SpanNode] ¶
Convert a JSON string containing a list of spans into a dictionary of SpanNode objects, keyed by span_id.