Copilot commented on code in PR #4803:
URL: https://github.com/apache/solr/pull/4803#discussion_r3839213477


##########
solr/webapp/web/partials/plugins.html:
##########
@@ -17,6 +17,9 @@
 <div id="plugins" class="clearfix">
 
   <div id="frame">
+      <div class="message-container" ng-show="metricsDisabled">
+        <div class="message">Metrics collection is disabled on this node, so 
no plugin information is available. Start Solr with metricsEnabled=true to 
enable it.</div>

Review Comment:
   `metricsEnabled` is not read by the shipped `server/solr/solr.xml`; the 
enabled value is taken from the `<metrics enabled="...">` attribute 
(`SolrXmlConfig.java:682-688`). A user who disabled metrics in `solr.xml` and 
follows this message will restart with this property and remain disabled. 
Please point to enabling the setting in `solr.xml` (or otherwise describe the 
actual configured mechanism).



##########
solr/core/src/java/org/apache/solr/response/PrometheusResponseWriter.java:
##########
@@ -63,6 +63,13 @@ public void write(
     // Otherwise handle MetricSnapshots
     var metrics = response.getValues().get("metrics");
     if (metrics == null) {
+      // No snapshots available, e.g. when metrics collection is disabled. 
Emit the reason as a
+      // comment so the response is still a valid Prometheus exposition
+      var error = response.getValues().get("error");
+      if (error != null) {
+        out.write(("# " + error + "\n").getBytes(StandardCharsets.UTF_8));
+        return;
+      }

Review Comment:
   OpenMetrics requests also reach this branch (`writeOpenMetricsFormat` is 
selected by `wt=openmetrics` or the Accept header), but this body stops after 
the comment. Unlike Prometheus, OpenMetrics requires a final `# EOF` marker 
(the existing tests assert this for normal OpenMetrics responses), so 
disabled-metrics responses are invalid. Append `# EOF` when the request is 
OpenMetrics and cover that format.



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