You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2022/02/22 22:59:51 UTC

[GitHub] [solr] dsmiley commented on a change in pull request #657: SOLR-14401: Track distrib/shard metrics differently

dsmiley commented on a change in pull request #657:
URL: https://github.com/apache/solr/pull/657#discussion_r812431211



##########
File path: solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java
##########
@@ -154,23 +138,50 @@ public SolrMetricsContext getSolrMetricsContext() {
   @Override
   public void initializeMetrics(SolrMetricsContext parentContext, String scope) {
     this.solrMetricsContext = parentContext.getChildContext(this);
-    numErrors = solrMetricsContext.meter("errors", getCategory().toString(), scope);
-    numServerErrors = solrMetricsContext.meter("serverErrors", getCategory().toString(), scope);
-    numClientErrors = solrMetricsContext.meter("clientErrors", getCategory().toString(), scope);
-    numTimeouts = solrMetricsContext.meter("timeouts", getCategory().toString(), scope);
-    requests = solrMetricsContext.counter("requests", getCategory().toString(), scope);
-    MetricsMap metricsMap = new MetricsMap(map ->
-        shardPurposes.forEach((k, v) -> map.putNoEx(k, v.getCount())));
-    solrMetricsContext.gauge(metricsMap, true, "shardRequests", getCategory().toString(), scope);
-    requestTimes = solrMetricsContext.timer("requestTimes", getCategory().toString(), scope);
-    distribRequestTimes = solrMetricsContext.timer("requestTimes", getCategory().toString(), scope, "distrib");
-    localRequestTimes = solrMetricsContext.timer("requestTimes", getCategory().toString(), scope, "local");
-    totalTime = solrMetricsContext.counter("totalTime", getCategory().toString(), scope);
-    distribTotalTime = solrMetricsContext.counter("totalTime", getCategory().toString(), scope, "distrib");
-    localTotalTime = solrMetricsContext.counter("totalTime", getCategory().toString(), scope, "local");
+    metrics = new RhMetrics(solrMetricsContext, getCategory().toString(), scope);
+    if (supportsDistribedRequests()) {
+      metricsShard = new RhMetrics(solrMetricsContext, getCategory().toString(), scope + "[shard]");
+    }
     solrMetricsContext.gauge(() -> handlerStart, true, "handlerStart", getCategory().toString(), scope);
   }
 
+  /**
+   * Does this handler receive per-shard (or similar) requests contributing to larger request?
+   * This is used to track metrics separately.
+   * @see ShardParams#IS_SHARD
+   */
+  protected boolean supportsDistribedRequests() {
+    return false;
+  }
+
+  protected static class RhMetrics {

Review comment:
       RequestHandler.
   Alternatively I could call it simply `Metrics` but sometimes it's annoying when simple/common classes are used across the codebase as it shows up in import pickers if it's needed somewhere else.  It's no big deal; I'll just rename it to that.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org