This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-24
Channels
- # aws (2)
- # babashka (27)
- # beginners (97)
- # calva (1)
- # cherry (12)
- # cider (6)
- # clara (12)
- # clj-kondo (24)
- # clj-on-windows (4)
- # cljfx (14)
- # clojure (54)
- # clojure-australia (3)
- # clojure-europe (26)
- # clojure-nl (1)
- # clojure-norway (4)
- # clojure-uk (9)
- # clojurescript (65)
- # conjure (5)
- # cursive (7)
- # datomic (18)
- # emacs (6)
- # helix (2)
- # honeysql (1)
- # jobs (1)
- # joyride (15)
- # kaocha (2)
- # lsp (10)
- # malli (5)
- # nbb (12)
- # observability (5)
- # off-topic (5)
- # reitit (2)
- # releases (4)
- # ring (1)
- # sci (17)
- # shadow-cljs (34)
- # testing (29)
- # tools-deps (45)
- # vim (7)
- # xtdb (6)
code i wrote recently to get logs:
;; credit for lazy-concat this goes to juxt post on iterat
(defn lazy-concat
"A concat version that is completely lazy and
does not require to use apply."
[colls]
(lazy-seq
(when-first [c colls]
(lazy-cat c (lazy-concat (rest colls))))))
(defn log-group-name->logs
"given a `log-group-name` (e.g 'staging') returns the log locally"
[log-group-name]
(->> (iteration
(fn [token]
(icc :DescribeLogStreams
(cond-> {:logGroupName log-group-name} token (assoc :nextToken token))))
:vf (fn [{:keys [logStreams]}]
(reduce
(fn [all-log-streams log-stream]
(concat all-log-streams (-> (icc :GetLogEvents
(-> log-stream
(select-keys [:logStreamName])
(assoc :logGroupName log-group-name)))
:events)))
[]
logStreams))
:kf :nextToken)
;;TODO make this lazy by using something other then apply concat
lazy-concat))
And then i do this:
(defn get-codebuild-logs []
(log-group-name->logs "/aws/codebuild/cacapi-training-codebuildproject"))
(transduce
(halt-when (fn [{:keys [message]}] (str/includes? message "FAILED"))
(fn [completed-result input-triggered] {:trigger input-triggered
:last-5-leading-upto-it (take-last 5 completed-result)}))
conj
codebuild-logs)
It still takes about 15 seconds, which is 15 seconds longer then i would like.. I mean, that seems really slow honestly. Whats going on here? Do i have some huge area for improvement or is aws just throttling requests because they want me to use the console (i'm only half joking).