Skip to content

Commit 3dfce38

Browse files
authored
Merge pull request #225 from UiPath/feature/traces_test
Testcases: add asserts for traces
2 parents e7588e3 + da4c960 commit 3dfce38

File tree

25 files changed

+1809
-658
lines changed

25 files changed

+1809
-658
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[project]
22
name = "uipath-langchain"
3-
version = "0.0.142"
3+
version = "0.0.143"
44
description = "UiPath Langchain"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.10"
77
dependencies = [
8-
"uipath>=2.1.101, <2.2.0",
8+
"uipath>=2.1.103, <2.2.0",
99
"langgraph>=0.5.0, <0.7.0",
1010
"langchain-core>=0.3.34",
1111
"langgraph-checkpoint-sqlite>=2.0.3",

src/uipath_langchain/_cli/cli_debug.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
UiPathRuntimeFactory,
1313
)
1414
from uipath._cli.middlewares import MiddlewareResult
15+
from uipath.tracing import LlmOpsHttpExporter
1516

16-
from .._tracing import LangChainExporter, _instrument_traceable_attributes
17+
from .._tracing import _instrument_traceable_attributes
1718
from ._runtime._exception import LangGraphRuntimeError
1819
from ._runtime._runtime import ( # type: ignore[attr-defined]
1920
LangGraphRuntimeContext,
@@ -61,7 +62,9 @@ def generate_runtime(
6162
)
6263

6364
if context.job_id:
64-
runtime_factory.add_span_exporter(LangChainExporter())
65+
runtime_factory.add_span_exporter(
66+
LlmOpsHttpExporter(extra_process_spans=True)
67+
)
6568

6669
runtime_factory.add_instrumentor(LangChainInstrumentor, get_current_span)
6770

src/uipath_langchain/_cli/cli_eval.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
from uipath._cli.middlewares import MiddlewareResult
1616
from uipath._events._event_bus import EventBus
1717
from uipath.eval._helpers import auto_discover_entrypoint
18+
from uipath.tracing import LlmOpsHttpExporter
1819

1920
from uipath_langchain._cli._runtime._context import LangGraphRuntimeContext
2021
from uipath_langchain._cli._runtime._runtime import LangGraphScriptRuntime
2122
from uipath_langchain._cli._utils._graph import LangGraphConfig
2223
from uipath_langchain._tracing import (
23-
LangChainExporter,
2424
_instrument_traceable_attributes,
2525
)
2626

@@ -41,7 +41,7 @@ def langgraph_eval_middleware(
4141

4242
if kwargs.get("register_progress_reporter", False):
4343
progress_reporter = StudioWebProgressReporter(
44-
spans_exporter=LangChainExporter()
44+
spans_exporter=LlmOpsHttpExporter(extra_process_spans=True)
4545
)
4646
asyncio.run(progress_reporter.subscribe_to_eval_runtime_events(event_bus))
4747
console_reporter = ConsoleProgressReporter()
@@ -76,7 +76,9 @@ def generate_runtime(ctx: LangGraphRuntimeContext) -> LangGraphScriptRuntime:
7676
)
7777

7878
if eval_context.job_id:
79-
runtime_factory.add_span_exporter(LangChainExporter())
79+
runtime_factory.add_span_exporter(
80+
LlmOpsHttpExporter(extra_process_spans=True)
81+
)
8082

8183
runtime_factory.add_instrumentor(LangChainInstrumentor, get_current_span)
8284

src/uipath_langchain/_cli/cli_run.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313
)
1414
from uipath._cli.middlewares import MiddlewareResult
1515
from uipath._events._events import UiPathAgentStateEvent
16+
from uipath.tracing import JsonLinesFileExporter, LlmOpsHttpExporter
1617

17-
from .._tracing import LangChainExporter, _instrument_traceable_attributes
18+
from .._tracing import (
19+
_instrument_traceable_attributes,
20+
)
1821
from ._runtime._exception import LangGraphRuntimeError
1922
from ._runtime._runtime import ( # type: ignore[attr-defined]
2023
LangGraphRuntimeContext,
@@ -24,7 +27,11 @@
2427

2528

2629
def langgraph_run_middleware(
27-
entrypoint: Optional[str], input: Optional[str], resume: bool, **kwargs
30+
entrypoint: Optional[str],
31+
input: Optional[str],
32+
resume: bool,
33+
trace_file: Optional[str] = None,
34+
**kwargs,
2835
) -> MiddlewareResult:
2936
"""Middleware to handle LangGraph execution"""
3037
config = LangGraphConfig()
@@ -61,8 +68,13 @@ def generate_runtime(
6168

6269
runtime_factory.add_instrumentor(LangChainInstrumentor, get_current_span)
6370

71+
if trace_file:
72+
runtime_factory.add_span_exporter(JsonLinesFileExporter(trace_file))
73+
6474
if context.job_id:
65-
runtime_factory.add_span_exporter(LangChainExporter())
75+
runtime_factory.add_span_exporter(
76+
LlmOpsHttpExporter(extra_process_spans=True)
77+
)
6678
await runtime_factory.execute(context)
6779
else:
6880
debug_bridge: UiPathDebugBridge = ConsoleDebugBridge()
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from ._instrument_traceable import _instrument_traceable_attributes
2-
from ._oteladapter import LangChainExporter
32

4-
__all__ = ["LangChainExporter", "_instrument_traceable_attributes"]
3+
__all__ = [
4+
"_instrument_traceable_attributes",
5+
]

src/uipath_langchain/_tracing/_oteladapter.py

Lines changed: 0 additions & 234 deletions
This file was deleted.

0 commit comments

Comments
 (0)