I noticed that the monitoring extension is classifying Geowebcache
cache hits as errors. The reason this happens is that on a cache
hit, Geowebcache throws an HttpErrorCodeException (with a 304 code).
The dispatcher catches this, and sets the error onto the request,
which the monitoring module filter picks up. Here's a link to the
relevant part of the Dispatcher:
https://github.com/geoserver/geoserver/blob/a7eff115e4343163dc99a88c6e849db85ffa981d/src/ows/src/main/java/org/geoserver/ows/Dispatcher.java#L1603
I can think of a few different possible places to try and resolve
this, in order of intrusiveness:
1. In the Dispatcher, explicitly check to see that the
HttpErrorCodeException error code is >= 400 before assigning the error
to the request. If code < 400, don't set the error on the request.
2. In the monitoring module MonitorFilter, check to see if the error
is an HttpErrorCodeException. If so, and the code is < 400,
don'tconsider it to be an error.
3. In my case, I have a plugin to the monitoring module, so I can
putthe relevant check there.
I think the change make sense in the dispatcher, because a 304 is not
really an error. But, I'm not sure if something like this would have
any negative consequences, and I'd imagine that any change here could
have far reaching effects.
Below is what that Dispatcher change could look like. Thoughts?
diff --git a/src/ows/src/main/java/org/
geoserver/ows/Dispatcher.java
b/src/ows/src/main/java/org/geoserver/ows/Dispatcher.java
index 54a0719..ef258f5 100644
--- a/src/ows/src/main/java/org/geoserver/ows/Dispatcher.java
+++ b/src/ows/src/main/java/org/geoserver/ows/Dispatcher.java
@@ -1593,6 +1593,11 @@ public class Dispatcher extends AbstractController {
} else {
request.getHttpResponse().sendError(ece.getErrorCode());
}
+ if (ece.getErrorCode() < 400) {
+ // gwc returns an HttpErrorCodeException for 304s
+ // we don't want to flag these as errors for
upstream filters, ie the monitoring extension
+ t = null;
+ }
}
catch (IOException e) {
//means the resposne was already commited
--
Robert Marianski
Software Engineer | Boundless
rmarianski@anonymised.com
@boundlessgeo