Skip to content
This repository was archived by the owner on Mar 4, 2026. It is now read-only.

Commit f6f9112

Browse files
committed
fix: cleanup unused methods
1 parent 37009a9 commit f6f9112

5 files changed

Lines changed: 913 additions & 68 deletions

File tree

src/uipath/core/tracing/_utils.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import inspect
44
import json
5-
import random
6-
import uuid
75
from collections.abc import Callable
86
from dataclasses import asdict, is_dataclass
97
from datetime import datetime, timezone
@@ -75,50 +73,6 @@ def _simple_serialize_defaults(obj):
7573
return str(obj)
7674

7775

78-
def span_id_to_uuid4(span_id: int) -> uuid.UUID:
79-
"""Convert a 64-bit span ID to a valid UUID4 format.
80-
81-
Creates a UUID where:
82-
- The 64 least significant bits contain the span ID
83-
- The UUID version (bits 48-51) is set to 4
84-
- The UUID variant (bits 64-65) is set to binary 10
85-
"""
86-
# Generate deterministic high bits using the span_id as seed
87-
temp_random = random.Random(span_id)
88-
high_bits = temp_random.getrandbits(64)
89-
90-
# Combine high bits and span ID into a 128-bit integer
91-
combined = (high_bits << 64) | span_id
92-
93-
# Set version to 4 (UUID4)
94-
combined = (combined & ~(0xF << 76)) | (0x4 << 76)
95-
96-
# Set variant to binary 10
97-
combined = (combined & ~(0x3 << 62)) | (2 << 62)
98-
99-
# Convert to hex string in UUID format
100-
hex_str = format(combined, "032x")
101-
return uuid.UUID(hex_str)
102-
103-
104-
def trace_id_to_uuid4(trace_id: int) -> uuid.UUID:
105-
"""Convert a 128-bit trace ID to a valid UUID4 format.
106-
107-
Modifies the trace ID to conform to UUID4 requirements:
108-
- The UUID version (bits 48-51) is set to 4
109-
- The UUID variant (bits 64-65) is set to binary 10
110-
"""
111-
# Set version to 4 (UUID4)
112-
uuid_int = (trace_id & ~(0xF << 76)) | (0x4 << 76)
113-
114-
# Set variant to binary 10
115-
uuid_int = (uuid_int & ~(0x3 << 62)) | (2 << 62)
116-
117-
# Convert to hex string in UUID format
118-
hex_str = format(uuid_int, "032x")
119-
return uuid.UUID(hex_str)
120-
121-
12276
def format_args_for_trace_json(
12377
signature: inspect.Signature, *args: Any, **kwargs: Any
12478
) -> str:

src/uipath/core/tracing/decorators.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
import inspect
44
import json
55
import logging
6+
import random
67
from functools import wraps
78
from typing import Any, Callable, Optional
89

910
from opentelemetry import trace
10-
from opentelemetry.trace import NonRecordingSpan
11+
from opentelemetry.trace import NonRecordingSpan, SpanContext, TraceFlags
1112
from opentelemetry.trace.status import StatusCode
1213

1314
from uipath.core.tracing._utils import (
@@ -36,10 +37,6 @@ def decorator(func):
3637
def get_span():
3738
if not recording:
3839
# Create a valid but non-sampled trace context
39-
import random
40-
41-
from opentelemetry.trace import SpanContext, TraceFlags
42-
4340
# Generate a valid trace ID (not INVALID)
4441
trace_id = random.getrandbits(128)
4542
span_id = random.getrandbits(64)
@@ -277,8 +274,6 @@ def decorator(func):
277274
# Decorate the function with only supported parameters
278275
decorated_func = tracer_impl(**supported_params)(func)
279276

280-
# Register both original and decorated function with parameters
281-
UiPathTracingManager.register_traced_function(func, decorated_func, params)
282277
return decorated_func
283278

284279
return decorator

src/uipath/core/tracing/manager.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
class UiPathTracingManager:
1313
"""Static utility class to manage tracing implementations and decorated functions."""
1414

15-
# Registry to track original functions, decorated functions, and their parameters
16-
# Each entry is (original_func, decorated_func, params)
17-
_traced_registry: List[Tuple[Callable[..., Any], Callable[..., Any], Any]] = []
18-
1915
_current_span_provider: Optional[Callable[[], Any]] = None
2016

2117
@classmethod
@@ -41,6 +37,7 @@ def get_parent_context():
4137
"""
4238
# Always use the currently active OTel span if valid (recursion / children)
4339
current_span = trace.get_current_span()
40+
4441
if current_span is not None and current_span.get_span_context().is_valid:
4542
return set_span_in_context(current_span)
4643

@@ -54,18 +51,9 @@ def get_parent_context():
5451
logger.warning(f"Error getting current span from provider: {e}")
5552

5653
# Last fallback
57-
return context.get_current()
58-
59-
@classmethod
60-
def register_traced_function(cls, original_func, decorated_func, params):
61-
"""Register a function decorated with @traced and its parameters.
54+
ctx = context.get_current()
6255

63-
Args:
64-
original_func: The original function before decoration
65-
decorated_func: The function after decoration
66-
params: The parameters used for tracing
67-
"""
68-
cls._traced_registry.append((original_func, decorated_func, params))
56+
return ctx
6957

7058

7159
__all__ = ["UiPathTracingManager"]

0 commit comments

Comments
 (0)