mirror of
https://github.com/penpot/penpot.git
synced 2025-12-11 22:14:05 +01:00
✨ Add better logging context report on worker runner
This commit is contained in:
@@ -319,5 +319,9 @@
|
||||
([key default]
|
||||
(c/get config key default)))
|
||||
|
||||
(defn logging-context
|
||||
[]
|
||||
{:version/backend (:full version)})
|
||||
|
||||
;; Set value for all new threads bindings.
|
||||
(alter-var-root #'*assert* (constantly (contains? flags :backend-asserts)))
|
||||
|
||||
@@ -25,15 +25,14 @@
|
||||
(let [claims (-> {}
|
||||
(into (::session/token-claims request))
|
||||
(into (::actoken/token-claims request)))]
|
||||
{:request/path (:path request)
|
||||
:request/method (:method request)
|
||||
:request/params (:params request)
|
||||
:request/user-agent (yreq/get-header request "user-agent")
|
||||
:request/ip-addr (inet/parse-request request)
|
||||
:request/profile-id (:uid claims)
|
||||
:version/frontend (or (yreq/get-header request "x-frontend-version") "unknown")
|
||||
:version/backend (:full cf/version)}))
|
||||
|
||||
(-> (cf/logging-context)
|
||||
(assoc :request/path (:path request))
|
||||
(assoc :request/method (:method request))
|
||||
(assoc :request/params (:params request))
|
||||
(assoc :request/user-agent (yreq/get-header request "user-agent"))
|
||||
(assoc :request/ip-addr (inet/parse-request request))
|
||||
(assoc :request/profile-id (:uid claims))
|
||||
(assoc :version/frontend (or (yreq/get-header request "x-frontend-version") "unknown")))))
|
||||
|
||||
(defmulti handle-error
|
||||
(fn [cause _ _]
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
[app.common.schema :as sm]
|
||||
[app.common.time :as ct]
|
||||
[app.common.transit :as t]
|
||||
[app.config :as cf]
|
||||
[app.db :as db]
|
||||
[app.metrics :as mtx]
|
||||
[app.redis :as rds]
|
||||
@@ -60,7 +61,8 @@
|
||||
|
||||
(defn get-error-context
|
||||
[_ item]
|
||||
{:params item})
|
||||
(-> (cf/logging-context)
|
||||
(assoc :params item)))
|
||||
|
||||
(defn- get-task
|
||||
[{:keys [::db/pool]} task-id]
|
||||
@@ -213,6 +215,7 @@
|
||||
:payload payload)))
|
||||
(catch Throwable cause
|
||||
(l/err :hint "unable to decode payload"
|
||||
::l/context (cf/logging-context)
|
||||
:payload payload
|
||||
:length (alength ^String/1 payload)
|
||||
:cause cause))))
|
||||
@@ -236,9 +239,9 @@
|
||||
:cause cause)
|
||||
(px/sleep timeout)
|
||||
(recur result))
|
||||
(do
|
||||
(l/err :hint "unhandled exception on processing task result"
|
||||
:cause cause))))))]
|
||||
(l/err :hint "unhandled exception on processing task result"
|
||||
::l/context (cf/logging-context)
|
||||
:cause cause)))))]
|
||||
|
||||
(try
|
||||
(let [key (str/ffmt "penpot.worker.queue:%" queue)
|
||||
@@ -254,11 +257,14 @@
|
||||
(if (rds/timeout-exception? cause)
|
||||
(do
|
||||
(l/err :hint "redis pop operation timeout, consider increasing redis timeout (will retry in some instants)"
|
||||
::l/context (cf/logging-context)
|
||||
:timeout timeout
|
||||
:cause cause)
|
||||
(px/sleep timeout))
|
||||
|
||||
(l/err :hint "unhandled exception" :cause cause))))))
|
||||
(l/err :hint "unhandled exception"
|
||||
::l/context (cf/logging-context)
|
||||
:cause cause))))))
|
||||
|
||||
(defn- start-thread!
|
||||
[{:keys [::id ::queue ::wrk/tenant] :as cfg}]
|
||||
@@ -284,6 +290,7 @@
|
||||
:queue queue))
|
||||
(catch Throwable cause
|
||||
(l/err :hint "unexpected exception"
|
||||
::l/context (cf/logging-context)
|
||||
:id id
|
||||
:queue queue
|
||||
:cause cause))
|
||||
|
||||
Reference in New Issue
Block a user