@@ -75,50 +75,6 @@ def _simple_serialize_defaults(obj):
7575 return str (obj )
7676
7777
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-
12278def format_args_for_trace_json (
12379 signature : inspect .Signature , * args : Any , ** kwargs : Any
12480) -> str :
0 commit comments