mirror of
https://github.com/penpot/penpot.git
synced 2025-07-19 19:57:22 +02:00
♻️ Refactor error reporting and logging context formatting
The prev approach uses clojure.pprint without any limit extensivelly for format error context data and all this is done on the calling thread. The clojure.pprint seems very inneficient in cpu and memory usage on pprinting large data structures. This is improved in the following way: - All formatting and pretty printing is moved to logging thread, reducing unnecesary blocking and load on jetty http threads. - Replace the clojure.pprint with fipp.edn that looks considerably faster than the first one. - Add some safe limits on pretty printer for strip printing some data when the data structure is very large, very deep or both.
This commit is contained in:
parent
2c25dfcf1b
commit
827c2140b7
10 changed files with 84 additions and 75 deletions
|
@ -249,10 +249,16 @@
|
|||
|
||||
(defn get-error-context
|
||||
[error item]
|
||||
(let [edata (ex-data error)]
|
||||
{:id (uuid/next)
|
||||
:data edata
|
||||
:params item}))
|
||||
(let [data (ex-data error)]
|
||||
(merge
|
||||
{:id (uuid/next)
|
||||
:hint (ex-message error)
|
||||
:spec-problems (some->> data ::s/problems (take 10) seq vec)
|
||||
:spec-value (some->> data ::s/value)
|
||||
:data (some-> data (dissoc ::s/problems ::s/value ::s/spec))
|
||||
:params item}
|
||||
(when (and data (::s/problems data))
|
||||
{:spec-explain (us/pretty-explain data)}))))
|
||||
|
||||
(defn- handle-exception
|
||||
[error item]
|
||||
|
@ -266,8 +272,10 @@
|
|||
|
||||
(= ::noop (:strategy edata))
|
||||
(assoc :inc-by 0))
|
||||
(l/with-context (get-error-context error item)
|
||||
(l/error :cause error :hint "unhandled exception on task")
|
||||
(do
|
||||
(l/error :hint "unhandled exception on task"
|
||||
::l/context (get-error-context error item)
|
||||
:cause error)
|
||||
(if (>= (:retry-num item) (:max-retries item))
|
||||
{:status :failed :task item :error error}
|
||||
{:status :retry :task item :error error})))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue