[
https://issues.apache.org/jira/browse/HTTPCLIENT-2274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17722186#comment-17722186
]
Lars Uffmann commented on HTTPCLIENT-2274:
------------------------------------------
Thanks, [~olegk]. In the meantime I
* replaced HttpRequestInterceptor using an AsyncExecChainHandler.
* meter normal Response in the HttpResponseInterceptor.
* correlate both using the *http.exchange-id* in ** (either from Scope or
HttpContext)
* non IO error related Retries (5x response) are metered individually.
* retries are using the same {*}http.exchange-id{*}.
Does that sounds reasonable?
I still need the RetryStrategy to catch connection related errors. Is this the
way to go, or did I oversee the obvious?
org.apache.hc.client5.http.HttpRequestRetryStrategy#retryRequest(org.apache.hc.core5.http.HttpRequest,
java.io.IOException, int, org.apache.hc.core5.http.protocol.HttpContext)
> Instrumenting HttpClient to gather http client request metrics.
> ---------------------------------------------------------------
>
> Key: HTTPCLIENT-2274
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2274
> Project: HttpComponents HttpClient
> Issue Type: Improvement
> Components: HttpClient (async), HttpClient (classic)
> Affects Versions: 5.2.1
> Reporter: Lars Uffmann
> Priority: Minor
> Labels: volunteers-wanted
>
> I recently started using the [micrometer|[https://micrometer.io/]] binding
> for HttpClient version 4 and 5, b both classic and async.
> Digging a bit deeper into the implementation I noticed that the async
> instrumentation is not able to measure IO errors.
> My attempt to solve this
> ([https://github.com/micrometer-metrics/micrometer/pull/3801)|https://github.com/micrometer-metrics/micrometer/pull/3801]
> is using a HttpRequestRetryStrategy to capture exceptions. Not only it feels
> a bit awkward using the retry strategy to meter errors, I discovered that
> only errors occurring during an established connection could be metered.
> Connection related IO errors (connection refused, connection timeout, etc.)
> are not metered.
> The issue seems to be that the RequestInterceptor used to start then
> observation, is not called before a connection is established. I see the same
> behavior with the classic http client instrumentation which is using a
> HttpRequestExecutor, not an Interceptor.
> This means
> * the metrics do not include the time needed to establish a connection.
> * The metrics do not count failed connection attempts.
> Could you advise on how to instrument HttpClient (classic and async) in order
> to be able to meter connection related time and errors?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]