fal-ai / fal

⚡ Fastest way to serve open source ML models to millions
https://fal.ai/docs
Apache License 2.0
201 stars 18 forks source link

feat: wrap tracebacks in JSON for easy detection #245

Closed squat closed 1 week ago

squat commented 1 week ago

Right now, multi-line tracebacks are spread out and ingested independently into the underlying logging system. This makes it hard to retrieve the entirety of a traceback without some hacky heuristics. To enable easy searching and retrieval of tracebacks, we catch all uncaught exceptions and log them as JSON, this way the whole traceback is in one single JSON line, which can be extracted by looking at the traceback key.

An alternative would be to print the traceback in unicode_escape encoding and then to to decode the string during log retrieval. This would remove the need for a JSON wrapping.

Signed-off-by: squat lserven@gmail.com

linear[bot] commented 1 week ago

FEA-2750 Add ability to filter for tracebacks

squat commented 1 week ago

weird, mypy is wrong here: https://github.com/fal-ai/fal/actions/runs/9567480026/job/26375314286?pr=245#step:4:96 traceback.format_exception accepts any Exception and the value and tb arguments are optional: https://docs.python.org/3/library/traceback.html#traceback.format_exception

In my manual tests the tracebacks are logged perfectly in the desired format. Adding a # type: ignore for tests to pass. Weirdly mypy doesn't complain in my local editor.