Commit graph

304 commits

Author SHA1 Message Date
Ruth Linehan
55d565acd7 (TK-316) Rename bytes-read to full-response
Rename the Metric Types from `bytes-read`/`init-repsonse` to
`full-response`/`initial-response` (note that the `initial-response` timer has
not yet been implemented, but when it is this will be its name).
2016-04-22 15:08:52 -07:00
Ruth Linehan
19b9208094 (TK-316) Use upstream implementation logic for getOrAddTimer
We are subclassing `Timer` to create our own `ClientTimer` instances.
Unfortunately, the method we would like to use to register these on the
MetricRegistry, `getOrAdd()`, is private. Instead, we have to have our own
`getOrAddTimer()` to handle getting the timer if it has already been
registered, or registering a new one. This commit updates our implementation
of `getOrAddTimer()` to match the logic of `getOrAdd()`.
2016-04-22 15:04:47 -07:00
Ruth Linehan
b744e99749 (TK-316) Improve metrics API
This commit does several things to improve the metrics API:

* Move get-client-metrics(-data) functions off of client:
Previously, the `get-client-metrics(-data)`/`.getClientMetrics(Data)`
functions were on the client. This didn't entirely make sense because if two
clients were using the same metric registry, these functions would actually
return metrics data for *all* clients, rather than just for the client the
function was called on. This commit removes these functions and changes the
tests to use the metrics namepsace/Metrics class versions instead, which take
a metric registry return all http-client related metrics on that metric
registry.

* Add a `with-url-and-method` namespace:
Move the timers that have both the url and the method from the `with-url`
namespace to a new `with-url-and-method` namepsace. This better matches the
data structure are returned in and the filtering mechanisms for getting them
back out (discussed below), and also removes a slight chance of having a
conflict with a url timer.

* Add a ClientTimer class:
Add a ClientTimer class that wraps the Timer class and also holds onto the
url, method, or metric id used to create the timer. Use this to add url,
method, metricId to ClientMetricData.

* Change the `getClientMetrics(Data)` methods to return a map of metric
category to an array of timers or timer data:
Previously, the methods for getting http client metrics/metric data out of a
metric registry returned a map of metric name to timer instance or metric
data. However, the metric name was most likely not useful to users, who
probably just want to iterate through the timers/data. This commit makes the
output of these functions more useful by returning arrays of timers/data
sorted into a map indexed by metric category (url, url and method, or metric
id).

* Add `getClientMetricsBy*` methods:
Add `getClientMetrics(Data)ByUrl`, `getClientMetrics(Data)ByUrlAndMethod`, and
`getClientMetrics(Data)ByMetricId` methods (and clojure versions) that allow
for filtering by a specific metric category and return an array of timers or
timer data that match the url, url and method, or metric id specified.

* Remove the filter-builder functions:
Previously, the `get-client-metrics(-data)` functions did filtering by taking
a filter map, and there were filter-builder functions to build these filter
maps. Now that there are separate filtering methods, these filter maps are no
longer used and the filter-builder functions are removed.
2016-04-19 13:13:10 -07:00
Ruth Linehan
df4e36a1aa (TK-316) Add metrics support
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.
2016-04-19 13:13:10 -07:00
Jeremy Barlow
fb39b41260 Merge pull request #50 from rlinehan/client-init-refactor
(TK-179) Refactor clojure client initialization
2016-02-16 07:42:36 -08:00
Ruth Linehan
ecad9f730a (TK-179) Have JavaClient/createClient do coercion of client options
Previously, anything that called `JavaClient/createClient` performed the same
coercion on the client options before passing them in as the argument.  This
commit refactors `createClient` to do this coercion itself, thereby removing a
bunch of duplication.

Also, remove the `common/Client` schema and replace it with the
`HttpAsyncClient` interface, and remove an unnecessary call to `.start` in the
clojure `create-client`.
2016-02-12 14:59:06 -08:00
Ruth Linehan
a801ae5b02 (TK-179) Cleanup for PR feedback
* Remove comment about :sslengine as an option, because it no longer seems to
be supported.
* Remove duplicate `.setSslContext`
* Use -> macro to clean up client creation and coersion of options
* Remove outdated TODO on the `common/Client` schema
* Remove unused `SslOptions` schema
* Remove unused imports
2016-02-08 14:15:41 -05:00
Ruth Linehan
4176251521 (TK-179) Remove unused ssl config functions
These functions were previously used for initializing an ssl context for the
clojure http client. However, with the clojure client initialization now just
wrapping the java code, these are no longer needed.
2016-02-08 14:00:07 +00:00
Ruth Linehan
80ed08e75b (TK-179) Refactor clojure client init to use JavaClient/createClient
Previously, there were two completely separate code paths for java and clojure
http client initialization. This meant that there was a lot of duplicated
logic between them for handling a number of client options, such as redirect
strategy, ssl protocols and ciphers, and ssl setup.

