From 21515ed9dfe314ff194d60d45feda79bf8ce7066 Mon Sep 17 00:00:00 2001 From: mcorbin Date: Sun, 8 Dec 2019 15:19:03 +0100 Subject: [PATCH] Add metrics on git commands --- src/meuse/git.clj | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/meuse/git.clj b/src/meuse/git.clj index 02c353a..04b8d25 100644 --- a/src/meuse/git.clj +++ b/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] @@ -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]