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


##########
pinot-common/src/test/java/org/apache/pinot/common/metrics/PinotJMXToPromMetricsTest.java:
##########
@@ -0,0 +1,379 @@
+/**
+ * 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 com.google.common.base.Objects;
+import io.prometheus.jmx.JmxCollector;
+import io.prometheus.jmx.common.http.HTTPServerFactory;
+import io.prometheus.jmx.shaded.io.prometheus.client.CollectorRegistry;
+import io.prometheus.jmx.shaded.io.prometheus.client.exporter.HTTPServer;
+import io.prometheus.jmx.shaded.io.prometheus.client.hotspot.DefaultExports;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.pinot.common.utils.SimpleHttpResponse;
+import org.apache.pinot.common.utils.http.HttpClient;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+import org.testng.Assert;
+
+
+public abstract class PinotJMXToPromMetricsTest {
+
+  private static final Map<PinotComponent, String> 
PINOT_COMPONENT_CONFIG_FILE_MAP =
+      Map.of(PinotComponent.CONTROLLER, "controller.yml", 
PinotComponent.SERVER, "server.yml", PinotComponent.MINION,
+          "minion.yml", PinotComponent.BROKER, "broker.yml");
+
+  private static final String CONFIG_DIR = 
"../docker/images/pinot/etc/jmx_prometheus_javaagent/configs";
+
+  protected HttpClient _httpClient;
+
+  protected static final String LABEL_KEY_TABLE = "table";
+  protected static final String LABEL_VAL_RAW_TABLENAME = "myTable";
+  protected static final String LABEL_KEY_TABLETYPE = "tableType";
+  protected static final String LABEL_VAL_TABLETYPE_REALTIME = "REALTIME";
+  protected static final String LABEL_VAL_TABLENAME_WITH_TYPE_REALTIME =
+      
TableNameBuilder.forType(TableType.REALTIME).tableNameWithType(LABEL_VAL_RAW_TABLENAME);
+  protected static final String LABEL_KEY_DATABASE = "database";
+  protected static final String LABEL_KEY_TOPIC = "topic";
+  protected static final String LABEL_KEY_PARTITION = "partition";
+  protected static final String LABEL_KEY_CONTROLLER_TASKTYPE = "taskType";
+  protected static final String LABEL_VAL_CONTROLLER_TASKTYPE_CHC = 
"ClusterHealthCheck";
+  protected static final String LABEL_KEY_CONTROLLER_PERIODIC_TASK = 
"periodicTask";
+  protected static final String LABEL_KEY_STATUS = "status";
+  protected static final String LABEL_VAL_STATUS_IN_PROGRESS = "IN_PROGRESS";
+
+  protected static final List<String> METER_TYPES =
+      List.of("Count", "FiveMinuteRate", "MeanRate", "OneMinuteRate", 
"FifteenMinuteRate");
+
+  protected static final List<String> TIMER_TYPES =
+      List.of("Count", "FiveMinuteRate", "Max", "999thPercentile", 
"95thPercentile", "75thPercentile", "98thPercentile",
+          "OneMinuteRate", "50thPercentile", "99thPercentile", 
"FifteenMinuteRate", "Mean", "StdDev", "MeanRate",
+          "Min");
+
+  protected static final String TABLE_NAME_WITH_TYPE =
+      
TableNameBuilder.forType(TableType.REALTIME).tableNameWithType(LABEL_VAL_RAW_TABLENAME);
+
+  protected static final String KAFKA_TOPIC = "myTopic";
+  protected static final String PARTITION_GROUP_ID = "partitionGroupId";
+  protected static final String CLIENT_ID =
+      String.format("%s-%s-%s", TABLE_NAME_WITH_TYPE, KAFKA_TOPIC, 
PARTITION_GROUP_ID);
+  protected static final String TABLE_STREAM_NAME = String.format("%s_%s", 
TABLE_NAME_WITH_TYPE, KAFKA_TOPIC);
+  protected static final List<String> 
EXPORTED_LABELS_FOR_TABLE_NAME_TABLE_TYPE =
+      List.of(LABEL_KEY_TABLE, LABEL_VAL_RAW_TABLENAME, LABEL_KEY_TABLETYPE, 
LABEL_VAL_TABLETYPE_REALTIME);
+
+  protected static final List<String> EXPORTED_LABELS_FOR_RAW_TABLE_NAME =
+      List.of(LABEL_KEY_TABLE, LABEL_VAL_RAW_TABLENAME);
+
+  protected static final List<String> EXPORTED_LABELS_FOR_CLIENT_ID =
+      List.of(LABEL_KEY_PARTITION, PARTITION_GROUP_ID, LABEL_KEY_TABLE, 
LABEL_VAL_RAW_TABLENAME, LABEL_KEY_TABLETYPE,
+          TableType.REALTIME.toString(), LABEL_KEY_TOPIC, KAFKA_TOPIC);
+
+  protected static final List<String> 
EXPORTED_LABELS_FOR_PARTITION_TABLE_NAME_AND_TYPE =
+      List.of(LABEL_KEY_PARTITION, "3", LABEL_KEY_TABLE, 
LABEL_VAL_RAW_TABLENAME, LABEL_KEY_TABLETYPE,
+          TableType.REALTIME.toString());
+
+  protected static final List<String> 
EXPORTED_LABELS_FOR_TABLE_TABLETYPE_TASKTYPE =
+      List.of(LABEL_KEY_TABLE, LABEL_VAL_RAW_TABLENAME, LABEL_KEY_TABLETYPE, 
LABEL_VAL_TABLETYPE_REALTIME,
+          LABEL_KEY_CONTROLLER_TASKTYPE, LABEL_VAL_CONTROLLER_TASKTYPE_CHC);
+
+  protected static final List<String> 
EXPORTED_LABELS_FOR_TABLENAMEANDTYPE_AND_TASKTYPE =
+      List.of(LABEL_KEY_TABLE, LABEL_VAL_TABLENAME_WITH_TYPE_REALTIME, 
LABEL_KEY_CONTROLLER_TASKTYPE,
+          LABEL_VAL_CONTROLLER_TASKTYPE_CHC);
+
+  protected static final List<String> EXPORTED_LABELS_FOR_TASK_TYPE_AND_STATUS 
=
+      List.of(LABEL_KEY_STATUS, LABEL_VAL_STATUS_IN_PROGRESS, 
LABEL_KEY_CONTROLLER_TASKTYPE,
+          LABEL_VAL_CONTROLLER_TASKTYPE_CHC);
+
+  protected static final List<String> 
EXPORTED_LABELS_PERIODIC_TASK_TABLE_TABLETYPE =
+      List.of(LABEL_KEY_CONTROLLER_PERIODIC_TASK, 
LABEL_VAL_CONTROLLER_TASKTYPE_CHC, LABEL_KEY_TABLE,
+          LABEL_VAL_RAW_TABLENAME, LABEL_KEY_TABLETYPE, 
LABEL_VAL_TABLETYPE_REALTIME);

Review Comment:
   It looks to me that most of these attributes are only used in one of the 
tests. For example, EXPORTED_LABELS_FOR_TASK_TYPE_AND_STATUS is only used in 
controller tests. Shouldn't it be declared in that class instead of here? By 
declaring them here we make this class larger than needed and it is more 
difficult for a reader to understand the scope of this attribute



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to