You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently ran into an issue with a misconfigured MeterFilter. The filter threw exceptions causing in requests failing. I'm adding the filter like this:
I first observed that this is not causing issues (other than a cluttered log) when recording http.server.requests metrics. This is due to the MetricsWebFilter catching Exceptions and logging them away:
privatevoidrecord(ServerWebExchangeexchange, Throwablecause, longstart) {
try {
[...]
AutoTimer.apply(this.autoTimer, this.metricName, annotations,
(builder) -> builder.tags(tags).register(this.registry).record(duration, TimeUnit.NANOSECONDS));
}
catch (Exceptionex) {
logger.warn("Failed to record timer metrics", ex);
// Allow exchange to continue, unaffected by metrics problem
}
}
I then discovered that when the exception occurs in recording http.client.requests this is not handled similarly and I get failed requests. Apparently this is due to code in MetricsWebClientFilterFunction that doesn't do any exception handling.
wilkinsona
changed the title
Improve resilience against exceptions thrown in Micrometer
A failure when an instrumented WebClient records metrics causes the request to fail
May 12, 2022
I recently ran into an issue with a misconfigured
MeterFilter
. The filter threw exceptions causing in requests failing. I'm adding the filter like this:I first observed that this is not causing issues (other than a cluttered log) when recording
http.server.requests
metrics. This is due to theMetricsWebFilter
catching Exceptions and logging them away:I then discovered that when the exception occurs in recording
http.client.requests
this is not handled similarly and I get failed requests. Apparently this is due to code inMetricsWebClientFilterFunction
that doesn't do any exception handling.While I will add additional resilience to my code, I'd also suggest to add exception handling here. Any thoughts?
The text was updated successfully, but these errors were encountered: