uipath-core 0.1.9__py3-none-any.whl → 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,9 +7,11 @@ with OpenTelemetry tracing, including custom processors for UiPath execution tra
7
7
  from uipath.core.tracing.decorators import traced
8
8
  from uipath.core.tracing.span_utils import UiPathSpanUtils
9
9
  from uipath.core.tracing.trace_manager import UiPathTraceManager
10
+ from uipath.core.tracing.types import UiPathTraceSettings
10
11
 
11
12
  __all__ = [
12
13
  "traced",
13
14
  "UiPathSpanUtils",
14
15
  "UiPathTraceManager",
16
+ "UiPathTraceSettings",
15
17
  ]
@@ -1,22 +1,27 @@
1
1
  """Custom span processors for UiPath execution tracing."""
2
2
 
3
- from typing import Optional, cast
3
+ from typing import cast
4
4
 
5
5
  from opentelemetry import context as context_api
6
6
  from opentelemetry import trace
7
- from opentelemetry.sdk.trace import Span
7
+ from opentelemetry.sdk.trace import ReadableSpan, Span, SpanProcessor
8
8
  from opentelemetry.sdk.trace.export import (
9
9
  BatchSpanProcessor,
10
10
  SimpleSpanProcessor,
11
+ SpanExporter,
11
12
  )
12
13
 
14
+ from uipath.core.tracing.types import UiPathTraceSettings
15
+
13
16
 
14
17
  class UiPathExecutionTraceProcessorMixin:
15
- def on_start(
16
- self, span: Span, parent_context: Optional[context_api.Context] = None
17
- ):
18
+ """Mixin that propagates execution.id and optionally filters spans."""
19
+
20
+ _settings: UiPathTraceSettings | None = None
21
+
22
+ def on_start(self, span: Span, parent_context: context_api.Context | None = None):
18
23
  """Called when a span is started."""
19
- parent_span: Optional[Span]
24
+ parent_span: Span | None
20
25
  if parent_context:
21
26
  parent_span = cast(Span, trace.get_current_span(parent_context))
22
27
  else:
@@ -27,17 +32,42 @@ class UiPathExecutionTraceProcessorMixin:
27
32
  if execution_id:
28
33
  span.set_attribute("execution.id", execution_id)
29
34
 
35
+ def on_end(self, span: ReadableSpan):
36
+ """Called when a span ends. Filters before delegating to parent."""
37
+ span_filter = self._settings.span_filter if self._settings else None
38
+ if span_filter is None or span_filter(span):
39
+ parent = cast(SpanProcessor, super())
40
+ parent.on_end(span)
41
+
30
42
 
31
43
  class UiPathExecutionBatchTraceProcessor(
32
44
  UiPathExecutionTraceProcessorMixin, BatchSpanProcessor
33
45
  ):
34
- """Batch span processor that propagates execution.id."""
46
+ """Batch span processor that propagates execution.id and optionally filters."""
47
+
48
+ def __init__(
49
+ self,
50
+ span_exporter: SpanExporter,
51
+ settings: UiPathTraceSettings | None = None,
52
+ ):
53
+ """Initialize the batch trace processor."""
54
+ super().__init__(span_exporter)
55
+ self._settings = settings
35
56
 
36
57
 
37
58
  class UiPathExecutionSimpleTraceProcessor(
38
59
  UiPathExecutionTraceProcessorMixin, SimpleSpanProcessor
39
60
  ):
40
- """Simple span processor that propagates execution.id."""
61
+ """Simple span processor that propagates execution.id and optionally filters."""
62
+
63
+ def __init__(
64
+ self,
65
+ span_exporter: SpanExporter,
66
+ settings: UiPathTraceSettings | None = None,
67
+ ):
68
+ """Initialize the simple trace processor."""
69
+ super().__init__(span_exporter)
70
+ self._settings = settings
41
71
 
42
72
 
43
73
  __all__ = [
@@ -1,5 +1,7 @@
1
1
  """Tracing manager for handling tracer implementations and function registry."""
2
2
 
3
+ from __future__ import annotations
4
+
3
5
  import contextlib
4
6
  from typing import Any, Generator, Optional
5
7
 
@@ -13,6 +15,7 @@ from uipath.core.tracing.processors import (
13
15
  UiPathExecutionBatchTraceProcessor,
14
16
  UiPathExecutionSimpleTraceProcessor,
15
17
  )
18
+ from uipath.core.tracing.types import UiPathTraceSettings
16
19
 
17
20
 
18
21
  class UiPathTraceManager:
@@ -38,13 +41,31 @@ class UiPathTraceManager:
38
41
  self,
39
42
  span_exporter: SpanExporter,
40
43
  batch: bool = True,
41
- ) -> "UiPathTraceManager":
42
- """Add a span processor to the tracer provider."""
44
+ settings: UiPathTraceSettings | None = None,
45
+ ) -> UiPathTraceManager:
46
+ """Add a span exporter to the tracer provider.
47
+
48
+ Args:
49
+ span_exporter: The exporter to add.
50
+ batch: Whether to use batch processing (default: True).
51
+ settings: Optional trace settings for filtering, etc.
52
+ """
43
53
  span_processor: SpanProcessor
44
54
  if batch:
45
- span_processor = UiPathExecutionBatchTraceProcessor(span_exporter)
55
+ span_processor = UiPathExecutionBatchTraceProcessor(span_exporter, settings)
46
56
  else:
47
- span_processor = UiPathExecutionSimpleTraceProcessor(span_exporter)
57
+ span_processor = UiPathExecutionSimpleTraceProcessor(
58
+ span_exporter, settings
59
+ )
60
+ self.tracer_span_processors.append(span_processor)
61
+ self.tracer_provider.add_span_processor(span_processor)
62
+ return self
63
+
64
+ def add_span_processor(
65
+ self,
66
+ span_processor: SpanProcessor,
67
+ ) -> UiPathTraceManager:
68
+ """Add a span processor to the tracer provider."""
48
69
  self.tracer_span_processors.append(span_processor)
49
70
  self.tracer_provider.add_span_processor(span_processor)
50
71
  return self
