diff options
author | Sahid Orentino Ferdjaoui <sahid.ferdjaoui@industrialdiscipline.com> | 2023-03-14 12:22:47 +0100 |
---|---|---|
committer | Sahid Orentino Ferdjaoui <sahid.ferdjaoui@industrialdiscipline.com> | 2023-05-10 10:18:48 +0200 |
commit | 908e7402320eb067db45aa9700d54d31c259f3ca (patch) | |
tree | 75631a7f7c79d7f546ebf25b1e12fbf8c86e170d /osprofiler/_utils.py | |
parent | 4f3eaa411c6ad731e831bafcb664a4649a1a75a5 (diff) | |
download | osprofiler-master.tar.gz |
Depends-On: Idcff5d79b4884dd1cc7ed1ab42c9e4ce89d4a6d2
Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@industrialdiscipline.com>
Change-Id: I74cdcb2aa99b0162ba1c14059111f09d0bb534e3
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 |