File: httpclient.rst

package info (click to toggle)
dropwizard-metrics 3.2.6-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 2,792 kB
  • sloc: java: 19,095; xml: 1,383; makefile: 132; python: 51; ruby: 11
file content (29 lines) | stat: -rw-r--r-- 1,139 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
.. _manual-httpclient:

###############################
Instrumenting Apache HttpClient
###############################

The ``metrics-httpclient`` module provides ``InstrumentedHttpClientConnManager`` and
``InstrumentedHttpClients``, two instrumented versions of `Apache HttpClient 4.x`__ classes.

.. __: http://hc.apache.org/httpcomponents-client-ga/

``InstrumentedHttpClientConnManager`` is a thread-safe ``HttpClientConnectionManager`` implementation which
measures the number of open connections in the pool and the rate at which new connections are
opened.

``InstrumentedHttpClients`` follows the ``HttpClients`` builder pattern and adds per-HTTP method timers for
HTTP requests.


Metric naming strategies
========================
The default per-method metric naming and scoping strategy can be overridden by passing an
implementation of ``HttpClientMetricNameStrategy`` to the ``InstrumentedHttpClients.createDefault`` method.

A number of pre-rolled strategies are available, e.g.:

.. code-block:: java

    HttpClient client = InstrumentedHttpClients.createDefault(registry, HttpClientMetricNameStrategies.HOST_AND_METHOD);