diff --git a/src/clj/auto_ap/graphql.clj b/src/clj/auto_ap/graphql.clj index 8f554d17..5c9ace2b 100644 --- a/src/clj/auto_ap/graphql.clj +++ b/src/clj/auto_ap/graphql.clj @@ -35,7 +35,8 @@ [datomic.api :as d] [unilog.context :as lc] [yang.time :refer [time-it]] - [com.unbounce.dogstatsd.core :as statsd]) + [com.unbounce.dogstatsd.core :as statsd] + [com.walmartlabs.lacinia.parser :as p]) (:import (clojure.lang IPersistentMap))) @@ -1326,14 +1327,21 @@ node)) m)) +(defn query-name [q] + (try + (str/join "," (map name (:operations (p/operations (p/parse-query schema q))))) + (catch Exception e + "unknown query"))) + (defn query ([id q] (query id q nil)) ([id q v] (statsd/increment "queries") - (statsd/time! [(subs q 0 (min 50 (count q))) {}] + (statsd/increment (query-name q)) + (statsd/time! [(query-name q) {}] (lc/with-context {:query q} - (log/info "Executing query" q) + (log/info "executing query name" (query-name q)) (try (let [[result time] (time-it (simplify (execute schema q v {:id id})))] (info-event "Query completed"