Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath-langchain"
version = "0.0.136"
version = "0.0.137"
description = "UiPath Langchain"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.10"
Expand Down
26 changes: 19 additions & 7 deletions src/uipath_langchain/_tracing/_oteladapter.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import json
import logging
from typing import Any, Dict, List
from typing import Any, Dict, List, Optional

from opentelemetry.sdk.trace.export import (
SpanExportResult,
)
from opentelemetry.sdk.trace.export import SpanExportResult
from uipath.tracing import LlmOpsHttpExporter

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -71,6 +69,11 @@ class LangChainExporter(LlmOpsHttpExporter):
# Add more mappings as needed
}

class Status:
SUCCESS = 1
ERROR = 2
INTERRUPTED = 3

def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)

Expand Down Expand Up @@ -161,13 +164,18 @@ def _map_tool_call_attributes(self, attributes: Dict[str, Any]) -> Dict[str, Any

return result

def _determine_status(self, error: Optional[str]) -> int:
if error:
if error and error.startswith("GraphInterrupt("):
return self.Status.INTERRUPTED
return self.Status.ERROR
return self.Status.SUCCESS

def _process_span_attributes(self, span_data: Dict[str, Any]) -> Dict[str, Any]:
"""Extracts, transforms, and maps attributes for a span."""
if "Attributes" not in span_data:
return span_data

logger.debug(f"Processing span: {span_data}")

attributes_val = span_data["Attributes"]
if isinstance(attributes_val, str):
try:
Expand Down Expand Up @@ -206,7 +214,11 @@ def _process_span_attributes(self, span_data: Dict[str, Any]) -> Dict[str, Any]:

span_data["Attributes"] = json.dumps(processed_attributes)

logger.debug(f"Transformed span: {span_data}")
# Determine status based on error information
error = attributes.get("error") or attributes.get("exception.message")
status = self._determine_status(error)
span_data["Status"] = status

return span_data

def _send_with_retries(
Expand Down