diff options
Diffstat (limited to 'osprofiler/_utils.py')
-rw-r--r-- | osprofiler/_utils.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/osprofiler/_utils.py b/osprofiler/_utils.py index 7563fb5..d903b9b 100644 --- a/osprofiler/_utils.py +++ b/osprofiler/_utils.py @@ -161,3 +161,15 @@ def shorten_id(span_id): # Return a new short id for this short_id = shorten_id(uuidutils.generate_uuid()) return short_id + + +def uuid_to_int128(span_uuid): + """Convert from uuid4 to 128 bit id for OpenTracing""" + if isinstance(span_uuid, int): + return span_uuid + try: + span_int = uuid.UUID(span_uuid).int + except ValueError: + # Return a new short id for this + span_int = uuid_to_int128(uuidutils.generate_uuid()) + return span_int |