Skip to content

Commit 4a6eb29

Browse files
committed
trace: add openinference
1 parent 838b1ba commit 4a6eb29

5 files changed

Lines changed: 64 additions & 51 deletions

File tree

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.10"
77
dependencies = [
88
"llama-index>=0.12.36",
9-
"opentelemetry-instrumentation-llamaindex>=0.40.7",
9+
"openinference-instrumentation-llama-index>=4.2.1",
1010
"uipath>=2.0.56",
1111
]
1212
classifiers = [
@@ -84,4 +84,4 @@ addopts = "-ra -q"
8484
name = "testpypi"
8585
url = "https://test.pypi.org/simple/"
8686
publish-url = "https://test.pypi.org/legacy/"
87-
explicit = true
87+
explicit = true

samples/quickstart-agent/pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,12 @@ dependencies = [
99
"uipath-llamaindex>=0.0.11",
1010
"llama-index-llms-openai>=0.2.2"
1111
]
12+
13+
[[tool.uv.index]]
14+
name = "testpypi"
15+
url = "https://test.pypi.org/simple/"
16+
publish-url = "https://test.pypi.org/legacy/"
17+
explicit = true
18+
19+
[tool.uv.sources]
20+
uipath = { index = "testpypi" }

src/uipath_llamaindex/_cli/_runtime/_runtime.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import json
22
import logging
3+
from contextlib import suppress
34
from typing import Optional
45

6+
from openinference.instrumentation.llama_index import LlamaIndexInstrumentor
7+
from opentelemetry import trace
58
from uipath import UiPath
69
from uipath._cli._runtime._contracts import (
710
UiPathBaseRuntime,
@@ -38,6 +41,11 @@ async def execute(self) -> Optional[UiPathRuntimeResult]:
3841
"""
3942
await self.validate()
4043

44+
with suppress(Exception):
45+
LlamaIndexInstrumentor().instrument(
46+
tracer_provider=trace.get_tracer_provider()
47+
)
48+
4149
try:
4250
start_event_class = self.context.workflow._start_event_class
4351

src/uipath_llamaindex/_cli/cli_run.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import asyncio
22
import logging
3-
from contextlib import suppress
43
from os import environ as env
54
from typing import Optional
65

76
from dotenv import load_dotenv
8-
from opentelemetry import trace
9-
from opentelemetry.instrumentation.llamaindex import LlamaIndexInstrumentor
107
from uipath._cli._runtime._contracts import UiPathTraceContext
118
from uipath._cli.middlewares import MiddlewareResult
12-
from uipath.tracing import wait_for_tracers
139

1410
from ._runtime._context import UiPathLlamaIndexRuntimeContext
1511
from ._runtime._exception import UiPathLlamaIndexRuntimeError
@@ -34,10 +30,6 @@ def llamaindex_run_middleware(
3430
try:
3531

3632
async def execute():
37-
38-
with suppress(Exception):
39-
LlamaIndexInstrumentor().instrument(tracer_provider=trace.get_tracer_provider())
40-
4133
context = UiPathLlamaIndexRuntimeContext.from_config(
4234
env.get("UIPATH_CONFIG_PATH", "uipath.json")
4335
)
@@ -67,10 +59,7 @@ async def execute():
6759
async with UiPathLlamaIndexRuntime.from_context(context) as runtime:
6860
await runtime.execute()
6961

70-
try:
71-
asyncio.run(execute())
72-
finally:
73-
wait_for_tracers()
62+
asyncio.run(execute())
7463

7564
return MiddlewareResult(should_continue=False, error_message=None)
7665

uv.lock

Lines changed: 44 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)