much more background process tracking

This commit is contained in:
2022-06-22 10:43:37 -07:00
parent 480066b202
commit 1db8d7a52c
15 changed files with 379 additions and 486 deletions

View File

@@ -1,7 +1,9 @@
(ns auto-ap.utils
#?@
(:clj
[(:require [com.unbounce.dogstatsd.core :as statsd])]))
[(:require [com.unbounce.dogstatsd.core :as statsd]
[clojure.tools.logging :as log]
[unilog.context :as lc])]))
(defn by
([f xs]
@@ -87,9 +89,19 @@
(defn heartbeat [f id]
(fn []
#?(:clj (do
(f)
(statsd/service-check {:name (str id)
:status :ok}
nil))
(lc/with-context {:source id}
(try
(log/info "Starting background process " id)
(f)
(log/info "Completed background process " id)
(statsd/service-check {:name (str id)
:status :ok}
nil)
(catch Exception e
(log/error e)
(statsd/service-check {:name (str id)
:status :critical}
nil)))))
:cljs (do (println "Heartbeat for " id)
(f)))))