Coverage for langsmith/_internal/_otel_utils.py: 40%

10 statements  

« prev     ^ index     » next       coverage.py v7.10.1, created at 2025-12-11 16:15 -0800

1from __future__ import annotations 

2 

3from uuid import UUID 

4 

5 

6def get_otel_trace_id_from_uuid(uuid_val: UUID) -> int: 

7 """Get OpenTelemetry trace ID as integer from UUID. 

8 

9 Args: 

10 uuid_val: The UUID to convert. 

11 

12 Returns: 

13 Integer representation of the trace ID. 

14 """ 

15 trace_id_hex = uuid_val.hex 

16 return int(trace_id_hex, 16) 

17 

18 

19def get_otel_span_id_from_uuid(uuid_val: UUID) -> int: 

20 """Get OpenTelemetry span ID as integer from UUID. 

21 

22 Args: 

23 uuid_val: The UUID to convert. 

24 

25 Returns: 

26 Integer representation of the span ID. 

27 """ 

28 uuid_bytes = uuid_val.bytes 

29 span_id_bytes = uuid_bytes[:8] 

30 span_id_hex = span_id_bytes.hex() 

31 return int(span_id_hex, 16)