Skip to content

Conversation

ionmincu
Copy link
Contributor

@ionmincu ionmincu commented Aug 28, 2025

Description

Add BaseSpanProcessor, JsonFileExporter, SqliteExporter.

Did not edit LlmOpsHttpExporter because llama index is using it, carefull not to create breaking changes.

Development Package

  • Add this package as a dependency in your pyproject.toml:
[project]
dependencies = [
  # Exact version:
  "uipath==2.1.28.dev1005170837",

  # Any version from PR
  "uipath>=2.1.28.dev1005170000,<2.1.28.dev1005180000"
]

[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
publish-url = "https://test.pypi.org/legacy/"
explicit = true

[tool.uv.sources]
uipath = { index = "testpypi" }

@ionmincu ionmincu requested a review from radu-mocanu August 28, 2025 14:25
@ionmincu ionmincu self-assigned this Aug 28, 2025
@ionmincu ionmincu requested a review from Copilot August 28, 2025 14:25
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds new tracing exporters to the Python SDK for enhanced debugging and local development capabilities. It introduces a base span processor architecture and two new exporters for saving traces to JSON files and SQLite databases.

  • Adds BaseSpanProcessor abstract class for processing span data before export
  • Implements JsonFileExporter for writing spans to JSON Lines format files
  • Implements SqliteExporter with comprehensive metadata management and schema versioning

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 9 comments.

File Description
src/uipath/tracing/_otel_exporters.py Core implementation of new exporters and base classes
tests/tracing/test_otel_exporters.py Comprehensive test coverage for all new exporter functionality
src/uipath/tracing/__init__.py Exports new classes in public API
pyproject.toml Version bump to 2.1.28

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

"""Base class for UiPath span exporters."""

def __init__(
self, processor: BaseSpanProcessor | None = None, *args: Any, **kwargs: Any
Copy link
Preview

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The union syntax BaseSpanProcessor | None requires Python 3.10+. Consider using Optional[BaseSpanProcessor] from typing for better compatibility with older Python versions.

Copilot uses AI. Check for mistakes.


@abstractmethod
def _export_uipath_spans(
self, uipath_spans: list[Dict[str, Any]]
Copy link
Preview

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generic syntax list[Dict[str, Any]] requires Python 3.9+. Consider using List[Dict[str, Any]] from typing for better compatibility.

Copilot uses AI. Check for mistakes.

file.
"""

def __init__(self, file_path: str, processor: BaseSpanProcessor | None = None):
Copy link
Preview

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The union syntax BaseSpanProcessor | None requires Python 3.10+. Consider using Optional[BaseSpanProcessor] from typing for better compatibility.

Copilot uses AI. Check for mistakes.

os.makedirs(os.path.dirname(self.file_path), exist_ok=True)

def _export_uipath_spans(
self, uipath_spans: list[Dict[str, Any]]
Copy link
Preview

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generic syntax list[Dict[str, Any]] requires Python 3.9+. Consider using List[Dict[str, Any]] from typing for better compatibility.

Copilot uses AI. Check for mistakes.

# Schema version for the SQLite database
SCHEMA_VERSION = "1.0.0"

def __init__(self, db_path: str, processor: BaseSpanProcessor | None = None):
Copy link
Preview

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The union syntax BaseSpanProcessor | None requires Python 3.10+. Consider using Optional[BaseSpanProcessor] from typing for better compatibility.

Copilot uses AI. Check for mistakes.

f"Initialized database with schema version {self.SCHEMA_VERSION}"
)

def get_schema_version(self) -> str | None:
Copy link
Preview

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The union syntax str | None requires Python 3.10+. Consider using Optional[str] from typing for better compatibility.

Copilot uses AI. Check for mistakes.

logger.warning(f"Failed to get schema version: {e}")
return None

def get_metadata(self, key: str) -> str | None:
Copy link
Preview

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The union syntax str | None requires Python 3.10+. Consider using Optional[str] from typing for better compatibility.

Copilot uses AI. Check for mistakes.

self._create_tables()

def _export_uipath_spans(
self, uipath_spans: list[Dict[str, Any]]
Copy link
Preview

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generic syntax list[Dict[str, Any]] requires Python 3.9+. Consider using List[Dict[str, Any]] from typing for better compatibility.

Copilot uses AI. Check for mistakes.

"""
import datetime

current_time = (
Copy link
Preview

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The datetime formatting logic is duplicated in multiple methods. Consider extracting this into a helper method to reduce code duplication.

Copilot uses AI. Check for mistakes.

@ionmincu ionmincu added the build:dev Create a dev build from the pr label Aug 29, 2025
@ionmincu ionmincu force-pushed the feature/tracing_enhance branch from e01ab34 to 16ea80e Compare August 29, 2025 14:31
@ionmincu ionmincu force-pushed the feature/tracing_enhance branch from 16ea80e to 8752a1b Compare August 29, 2025 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build:dev Create a dev build from the pr
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant