Right now when you add an object to your log like this:
logger.info(
"request_started",
request=request,
user_agent=request.META.get("HTTP_USER_AGENT"),
)
You end up with TypeError like this: <WSGIRequest: GET '/healthcheck/'> is not JSON serializable in json_dumps (ecs_logging/_utils.py):
if value:
return "{%s,%s" % (
ordered_json,
json.dumps(value, sort_keys=True, separators=(",", ":"))[1:],
)
You should use a default argument for json.dumps and provide fallback mechanism to handle this situation. See https://www.structlog.org/en/stable/_modules/structlog/processors.html#JSONRenderer and _json_fallback_handler.
Right now when you add an object to your log like this:
You end up with
TypeErrorlike this:<WSGIRequest: GET '/healthcheck/'> is not JSON serializableinjson_dumps(ecs_logging/_utils.py):You should use a
defaultargument forjson.dumpsand provide fallback mechanism to handle this situation. See https://www.structlog.org/en/stable/_modules/structlog/processors.html#JSONRenderer and_json_fallback_handler.