Fix Datadog JSON serialization

Nested dicts were not being serialized properly
This commit is contained in:
Idris Mokhtarzada
2024-07-27 02:16:36 -04:00
committed by GitHub
parent 9bdcef238b
commit c2c5877afa
+3 -2
View File
@@ -1,5 +1,5 @@
#### What this does ####
# On success + failure, log events to Supabase
# On success + failure, log events to Datadog
import dotenv, os
import requests # type: ignore
@@ -15,12 +15,13 @@ def make_json_serializable(payload):
if isinstance(value, dict):
# recursively sanitize dicts
payload[key] = make_json_serializable(value.copy())
if not isinstance(value, (str, int, float, bool, type(None))):
elif not isinstance(value, (str, int, float, bool, type(None))):
# everything else becomes a string
payload[key] = str(value)
except:
# non blocking if it can't cast to a str
pass
return payload
class DataDogLogger: