Skip to content

Commit

Permalink
Add metrics on git commands
Browse files Browse the repository at this point in the history
  • Loading branch information
mcorbin committed Dec 8, 2019
1 parent 3427329 commit 21515ed
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/meuse/git.clj
@@ -1,6 +1,7 @@
(ns meuse.git
"Interacts with a git repository"
(:require [meuse.config :refer [config]]
[meuse.metric :as metric]
[exoscale.ex :as ex]
[mount.core :refer [defstate]]
[clojure.java.shell :as shell]
Expand All @@ -25,16 +26,17 @@
lock)
(git-cmd [this args]
(debug "git command" (string/join " " args))
(let [result (apply shell/sh "git" "-C" path args)]
(debug "git command status code=" (:exit result)
"out=" (:out result)
"err=" (:err result))
(when-not (= 0 (:exit result))
(throw (ex/ex-fault "error executing git command"
{:exit-code (:exit result)
:stdout (:out result)
:stderr (:err result)
:command args})))))
(metric/with-time :git.local ["command" (first args)]
(let [result (apply shell/sh "git" "-C" path args)]
(debug "git command status code=" (:exit result)
"out=" (:out result)
"err=" (:err result))
(when-not (= 0 (:exit result))
(throw (ex/ex-fault "error executing git command"
{:exit-code (:exit result)
:stdout (:out result)
:stderr (:err result)
:command args}))))))
(push [this]
(git-cmd this (concat ["push"] (string/split target #"/"))))
(pull [this]
Expand Down

0 comments on commit 21515ed

Please sign in to comment.