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/08/23 22:11:13 UTC

[GitHub] [solr] dsmiley commented on a diff in pull request #948: SOLR-15007: Adding ability to provide aggregated node level metrics for request handlers

dsmiley commented on code in PR #948:
URL: https://github.com/apache/solr/pull/948#discussion_r953142468


##########
solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java:
##########
@@ -131,6 +134,11 @@ public void init(NamedList<?> args) {
     if (initArgs != null) {
       Object caching = initArgs.get("httpCaching");
       httpCaching = caching != null ? Boolean.parseBoolean(caching.toString()) : true;
+      Boolean aggregateNodeLevelMetricsEnabled =

Review Comment:
   Nitpick; the "Enabled" suffix isn't really necessary; I think we tend not to do that.



##########
solr/core/src/java/org/apache/solr/metrics/DelegateRegistryHistogram.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.metrics;
+
+import com.codahale.metrics.Histogram;
+import com.codahale.metrics.Snapshot;
+
+public class DelegateRegistryHistogram extends Histogram {

Review Comment:
   Add a class javadoc please; one line is fine.  I suggest adding a `@see` to who creates this.



##########
solr/core/src/test/org/apache/solr/handler/RequestHandlerMetricsTest.java:
##########
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.handler;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.apache.solr.client.solrj.*;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.response.SolrResponseBase;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.util.NamedList;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class RequestHandlerMetricsTest extends SolrCloudTestCase {
+
+  @BeforeClass
+  public static void beforeClass() throws Exception {
+    System.setProperty("metricsEnabled", "true");
+    configureCluster(1).addConfig("conf1", configset("cloud-aggregate-node-metrics")).configure();
+  }
+
+  @Before
+  public void setUp() throws Exception {
+    super.setUp();
+    cluster.deleteAllCollections();
+  }
+
+  @AfterClass
+  public static void afterClass() {
+    System.clearProperty("metricsEnabled");
+  }
+
+  @Test
+  @SuppressWarnings({"unchecked"})
+  public void testAggregateNodeLevelMetrics() throws SolrServerException, IOException {
+    String collection1 = "testRequestHandlerMetrics1";
+    String collection2 = "testRequestHandlerMetrics2";
+
+    CloudSolrClient cloudClient = cluster.getSolrClient();
+
+    CollectionAdminRequest.Create create =
+        CollectionAdminRequest.createCollection(collection1, "conf1", 1, 1);
+    cloudClient.request(create);
+    cluster.waitForActiveCollection(collection1, 1, 1);
+
+    create = CollectionAdminRequest.createCollection(collection2, "conf1", 1, 1);
+    cloudClient.request(create);
+    cluster.waitForActiveCollection(collection2, 1, 1);
+
+    SolrInputDocument solrInputDocument =
+        new SolrInputDocument("id", "10", "title", "test", "val_s1", "aaa");
+    cloudClient.add(collection1, solrInputDocument);
+    cloudClient.add(collection2, solrInputDocument);
+
+    SolrQuery solrQuery = new SolrQuery("*:*");
+    cloudClient.query(collection1, solrQuery);
+    cloudClient.query(collection2, solrQuery);
+
+    NamedList<Object> response =
+        cloudClient.request(
+            new SolrRequest<>(SolrRequest.METHOD.GET, "/admin/metrics") {

Review Comment:
   Use GenericSolrRequest instead



##########
solr/core/src/java/org/apache/solr/metrics/DelegateRegistryTimer.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.metrics;
+
+import com.codahale.metrics.Clock;
+import com.codahale.metrics.Snapshot;
+import com.codahale.metrics.Timer;
+import java.time.Duration;
+import java.util.concurrent.Callable;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Supplier;
+
+public class DelegateRegistryTimer extends Timer {

Review Comment:
   Add a class javadoc please; one line is fine.  I suggest adding a `@see` to who creates this.



##########
solr/core/src/java/org/apache/solr/metrics/DelegateRegistryCounter.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.metrics;
+
+import com.codahale.metrics.Counter;
+
+public class DelegateRegistryCounter extends Counter {

Review Comment:
   Add a class javadoc please; one line is fine.  I suggest adding a `@see` to who creates this.



##########
solr/core/src/java/org/apache/solr/metrics/DelegateRegistryCounter.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.metrics;
+
+import com.codahale.metrics.Counter;
+
+public class DelegateRegistryCounter extends Counter {
+
+  private final Counter primaryCounter;

Review Comment:
   Ah; I vaguely recall such complications but you've thought it through more.  It would be great to add some comments about this below the class declaration, maybe in SolrDelegateRegistryMetricsContext instead of repeating it in each delegating metric.



##########
solr/core/src/java/org/apache/solr/metrics/DelegateRegistryMeter.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.metrics;
+
+import com.codahale.metrics.Meter;
+
+public class DelegateRegistryMeter extends Meter {

Review Comment:
   Add a class javadoc please; one line is fine.  I suggest adding a `@see` to who creates this.



##########
solr/core/src/java/org/apache/solr/metrics/SolrDelegateRegistryMetricsContext.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.metrics;
+
+import com.codahale.metrics.Counter;
+import com.codahale.metrics.Histogram;
+import com.codahale.metrics.Meter;
+import com.codahale.metrics.Timer;
+
+public class SolrDelegateRegistryMetricsContext extends SolrMetricsContext {

Review Comment:
   Please add some class javadocs.



-- 
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