gortiz commented on code in PR #14155:
URL: https://github.com/apache/pinot/pull/14155#discussion_r1808216874


##########
pinot-common/src/test/java/org/apache/pinot/common/metrics/BrokerPrometheusMetricsTest.java:
##########
@@ -0,0 +1,141 @@
+/**
+ * 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.pinot.common.metrics;
+
+import io.prometheus.jmx.shaded.io.prometheus.client.exporter.HTTPServer;
+import java.net.URI;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.pinot.common.utils.SimpleHttpResponse;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+
+public class BrokerPrometheusMetricsTest extends PinotPrometheusMetricsTest {
+
+  private static final String EXPORTED_METRIC_PREFIX = "pinot_broker_";
+
+  private static final String EXPORTED_METRIC_PREFIX_EXCEPTIONS = "exceptions";
+
+  private static final List<BrokerMeter> GLOBAL_METERS_WITH_EXCEPTIONS_PREFIX =
+      List.of(BrokerMeter.UNCAUGHT_GET_EXCEPTIONS, 
BrokerMeter.UNCAUGHT_POST_EXCEPTIONS,
+          BrokerMeter.QUERY_REJECTED_EXCEPTIONS, 
BrokerMeter.REQUEST_COMPILATION_EXCEPTIONS,
+          BrokerMeter.RESOURCE_MISSING_EXCEPTIONS);
+
+  private static final List<BrokerMeter> METERS_ACCEPTING_RAW_TABLENAME =
+      List.of(BrokerMeter.QUERIES, BrokerMeter.NO_SERVER_FOUND_EXCEPTIONS, 
BrokerMeter.DOCUMENTS_SCANNED,
+          BrokerMeter.ENTRIES_SCANNED_IN_FILTER, 
BrokerMeter.BROKER_RESPONSES_WITH_UNAVAILABLE_SEGMENTS,
+          BrokerMeter.BROKER_RESPONSES_WITH_PARTIAL_SERVERS_RESPONDED,
+          BrokerMeter.BROKER_RESPONSES_WITH_PROCESSING_EXCEPTIONS,
+          BrokerMeter.BROKER_RESPONSES_WITH_NUM_GROUPS_LIMIT_REACHED, 
BrokerMeter.BROKER_RESPONSES_WITH_TIMEOUTS,
+          BrokerMeter.ENTRIES_SCANNED_POST_FILTER, 
BrokerMeter.TOTAL_SERVER_RESPONSE_SIZE,
+          BrokerMeter.QUERY_QUOTA_EXCEEDED);
+
+  private BrokerMetrics _brokerMetrics;
+
+  private HTTPServer _httpServer;

Review Comment:
   nit: Given it is going to be the same in all tests... shouldn't this be 
managed in the parent class? Something like:
   
   ```java
   // in PinotPrometheusMetricsTest
   private HTTPServer _httpServer;
   protected abstract PinotComponent getComponent();
   
   @BeforeClass
   public void startServer() {
     _httpServer = startExporter(getComponent());
   }
   
   @AfterClass
   public void stopServer() {
     if (_httpServer != null) {
       _httpServer.close();
     }
   }
   ```
   
   Then on each test class you can implement `PinotComponent getComponent()`



-- 
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: commits-unsubscr...@pinot.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to