Skip to content
Draft
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
11 changes: 11 additions & 0 deletions packages/uipath-platform/src/uipath/platform/common/_span_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
# SourceEnum.Robots = 4 (default for Python SDK / coded agents)
DEFAULT_SOURCE = 4

SOURCE_NAMES: dict[int, str] = {
0: "Testing",
1: "Agents",
2: "ProcessOrchestration",
3: "ApiWorkflows",
4: "Robots",
5: "ConversationalAgentsService",
6: "IntegrationServiceTrigger",
7: "Playground",
}


class AttachmentProvider(IntEnum):
ORCHESTRATOR = 0
Expand Down
2 changes: 1 addition & 1 deletion packages/uipath/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath"
version = "2.10.11"
version = "2.10.12"
description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools."
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
Expand Down
7 changes: 6 additions & 1 deletion packages/uipath/src/uipath/tracing/_otel_exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from uipath._utils._ssl_context import get_httpx_client_kwargs
from uipath.platform.common import _SpanUtils
from uipath.platform.common._span_utils import DEFAULT_SOURCE, SOURCE_NAMES
from uipath.platform.common.retry import NON_RETRYABLE_STATUS_CODES

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -389,7 +390,11 @@ def _process_span_attributes(self, span_data: Dict[str, Any]) -> None:
def _build_url(self, span_list: list[Dict[str, Any]]) -> str:
"""Construct the URL for the API request."""
trace_id = str(span_list[0]["TraceId"])
return f"{self.base_url}/api/Traces/spans?traceId={trace_id}&source=Robots"
source_int = span_list[0].get("Source", DEFAULT_SOURCE)
source_name = SOURCE_NAMES.get(source_int, "Robots")
return (
f"{self.base_url}/api/Traces/spans?traceId={trace_id}&source={source_name}"
)

def _send_with_retries(
self, url: str, payload: list[Dict[str, Any]], max_retries: int = 4
Expand Down
45 changes: 45 additions & 0 deletions packages/uipath/tests/tracing/test_otel_exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,51 @@ def test_get_base_url():
assert exporter.base_url == "https://custom-trace.example.com/prefix"


def test_build_url_uses_span_source():
"""Test _build_url derives source query param from span's Source field."""
with (
patch("uipath.tracing._otel_exporters.httpx.Client"),
patch.dict(os.environ, {"UIPATH_ACCESS_TOKEN": "t"}, clear=True),
):
exporter = LlmOpsHttpExporter()
exporter.base_url = "https://example.com/llmops"

# Source=1 (Agents)
url = exporter._build_url([{"TraceId": "abc", "Source": 1}])
assert (
url
== "https://example.com/llmops/api/Traces/spans?traceId=abc&source=Agents"
)

# Source=4 (Robots) - default
url = exporter._build_url([{"TraceId": "abc", "Source": 4}])
assert (
url
== "https://example.com/llmops/api/Traces/spans?traceId=abc&source=Robots"
)

# Missing Source defaults to Robots
url = exporter._build_url([{"TraceId": "abc"}])
assert (
url
== "https://example.com/llmops/api/Traces/spans?traceId=abc&source=Robots"
)

# Source=7 (Playground)
url = exporter._build_url([{"TraceId": "abc", "Source": 7}])
assert (
url
== "https://example.com/llmops/api/Traces/spans?traceId=abc&source=Playground"
)

# Unknown source int falls back to Robots
url = exporter._build_url([{"TraceId": "abc", "Source": 99}])
assert (
url
== "https://example.com/llmops/api/Traces/spans?traceId=abc&source=Robots"
)


def test_internal_headers_set_when_trace_base_url_present():
"""Test that internal tenant/account headers are set when UIPATH_TRACE_BASE_URL is configured."""
with patch.dict(
Expand Down
8 changes: 4 additions & 4 deletions packages/uipath/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading