|
10 | 10 | from mcp import ClientSession, StdioServerParameters, stdio_client |
11 | 11 | from mcp.types import JSONRPCResponse |
12 | 12 | from opentelemetry import trace |
| 13 | +from opentelemetry.sdk.trace import TracerProvider |
| 14 | +from opentelemetry.sdk.trace.export import BatchSpanProcessor |
13 | 15 | from pysignalr.client import CompletionMessage, SignalRClient |
14 | 16 | from uipath import UiPath |
15 | 17 | from uipath._cli._runtime._contracts import ( |
16 | 18 | UiPathBaseRuntime, |
17 | 19 | UiPathErrorCategory, |
18 | 20 | UiPathRuntimeResult, |
19 | 21 | ) |
20 | | -from uipath.tracing import wait_for_tracers |
| 22 | +from uipath.tracing import LlmOpsHttpExporter |
21 | 23 |
|
22 | 24 | from .._utils._config import McpServer |
23 | 25 | from ._context import UiPathMcpRuntimeContext, UiPathServerType |
@@ -62,6 +64,12 @@ async def execute(self) -> Optional[UiPathRuntimeResult]: |
62 | 64 | try: |
63 | 65 | if self._server is None: |
64 | 66 | return None |
| 67 | + |
| 68 | + self.trace_provider = TracerProvider() |
| 69 | + trace.set_tracer_provider(self.trace_provider) |
| 70 | + self.trace_provider.add_span_processor( |
| 71 | + BatchSpanProcessor(LlmOpsHttpExporter()) |
| 72 | + ) # type: ignore |
65 | 73 |
|
66 | 74 | # Set up SignalR client |
67 | 75 | signalr_url = f"{os.environ.get('UIPATH_URL')}/mcp_/wsstunnel?slug={self._server.name}&runtimeId={self._runtime_id}" |
@@ -125,7 +133,7 @@ async def execute(self) -> Optional[UiPathRuntimeResult]: |
125 | 133 | UiPathErrorCategory.USER, |
126 | 134 | ) from e |
127 | 135 | finally: |
128 | | - wait_for_tracers() |
| 136 | + self.trace_provider.shutdown() |
129 | 137 |
|
130 | 138 | async def validate(self) -> None: |
131 | 139 | """Validate runtime inputs and load MCP server configuration.""" |
|
0 commit comments