-
Notifications
You must be signed in to change notification settings - Fork 14
feat(tracing): add json and sqlite exporters to python #517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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]] |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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]] |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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]] |
There was a problem hiding this comment.
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 = ( |
There was a problem hiding this comment.
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.
e01ab34
to
16ea80e
Compare
16ea80e
to
8752a1b
Compare
Description
Add
BaseSpanProcessor
,JsonFileExporter
,SqliteExporter
.Did not edit
LlmOpsHttpExporter
because llama index is using it, carefull not to create breaking changes.Development Package