Skip to content

Commit 0fca713

Browse files
fix
1 parent 066eaa2 commit 0fca713

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

drift/instrumentation/redis/instrumentation.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,9 @@ def _serialize_value(self, value: Any) -> Any:
10911091
return {"__bytes__": True, "encoding": "utf8", "value": decoded}
10921092
except UnicodeDecodeError:
10931093
return {"__bytes__": True, "encoding": "hex", "value": value.hex()}
1094-
elif isinstance(value, (str, int, float, bool, type(None))):
1094+
elif isinstance(value, float):
1095+
return {"__float__": True, "value": value}
1096+
elif isinstance(value, (str, int, bool, type(None))):
10951097
return value
10961098
elif isinstance(value, (list, tuple)):
10971099
return [self._serialize_value(v) for v in value]
@@ -1109,7 +1111,6 @@ def _serialize_response(self, response: Any) -> Any:
11091111
def _deserialize_value(self, value: Any) -> Any:
11101112
"""Deserialize a value, converting typed wrappers back to original types."""
11111113
if isinstance(value, dict):
1112-
# Check for bytes wrapper
11131114
if value.get("__bytes__") is True:
11141115
encoding = value.get("encoding")
11151116
data = value.get("value", "")
@@ -1118,6 +1119,8 @@ def _deserialize_value(self, value: Any) -> Any:
11181119
elif encoding == "hex":
11191120
return bytes.fromhex(data)
11201121
return data # fallback
1122+
if value.get("__float__") is True:
1123+
return float(value.get("value", 0.0))
11211124
# Recursively deserialize dict values
11221125
return {k: self._deserialize_value(v) for k, v in value.items()}
11231126
elif isinstance(value, list):

0 commit comments

Comments
 (0)