This refactors clojure client initialization to use JavaClient/createClient,
thereby removing a lot of this duplication.
2016-02-08 13:59:22 +00:00
Ruth Linehan
24b3d52845 Merge pull request #47 from scottyw/tk179/consolidation
(TK-179) Modify the Clojure implementation to share more of the Java impl
2016-02-04 17:40:05 +00:00
Scott Walker
66c584fff4 Handle an empty content type in the response 2016-02-04 13:11:27 +00:00
Scott Walker
63962dbe45 Apply callback during failure/cancellation. 2016-02-04 12:08:32 +00:00
Scott Walker
41836a72ad Add async/sync test to check that a bad HTTP verb is rejected 2016-02-04 11:07:07 +00:00
Scott Walker
e71c5b8434 Throw error on bad HTTP verb in Clojure 2016-02-04 10:47:24 +00:00
Scott Walker
8548bbb4d7 (TK-179) Modify the Clojure implementation to share more of the Java impl
This commit removes duplicate functionality from the Clojure implementation and reuses the Java request/response handling impl. It doesn't address client creation so there are still two distinct paths for that.

The main changes are Ring <-> Java request/response conversion and the addition of interface ResponseDeliveryDelegate. The delegate implementations take care of the language-specific aspects of response building and promise delivery. One of the Clojure test namespaces is removed too.
2016-02-04 10:47:18 +00:00
Jenkins CI
5a9d80d90e Version 0.5.1-SNAPSHOT 2016-02-02 15:42:30 -08:00
Jenkins CI
c3ac698398 Version 0.5.0 2016-02-02 15:42:25 -08:00
Chris Price
a598a75592 Merge pull request #49 from adreyer/changelog
(maint) update changelog for 0.4.7 release.
2016-02-02 15:31:58 -08:00
Alex Dreyer
6e11d2074f (maint) update changelog for 0.4.7 release. 2016-02-02 15:23:23 -08:00
Preben Ingvaldsen
9d032c1a69 Merge pull request #46 from adreyer/add-request
Add a general request function to the client protocol.
2016-02-02 10:37:49 -08:00
Alex Dreyer
a383bd7046 Add a general request function to the client protocol.
There are a few places where we map request method keywords to
http-client function. The http client then maps them back to keywords
which is redundant. This adds a general request function to the protocol
that accepts a keyword method.
2016-01-29 08:45:44 -08:00
Scott Walker
a50b3ef7a3 Merge pull request #48 from rlinehan/update-gitignore
(maint) Update .gitignore
2016-01-25 15:22:26 +00:00
Ruth Linehan
1ad1434d7b (maint) Update .gitignore
Update .gitignore to exclude anything that starts with `.lein` (e.g.
`.lein-failures` or `.lein-repl-history`).
2016-01-25 14:31:18 +00:00
Ruth Linehan
e66a9847d9 Merge pull request #45 from scottyw/tk312/unbuffered-stream-in-java
(TK-312) Unbuffered streams in Java
2016-01-19 18:20:51 +01:00
Scott Walker
15b13fed4f Update Java API to include ResponseBodyType.UNBUFFERED_STREAM and update Clojure implementation to give consistent HttpContext usage with both clj and Java 2016-01-15 14:31:36 +00:00
Scott Walker
a5ed1d0bf8 Move unbuffered stream Clojure tests into a separate namespace 2016-01-11 07:57:12 +00:00
Jenkins CI
e431b5036f Version 0.4.7-SNAPSHOT 2016-01-09 16:42:34 -08:00
Jenkins CI
2b7af91c24 Version 0.4.6 2016-01-09 16:42:27 -08:00
Chris Price
840edf62be Merge pull request #44 from cprice404/maint/master/update-changelog-for-0.4.6-release
(MAINT) Update CHANGELOG for 0.4.6 release
2016-01-09 16:35:33 -08:00
Chris Price
876fd1c163 (MAINT) Update CHANGELOG for 0.4.6 release 2016-01-09 16:32:49 -08:00
Jeremy Barlow
06910455a5 Merge pull request #43 from cprice404/maint/master/update-to-httpasyncclient-4.1.1
(TK-303) Update to latest apache httpasyncclient
2016-01-07 10:28:23 -08:00
Chris Price
e7c9d22aa4 (MAINT) Update to latest apache httpasyncclient
This commit updates us to the latest version of the Apache
HTTPAsyncClient.  This is necessary in order to make it
possible to use this library in the same VM as the latest
version of clj-http, because they have some common dependencies.

