From 49c81bd8691305cc7d7f8b3d58ed3bfb1dc1e7dc Mon Sep 17 00:00:00 2001 From: Erick Date: Sat, 28 May 2016 09:16:11 -0700 Subject: [PATCH] SOLR-9136: Separate out the error statistics into server-side error vs client-side error --- solr/CHANGES.txt | 3 ++ .../solr/handler/RequestHandlerBase.java | 29 ++++++++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 5a9c12a47d7..5ccccc69650 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -339,6 +339,9 @@ Other Changes * SOLR-9161: SolrPluginUtils.invokeSetters now accommodates setter variants (Christine Poerschke) +* SOLR-9136: Separate out the error statistics into server-side error vs client-side error + (Jessica Chent Mallet via Erick Erickson) + ================== 6.0.1 ================== (No Changes) diff --git a/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java b/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java index cf3aa706dfa..98f68967384 100644 --- a/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java +++ b/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java @@ -56,7 +56,8 @@ public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfo // Statistics private final AtomicLong numRequests = new AtomicLong(); - private final AtomicLong numErrors = new AtomicLong(); + private final AtomicLong numServerErrors = new AtomicLong(); + private final AtomicLong numClientErrors = new AtomicLong(); private final AtomicLong numTimeouts = new AtomicLong(); private final Timer requestTimes = new Timer(); @@ -164,23 +165,33 @@ public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfo } } } catch (Exception e) { + boolean incrementErrors = true; + boolean isServerError = true; if (e instanceof SolrException) { SolrException se = (SolrException)e; if (se.code() == SolrException.ErrorCode.CONFLICT.code) { - // TODO: should we allow this to be counted as an error (numErrors++)? - - } else { - SolrException.log(log, e); + incrementErrors = false; + } else if (se.code() >= 400 && se.code() < 500) { + isServerError = false; } } else { - SolrException.log(log, e); if (e instanceof SyntaxError) { + isServerError = false; e = new SolrException(SolrException.ErrorCode.BAD_REQUEST, e); } } rsp.setException(e); - numErrors.incrementAndGet(); + + if (incrementErrors) { + SolrException.log(log, e); + + if (isServerError) { + numServerErrors.incrementAndGet(); + } else { + numClientErrors.incrementAndGet(); + } + } } finally { timer.stop(); @@ -263,7 +274,9 @@ public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfo Snapshot snapshot = requestTimes.getSnapshot(); lst.add("handlerStart",handlerStart); lst.add("requests", numRequests.longValue()); - lst.add("errors", numErrors.longValue()); + lst.add("errors", numServerErrors.longValue() + numClientErrors.longValue()); + lst.add("serverErrors", numServerErrors.longValue()); + lst.add("clientErrors", numClientErrors.longValue()); lst.add("timeouts", numTimeouts.longValue()); lst.add("totalTime", requestTimes.getSum()); lst.add("avgRequestsPerSecond", requestTimes.getMeanRate());