sigram commented on code in PR #4917:
URL: https://github.com/apache/solr/pull/4917#discussion_r4035025270
##########
solr/core/src/java/org/apache/solr/metrics/SolrMetricsContext.java:
##########
@@ -160,65 +160,67 @@ public DoubleGauge doubleGauge(String metricName, String
description, OtelUnit u
public ObservableLongGauge observableLongGauge(
String metricName, String description,
Consumer<ObservableLongMeasurement> callback) {
- var observableLongGauge = observableLongGauge(metricName, description,
callback, null);
- closeables.add(observableLongGauge);
- return observableLongGauge;
+ return observableLongGauge(metricName, description, callback, null);
}
public ObservableLongGauge observableLongGauge(
String metricName,
String description,
Consumer<ObservableLongMeasurement> callback,
OtelUnit unit) {
- return metricManager.observableLongGauge(registryName, metricName,
description, callback, unit);
+ var observableLongGauge =
+ metricManager.observableLongGauge(registryName, metricName,
description, callback, unit);
+ closeables.add(observableLongGauge);
+ return observableLongGauge;
Review Comment:
@mlbiscoc +1, Solr 9 used a similar mechanism to solve a similar problem -
Dropwizard gauges were constructed with lambdas that would keep references to
closed searchers, thus causing similar leaks. The solution we came up with was
to hide this mechanism in SolrMetricManager - always register gauges with a
helper method in SolrMetricManager that would wrap the gauge instance + a
unique tag and add these lambdas to a list of closables to be called on
SolrMetricsContext.unregister().
--
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]