df4e36a1aa
This commit adds metrics support to the http client (clojure and java, sync and async). A metric registry can optionally be passed into the client as a client option on creation. If a metric registry is present, timers will be added to time each request. By default, a timer is added for the URL (stripped of username, password, query string, and path fragments) and the URL plus the method used for the request. In addition, a request can include a `metric-id` option, which takes a tuple of metric ids. If this request option is specified, a timer will be created for each element of the metric id tuple - thus if the tuple is [:foo :bar :baz] there will be a foo timer, a foo.bar timer, and a foo.bar.baz timer. In addition, each timer has a "MetricType" - currently there is only one metric type, bytes-read, which is stopped when the full response has been read. In the future, we may add "response-init" timers that get stopped when the first byte of the response has been read. This commit also adds a `get-client-metrics`/`.getClientMetrics` function that takes a client instance and returns the http client-specific metrics from the metric registry and a `get-client-metrics-data`/`.getClientMetricsData` function for clojure and java sync and async clients to get out metrics data from the client. This function takes a client instance and returns a map of metric name to a map of metric data (for clojure) or a ClientMetricData object (for java), both of which include the mean, count, and aggregate for the timer These `get-client-metrics*`/`.getClientMetrics*` functions also have versions that take a url, url and method, or metric id to allow for filtering of the timers/metrics data returned by these functions. The clojure versions of these functions take a metric filter map. There are also metric filter builder functions to build up the type of metric filter desired from a url, a url and method, or a metric id. These will prevent users from having to know the specifics of how to build a metric themselves; instead they can use a convenience function. An empty metric id can be passed in to the filter to return all metric-id timers.
54 lines
2.5 KiB
Clojure
54 lines
2.5 KiB
Clojure
(def ks-version "1.2.0")
|
|
(def tk-version "1.1.1")
|
|
(def tk-jetty-version "1.5.0")
|
|
|
|
(defproject puppetlabs/http-client "0.5.1-SNAPSHOT"
|
|
:description "HTTP client wrapper"
|
|
:license {:name "Apache License, Version 2.0"
|
|
:url "http://www.apache.org/licenses/LICENSE-2.0.html"}
|
|
|
|
;; Abort when version ranges or version conflicts are detected in
|
|
;; dependencies. Also supports :warn to simply emit warnings.
|
|
;; requires lein 2.2.0+.
|
|
:pedantic? :abort
|
|
|
|
:dependencies [[org.clojure/clojure "1.7.0"]
|
|
|
|
[org.apache.httpcomponents/httpasyncclient "4.1.1"]
|
|
[org.apache.commons/commons-lang3 "3.4"]
|
|
[prismatic/schema "1.0.4"]
|
|
[org.slf4j/slf4j-api "1.7.13"]
|
|
[commons-io "2.4"]
|
|
[io.dropwizard.metrics/metrics-core "3.1.2"]
|
|
|
|
[puppetlabs/ssl-utils "0.8.1"]]
|
|
|
|
:source-paths ["src/clj"]
|
|
:java-source-paths ["src/java"]
|
|
:jar-exclusions [#".*\.java$"]
|
|
|
|
;; By declaring a classifier here and a corresponding profile below we'll get an additional jar
|
|
;; during `lein jar` that has all the source code (including the java source). Downstream projects can then
|
|
;; depend on this source jar using a :classifier in their :dependencies.
|
|
:classifiers [["sources" :sources-jar]]
|
|
|
|
:profiles {:dev {:dependencies [[puppetlabs/kitchensink ~ks-version :classifier "test"]
|
|
[puppetlabs/trapperkeeper ~tk-version]
|
|
[puppetlabs/trapperkeeper ~tk-version :classifier "test"]
|
|
[puppetlabs/trapperkeeper-webserver-jetty9 ~tk-jetty-version]
|
|
[puppetlabs/trapperkeeper-webserver-jetty9 ~tk-jetty-version :classifier "test"]]
|
|
;; TK-143, enable SSLv3 for unit tests that exercise SSLv3
|
|
:jvm-opts ["-Djava.security.properties=./dev-resources/java.security"]}
|
|
:sources-jar {:java-source-paths ^:replace []
|
|
:jar-exclusions ^:replace []
|
|
:source-paths ^:replace ["src/clj" "src/java"]}}
|
|
|
|
:deploy-repositories [["releases" {:url "https://clojars.org/repo"
|
|
:username :env/clojars_jenkins_username
|
|
:password :env/clojars_jenkins_password
|
|
:sign-releases false}]]
|
|
|
|
:lein-release {:scm :git
|
|
:deploy-via :lein-deploy}
|
|
|
|
:plugins [[lein-release "1.0.5" :exclusions [org.clojure/clojure]]])
|