mirror of https://github.com/apache/lucene.git
SOLR-11215: Support retrieval of any property of a regular metric when
using 'key' parameter.
This commit is contained in:
parent
5324c7436c
commit
26ed40bcdb
|
@ -22,6 +22,7 @@ import java.util.Collections;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -139,14 +140,18 @@ public class MetricsHandler extends RequestHandlerBase implements PermissionName
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
MetricUtils.PropertyFilter propertyFilter = MetricUtils.PropertyFilter.ALL;
|
MetricUtils.PropertyFilter propertyFilter = MetricUtils.PropertyFilter.ALL;
|
||||||
boolean simple = false;
|
|
||||||
if (propertyName != null) {
|
if (propertyName != null) {
|
||||||
propertyFilter = (name) -> name.equals(propertyName);
|
propertyFilter = (name) -> name.equals(propertyName);
|
||||||
simple = true;
|
|
||||||
// use escaped versions
|
// use escaped versions
|
||||||
key = parts[0] + ":" + parts[1];
|
key = parts[0] + ":" + parts[1];
|
||||||
}
|
}
|
||||||
MetricUtils.convertMetric(key, m, propertyFilter, false, true, true, simple, ":", (k, v) -> result.add(k, v));
|
MetricUtils.convertMetric(key, m, propertyFilter, false, true, true, false, ":", (k, v) -> {
|
||||||
|
if ((v instanceof Map) && propertyName != null) {
|
||||||
|
((Map)v).forEach((k1, v1) -> result.add(k + ":" + k1, v1));
|
||||||
|
} else {
|
||||||
|
result.add(k, v);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
rsp.getValues().add("metrics", result);
|
rsp.getValues().add("metrics", result);
|
||||||
if (errors.size() > 0) {
|
if (errors.size() > 0) {
|
||||||
|
|
|
@ -277,6 +277,15 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
|
||||||
val = values.findRecursive("metrics", key3);
|
val = values.findRecursive("metrics", key3);
|
||||||
assertNotNull(val);
|
assertNotNull(val);
|
||||||
|
|
||||||
|
String key4 = "solr.core.collection1:QUERY./select.requestTimes:1minRate";
|
||||||
|
resp = new SolrQueryResponse();
|
||||||
|
handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", CommonParams.WT, "json",
|
||||||
|
MetricsHandler.KEY_PARAM, key4), resp);
|
||||||
|
values = resp.getValues();
|
||||||
|
val = values.findRecursive("metrics", key4);
|
||||||
|
assertNotNull(val);
|
||||||
|
assertTrue(val instanceof Number);
|
||||||
|
|
||||||
// test errors
|
// test errors
|
||||||
|
|
||||||
// invalid keys
|
// invalid keys
|
||||||
|
|
Loading…
Reference in New Issue