Skip to content

Commit

Permalink
Add metrics for fetching and storing words
Browse files Browse the repository at this point in the history
Related to #28
  • Loading branch information
egli committed Mar 1, 2021
1 parent c967ec4 commit 1555e69
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/clj/daisyproducer2/words/confirm.clj
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
(ns daisyproducer2.words.confirm
(:require [conman.core :as conman]
[daisyproducer2.db.core :as db]
[daisyproducer2.metrics :as metrics]
[daisyproducer2.words :as words]
[daisyproducer2.words.global :as global]
[daisyproducer2.words.local :as local]))
[daisyproducer2.words.local :as local]
[iapetos.collector.fn :as prometheus]))

(defn get-words [limit offset]
(->> (db/get-confirmable-words-aggregated {:limit limit :offset offset})
Expand Down Expand Up @@ -40,3 +42,5 @@
;; the number of additions.
(global/put-word word))))))

(prometheus/instrument! metrics/registry #'get-words)
(prometheus/instrument! metrics/registry #'put-word)
11 changes: 8 additions & 3 deletions src/clj/daisyproducer2/words/global.clj
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
(ns daisyproducer2.words.global
(:require [clojure.string :as string]
[clojure.tools.logging :as log]
(:require [clojure.tools.logging :as log]
[daisyproducer2.db.core :as db]
[daisyproducer2.metrics :as metrics]
[daisyproducer2.whitelists.hyphenation :as hyphenations]
[daisyproducer2.words :as words]))
[daisyproducer2.words :as words]
[iapetos.collector.fn :as prometheus]))

(defn get-words [{:keys [untranslated limit offset]}]
(-> (db/find-global-words {:untranslated (db/search-to-sql untranslated)
Expand Down Expand Up @@ -33,3 +34,7 @@
(words/to-db word words/hyphenation-keys words/hyphenation-mapping))
(hyphenations/export))
deletions))

(prometheus/instrument! metrics/registry #'get-words)
(prometheus/instrument! metrics/registry #'put-word)
(prometheus/instrument! metrics/registry #'delete-word)
8 changes: 7 additions & 1 deletion src/clj/daisyproducer2/words/local.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
(:require [clojure.string :as string]
[clojure.tools.logging :as log]
[daisyproducer2.db.core :as db]
[daisyproducer2.metrics :as metrics]
[daisyproducer2.whitelists.async :as whitelists]
[daisyproducer2.whitelists.hyphenation :as hyphenations]
[daisyproducer2.words :as words]))
[daisyproducer2.words :as words]
[iapetos.collector.fn :as prometheus]))

(defn get-words
"Retrieve all local words for given document-id `id`, `grade` and
Expand Down Expand Up @@ -61,3 +63,7 @@
(hyphenations/export))
(whitelists/export-local-tables (:document-id word))
deletions))

(prometheus/instrument! metrics/registry #'get-words)
(prometheus/instrument! metrics/registry #'put-word)
(prometheus/instrument! metrics/registry #'delete-word)
4 changes: 4 additions & 0 deletions src/clj/daisyproducer2/words/unknown.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
[clojure.string :as string]
[clojure.tools.logging :as log]
[daisyproducer2.db.core :as db]
[daisyproducer2.metrics :as metrics]
[daisyproducer2.words :as words]
[iapetos.collector.fn :as prometheus]
[sigel.xpath.core :as xpath]
[sigel.xslt.core :as xslt]))

Expand Down Expand Up @@ -140,3 +142,5 @@
(map words/complement-braille)
(map words/complement-ellipsis-braille)
(map words/complement-hyphenation)))

(prometheus/instrument! metrics/registry #'get-words)

0 comments on commit 1555e69

Please sign in to comment.