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

Commit e8bc0c8

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

4 files changed

Lines changed: 910 additions & 51 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 & 5 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)

0 commit comments

Comments
 (0)