@@ -0,0 +1,21 @@
1
+ """Tracing types for UiPath SDK."""
2
+
3
+ from typing import Callable
4
+
5
+ from opentelemetry.sdk.trace import ReadableSpan
6
+ from pydantic import BaseModel, Field
7
+
8
+
9
+ class UiPathTraceSettings(BaseModel):
10
+ """Trace settings for UiPath SDK."""
11
+
12
+ model_config = {"arbitrary_types_allowed": True} # Needed for Callable
13
+
14
+ span_filter: Callable[[ReadableSpan], bool] | None = Field(
15
+ default=None,
16
+ description=(
17
+ "Optional filter to decide whether a span should be exported. "
18
+ "Called when a span ends with a ReadableSpan argument. "
19
+ "Return True to export, False to skip."
20
+ ),
21
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: uipath-core
3
- Version: 0.1.9
3
+ Version: 0.2.0
4
4
  Summary: UiPath Core abstractions
5
5
  Project-URL: Homepage, https://uipath.com
6
6
  Project-URL: Repository, https://github.com/UiPath/uipath-core-python
@@ -13,8 +13,8 @@ Classifier: Programming Language :: Python :: 3.12
13
13
  Classifier: Programming Language :: Python :: 3.13
14
14
  Classifier: Topic :: Software Development :: Build Tools
15
15
  Requires-Python: >=3.11
16
- Requires-Dist: opentelemetry-instrumentation<1.0.0,>=0.60b0
17
- Requires-Dist: opentelemetry-sdk<2.0.0,>=1.39.0
16
+ Requires-Dist: opentelemetry-instrumentation<1.0.0,>=0.60b1
17
+ Requires-Dist: opentelemetry-sdk<2.0.0,>=1.39.1
18
18
  Requires-Dist: pydantic<3.0.0,>=2.12.5
19
19
  Description-Content-Type: text/markdown
20
20
 
@@ -18,14 +18,15 @@ uipath/core/guardrails/__init__.py,sha256=hUCmD4y5te2iy01YnJlBuf2RWvqxmsNzoyOamX
18
18
  uipath/core/guardrails/_deterministic_guardrails_service.py,sha256=61ROXYmX3rjBfFUp7E83fm4Lk7h1DlJeukpZm7uzVqQ,6355
19
19
  uipath/core/guardrails/_evaluators.py,sha256=10tIRUufxoy9MkZPb-ytjsCSCIfIqQSOYXyEl4G7PSw,15649
20
20
  uipath/core/guardrails/guardrails.py,sha256=sTxsNHilEX908aF-WtQWVOQ4dCCwMgAepDebH35ngvo,5430
21
- uipath/core/tracing/__init__.py,sha256=1XNLYZ4J76XkRrizGO486mS6yxzVXUbrldpvxTyJe3E,483
21
+ uipath/core/tracing/__init__.py,sha256=Y0wfRSGCVcDoFYTmTkVQElu5JE91h4dTNkKQnd86dBM,568
22
22
  uipath/core/tracing/_utils.py,sha256=FiCFGOFa4czruhlSF87Q5Q4jX9KKPHZiw8k14K7W5v4,6636
23
23
  uipath/core/tracing/decorators.py,sha256=JDNULkUu-Ufg8pJslG4i6Q2pmqaGNDS8NFRPgFs29Dw,11937
24
24
  uipath/core/tracing/exporters.py,sha256=FClouEEQfk3F8J7G_NFoarDJM3R0-gA5jUxA5xRHx5s,1562
25
- uipath/core/tracing/processors.py,sha256=R_652rtjPmfpUtaXoIcmfZrRZylVXFRNwjOmJUUxOQw,1408
25
+ uipath/core/tracing/processors.py,sha256=XlMKA_AWwrtC-0ytnAHxl4P9kXlQdsjcn8zwnSpZKts,2500
26
26
  uipath/core/tracing/span_utils.py,sha256=LZXNdnI0-fhKe49CLPsvMJIfh9zdzk8rK4g4YN5RfDU,13064
27
- uipath/core/tracing/trace_manager.py,sha256=51rscJcepkTK4bWoCZdE-DFc9wt2F-aSuFBaSXmkHl0,3130
28
- uipath_core-0.1.9.dist-info/METADATA,sha256=wLk7EKaDR01IqA7RvbhRzw13dw2DRX6twknAm793_OY,938
29
- uipath_core-0.1.9.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
30
- uipath_core-0.1.9.dist-info/licenses/LICENSE,sha256=-KBavWXepyDjimmzH5fVAsi-6jNVpIKFc2kZs0Ri4ng,1058
31
- uipath_core-0.1.9.dist-info/RECORD,,
27
+ uipath/core/tracing/trace_manager.py,sha256=vmPup-C2pSgwpSdcCzAjzP_nTtRWZgqlxnNT50ygOfk,3843
28
+ uipath/core/tracing/types.py,sha256=8A8fFuWqMGk0SzIrFbMajmY6LA3w57h-YA602OctCrI,634
29
+ uipath_core-0.2.0.dist-info/METADATA,sha256=QaPAikNEVglQuX5U4GVytJ426EAsHleGxBRJ-yzOTm4,938
30
+ uipath_core-0.2.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
31
+ uipath_core-0.2.0.dist-info/licenses/LICENSE,sha256=-KBavWXepyDjimmzH5fVAsi-6jNVpIKFc2kZs0Ri4ng,1058
32
+ uipath_core-0.2.0.dist-info/RECORD,,