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


##########
solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreMetric.java:
##########
@@ -41,14 +46,30 @@ public SolrCoreMetric(
     this.metricName = metricName;
     labels.put("core", coreName);
     if (cloudMode) {
-      String[] coreNameParsed = coreName.split("_");
-      labels.put("collection", coreNameParsed[1]);
-      labels.put("shard", coreNameParsed[2]);
-      labels.put("replica", coreNameParsed[3] + "_" + coreNameParsed[4]);
+      appendCloudModeLabels();
     }
   }
 
+  public Labels getLabels() {
+    return Labels.of(new ArrayList<>(labels.keySet()), new 
ArrayList<>(labels.values()));
+  }
+
   public abstract SolrCoreMetric parseLabels();
 
-  public abstract void toPrometheus(SolrPrometheusCoreExporter 
solrPrometheusCoreRegistry);
+  public abstract void toPrometheus(SolrPrometheusCoreExporter 
solrPrometheusCoreExporter);
+
+  private void appendCloudModeLabels() {
+    Pattern p = Pattern.compile("^core_(.*)_(shard[0-9]+)_(replica_n[0-9]+)");

Review Comment:
   Added dollar sign for clear concise match and probably make the test more 
resilient. Also moved the pattern to `PrometheusCoreExporterInfo.java`. I like 
it and makes sense to me but I can see the possibility to someone else it's 
confusing. Let me know if you disagree on it's placement here.



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