The commit also cleans up some other dependencies while I was
in there.
2015-12-18 12:21:27 -08:00
Jenkins CI
7c4f95ddfd Version 0.4.6-SNAPSHOT 2015-10-13 07:13:14 -07:00
Jenkins CI
3a1aec68c7 Version 0.4.5 2015-10-13 07:13:06 -07:00
David McCauley
d72f8393a5 Merge pull request #42 from scottyw/clojure-unbuffered-stream
(PE-11976) Add option to return response early and stream body asynchronously
2015-10-13 15:04:57 +01:00
Scott Walker
fbab9a37bc Rework tests for improved clarity and AsyncConsumer releaseResources() fix 2015-10-13 12:09:50 +01:00
Scott Walker
e20d5cf7e3 Update docs 2015-10-12 19:15:26 +01:00
Scott Walker
862090251c Incorporate comments from camlow325
- Fixes to ExceptionInsertingPipedInputStream
- Fix to async consumer and removal of decompression code
- Use ResponseContentEncoding to do all decompression including removing previous approach
- Clarify tests and add ConnectionException
2015-10-07 17:45:18 +01:00
Scott Walker
ca5ad63179 (PE-11976) Add option to return the response early and stream the body asynchronously
Adds a new :as option that uses Apache's AsyncConsumer to return the response as quickly as possible then asynchronously stream the response body using piped input/output streams.
2015-10-05 15:38:30 +01:00
Preben Ingvaldsen
99f9b840af Merge pull request #41 from camlow325/maint/master/PE-11025-add-support-section-to-readme
(PE-11025) Add support section to README.md
2015-07-20 10:26:40 -07:00
Jeremy Barlow
91475cc71a (PE-11025) Add support section to README.md
This commit adds a support section to the README.md.
2015-07-17 11:06:25 -07:00
Jeremy Barlow
146d2fb4bc Merge pull request #40 from jpinsonault/tk-182-illegal-arg-exception-on-204-response
(TK-182) Illegal argument exception on 204 response
2015-04-24 12:07:02 -07:00
Joe Pinsonault
c5489e0e43 (MAINT) Added fix/test for java coerceBodyType 2015-04-24 10:17:30 -07:00
Joe Pinsonault
08ca923e69 (MAINT) nil body is coerced into empty string 2015-04-24 10:17:05 -07:00
Joe Pinsonault
c906d5abd0 (TK-182) coerce-body-type handles nil body 2015-04-24 10:05:29 -07:00
Chris Price
b68dda3ae2 (MAINT) Update CHANGELOG for 0.4.4 release 2015-04-15 15:44:55 +01:00
Jenkins CI
8a03faacd6 Version 0.4.5-SNAPSHOT 2015-04-15 07:33:01 -07:00
Jenkins CI
52a4fc7be4 Version 0.4.4 2015-04-15 07:32:57 -07:00
Chris Price
4af8813899 Merge pull request #39 from dparis/fix/master/update-prismatic-deps
(TK-196) Update prismatic library dependencies
2015-04-15 15:21:39 +01:00
Dylan Paris
a75a9eea4b (TK-196) Update prismatic library dependencies
The prismatic/plumbing and prismatic/schema library dependencies are
lagging behind the latest stable version. This will increasingly
cause conflicts in trapperkeeper projects. This patch updates the
dependencies and fixes several functions which were validating against
schemas incompatible with the new versions.

* Update project.clj dependencies
* Use protocol schema instead of the protocol object directly
2015-04-09 15:03:57 -07:00