mlbiscoc commented on code in PR #2405:
URL: https://github.com/apache/solr/pull/2405#discussion_r1644645966


##########
solr/core/src/java/org/apache/solr/metrics/prometheus/node/SolrNodeHandlerMetric.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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.prometheus.node;
+
+import com.codahale.metrics.Counter;
+import com.codahale.metrics.Gauge;
+import com.codahale.metrics.Meter;
+import com.codahale.metrics.Metric;
+import org.apache.solr.metrics.prometheus.SolrMetric;
+import org.apache.solr.metrics.prometheus.SolrPrometheusExporter;
+
+/* Dropwizard metrics of name ADMIN.* and UPDATE.* */
+public class SolrNodeHandlerMetric extends SolrNodeMetric {
+  public static final String NODE_REQUESTS = "solr_metrics_node_requests";
+  public static final String NODE_SECONDS_TOTAL = 
"solr_metrics_node_requests_time";
+  public static final String NODE_CONNECTIONS = 
"solr_metrics_node_connections";

Review Comment:
   I personally prefer constants so I'd leave it unless someone feels strongly 
about it.



##########
solr/core/src/java/org/apache/solr/metrics/prometheus/node/SolrPrometheusNodeExporter.java:
##########
@@ -0,0 +1,99 @@
+/*
+ * 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.prometheus.node;
+
+import static 
org.apache.solr.metrics.prometheus.node.SolrNodeMetric.NODE_THREAD_POOL;
+
+import com.codahale.metrics.Counter;
+import com.codahale.metrics.Meter;
+import com.codahale.metrics.Metric;
+import com.google.common.base.Enums;
+import io.prometheus.metrics.model.snapshots.Labels;
+import org.apache.solr.metrics.prometheus.SolrMetric;
+import org.apache.solr.metrics.prometheus.SolrNoOpMetric;
+import org.apache.solr.metrics.prometheus.SolrPrometheusExporter;
+
+/**
+ * This class maintains a {@link 
io.prometheus.metrics.model.snapshots.MetricSnapshot}s exported
+ * from solr.node {@link com.codahale.metrics.MetricRegistry}
+ */
+public class SolrPrometheusNodeExporter extends SolrPrometheusExporter
+    implements PrometheusNodeExporterInfo {
+  public SolrPrometheusNodeExporter() {
+    super();
+  }
+
+  @Override
+  public void exportDropwizardMetric(Metric dropwizardMetric, String 
metricName) {
+    if (metricName.contains(".threadPool.")) {
+      exportThreadPoolMetric(dropwizardMetric, metricName);
+      return;
+    }
+
+    SolrMetric solrNodeMetric = categorizeMetric(dropwizardMetric, metricName);
+    solrNodeMetric.parseLabels().toPrometheus(this);

Review Comment:
   I wouldn't say its a mistake. I split these into 2 abstract functions to 
split out the logic for getting the labels, then converting the correct 
dropwizard type to the correct prometheus type instead of 1 big function.
   
   I think it's fine if not called. If down the line additional metrics want to 
be exported from dropwizard, it's possible to just have it exported without any 
labels and just it's value to which parselabels isn't needed.



-- 
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-unsubscr...@solr.apache.org

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


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

Reply via email to