Add note to clojure client docs about precendence of `metric-prefix` option if
both it and `server-id` are specified as client options.
Also remove some empty lines.
Add two new client options - `server-id` and `metric-prefix` that allow the
metric namespace to be configured rather than always
`puppetlabs.http-client.experimental`.
If `server-id` is set, the metric namespace becomes
`puppetlabs.<server-id>.http-client.experimental`.
If `metric-prefix` is set, the metric namespace becomes
`<metric-prefix>.http-client.experimental`.
If both are set, `metric-prefix` wins out and a warning message is logged.
Also add a `get-client-metric-namespace`/`getMetricNamespace` method on the
client (clojure and java) to get back the metric namespace.
There was a bug in the previous version of the Apache HttpAsyncClient library
that caused the cline tto hang if the process had exhausted the number of open
file descriptors it was allowed. This bug was fixed in the 4.1.2 release,
which this commit bumps to.
The Clojure metrics API supports metric-ids as vectors of keywords or strings.
Previously, the docs only mentioned that keywords could be used. Strings
should be used if special characters are needed.
(MAINT) remove comments
(MAINT) change body message to reflect 400 status
(MAINT) change test to use Java and Clj API
(MAINT) refactor RequestOptions in let block of java api test
(MAINT) add tests for async cookie support
When constructing url timers for request metrics, we strip off any username,
password, query params, and path fragments on the request uri. This commit
provides a public method to do this conversion of a url, so that users can
take the url they used for their request and easily figure out the url we used
for the metric.
Previously, if any of the `get-client-metrics*` methods (in Clojure or Java)
had a nil metric registry passed into them, they would return nil. This commit
updates the behavior of all of these methods to instead return an error - a
schema error (clojure.lang.ExceptionInfo) for the clojure functions, and an
IllegalArgumentException for the java methods.
Previously, all the get-client-metrics* functions had two arities - one with a
metric type and one without. This commit removes the arity with a metric type
from all these functions since currently we only have one metric type and
since we aren't entirely certain of what we want the API to be when we add
additional metric types. When we add more metric types, we will change the API
in a backward compatible way.
Rather than having e.g a nil url and method in the metric data when metric-id
is filtered on, or a nil metric id if url and method are filtered on, use
specific schemas for metrics data returned for each metric category - metric
id, url, and url and method.
* Don't pass args into `isMatch()` in `ClientMetricFilter`, since this method
isn't static and so has access to the member variables.
Relevant gif: https://aphyr.com/data/posts/317/state.gif.
* Remove unused `metricTypeString` method
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).
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()`.
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.