Apache Solr open-source search software
SOLR-10418: Metrics API should return JVM system properties.
Andrzej Bialeckibb69c02e575c
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 294cdccb646..b39061c80d7 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -113,6 +113,10 @@ Other Changesthe metrics API, legacy JMX support has been replaced with SolrJmxReporter functionality. Several reporterimprovements (support for multiple prefix filters, "enabled" flag, reuse of service clients). (ab)+* SOLR-10418: Expose safe system properties via metrics API as 'system.properties' in 'solr.jvm' group.+ Add support for selecting specific properties from any compound metric using 'property' parameter to+ /admin/metrics handler. (ab)+----------------------================== 6.6.0 ==================diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/plugin/AnalyticsStatisticsCollector.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/plugin/AnalyticsStatisticsCollector.javaindex 657768f4ad4..1670ad5689a 100644--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/plugin/AnalyticsStatisticsCollector.java+++ b/solr/contrib/analytics/src/java/org/apache/solr/analytics/plugin/AnalyticsStatisticsCollector.java@@ -88,7 +88,7 @@ public class AnalyticsStatisticsCollector {public Map<String, Object> getStatistics() {Map<String, Object> map = new HashMap<>();- MetricUtils.convertTimer("", requestTimes, false, false, (k, v) -> {+ MetricUtils.convertTimer("", requestTimes, MetricUtils.PropertyFilter.ALL, false, false, (k, v) -> {map.putAll((Map<String, Object>)v);});map.put("requests", numRequests.longValue());diff --git a/solr/core/src/java/org/apache/solr/core/NodeConfig.java b/solr/core/src/java/org/apache/solr/core/NodeConfig.javaindex de2dcead05f..7a209d0d777 100644--- a/solr/core/src/java/org/apache/solr/core/NodeConfig.java+++ b/solr/core/src/java/org/apache/solr/core/NodeConfig.java@@ -17,7 +17,10 @@package org.apache.solr.core;import java.nio.file.Path;+import java.util.Arrays;+import java.util.HashSet;import java.util.Properties;+import java.util.Set;import org.apache.solr.common.SolrException;import org.apache.solr.logging.LogWatcherConfig;@@ -64,6 +67,8 @@ public class NodeConfig {private final PluginInfo[] metricReporterPlugins;+ private final Set<String> hiddenSysProps;+private final PluginInfo transientCacheConfig;private NodeConfig(String nodeName, Path coreRootDirectory, Path configSetBaseDirectory, String sharedLibDirectory,@@ -73,7 +78,7 @@ public class NodeConfig {LogWatcherConfig logWatcherConfig, CloudConfig cloudConfig, Integer coreLoadThreads,int transientCacheSize, boolean useSchemaCache, String managementPath, SolrResourceLoader loader,Properties solrProperties, PluginInfo[] backupRepositoryPlugins,- PluginInfo[] metricReporterPlugins, PluginInfo transientCacheConfig) {+ PluginInfo[] metricReporterPlugins, Set<String> hiddenSysProps, PluginInfo transientCacheConfig) {this.nodeName = nodeName;this.coreRootDirectory = coreRootDirectory;this.configSetBaseDirectory = configSetBaseDirectory;@@ -94,6 +99,7 @@ public class NodeConfig {this.solrProperties = solrProperties;this.backupRepositoryPlugins = backupRepositoryPlugins;this.metricReporterPlugins = metricReporterPlugins;+ this.hiddenSysProps = hiddenSysProps;this.transientCacheConfig = transientCacheConfig;if (this.cloudConfig != null && this.getCoreLoadThreadCount(false) < 2) {@@ -187,6 +193,10 @@ public class NodeConfig {return metricReporterPlugins;}+ public Set<String> getHiddenSysProps() {+ return hiddenSysProps;+ }+public PluginInfo getTransientCachePluginInfo() { return transientCacheConfig; }public static class NodeConfigBuilder {@@ -211,6 +221,7 @@ public class NodeConfig {private Properties solrProperties = new Properties();private PluginInfo[] backupRepositoryPlugins;private PluginInfo[] metricReporterPlugins;+ private Set<String> hiddenSysProps = new HashSet<>(DEFAULT_HIDDEN_SYS_PROPS);private PluginInfo transientCacheConfig;private final SolrResourceLoader loader;@@ -227,6 +238,14 @@ public class NodeConfig {private static final String DEFAULT_COLLECTIONSHANDLERCLASS = "org.apache.solr.handler.admin.CollectionsHandler";private static final String DEFAULT_CONFIGSETSHANDLERCLASS = "org.apache.solr.handler.admin.ConfigSetsHandler";+ public static final Set<String> DEFAULT_HIDDEN_SYS_PROPS = new HashSet<>(Arrays.asList(+ "javax.net.ssl.keyStorePassword",+ "javax.net.ssl.trustStorePassword",+ "basicauth",+ "zkDigestPassword",+ "zkDigestReadonlyPassword"+ ));+public NodeConfigBuilder(String nodeName, SolrResourceLoader loader) {this.nodeName = nodeName;this.loader = loader;@@ -331,11 +350,16 @@ public class NodeConfig {return this;}+ public NodeConfigBuilder setHiddenSysProps(Set<String> hiddenSysProps) {+ this.hiddenSysProps = hiddenSysProps;+ return this;+ }+public NodeConfig build() {return new NodeConfig(nodeName, coreRootDirectory, configSetBaseDirectory, sharedLibDirectory, shardHandlerFactoryConfig,updateShardHandlerConfig, coreAdminHandlerClass, collectionsAdminHandlerClass, infoHandlerClass, configSetsHandlerClass,logWatcherConfig, cloudConfig, coreLoadThreads, transientCacheSize, useSchemaCache, managementPath, loader, solrProperties,- backupRepositoryPlugins, metricReporterPlugins, transientCacheConfig);+ backupRepositoryPlugins, metricReporterPlugins, hiddenSysProps, transientCacheConfig);}}}diff --git a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.javaindex 1455018be52..65f29a47ba9 100644--- a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java+++ b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java@@ -104,6 +104,7 @@ public class SolrXmlConfig {configBuilder.setCloudConfig(cloudConfig);configBuilder.setBackupRepositoryPlugins(getBackupRepositoryPluginInfos(config));configBuilder.setMetricReporterPlugins(getMetricReporterPluginInfos(config));+ configBuilder.setHiddenSysProps(getHiddenSysProps(config));return fillSolrSection(configBuilder, entries);}@@ -487,6 +488,26 @@ public class SolrXmlConfig {}return configs.toArray(new PluginInfo[configs.size()]);}++ private static Set<String> getHiddenSysProps(Config config) {+ NodeList nodes = (NodeList) config.evaluate("solr/metrics/hiddenSysProps/str", XPathConstants.NODESET);+ if (nodes == null || nodes.getLength() == 0) {+ return NodeConfig.NodeConfigBuilder.DEFAULT_HIDDEN_SYS_PROPS;+ }+ Set<String> props = new HashSet<>();+ for (int i = 0; i < nodes.getLength(); i++) {+ String prop = DOMUtil.getText(nodes.item(i));+ if (prop != null && !prop.trim().isEmpty()) {+ props.add(prop.trim());+ }+ }+ if (props.isEmpty()) {+ return NodeConfig.NodeConfigBuilder.DEFAULT_HIDDEN_SYS_PROPS;+ } else {+ return props;+ }+ }+private static PluginInfo getTransientCoreCacheFactoryPluginInfo(Config config) {Node node = config.getNode("solr/transientCoreCacheFactory", false);return (node == null) ? null : new PluginInfo(node, "transientCoreCacheFactory", false, true);diff --git a/solr/core/src/java/org/apache/solr/handler/admin/MetricsHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/MetricsHandler.javaindex 54ab092aa33..9dda6aefee4 100644--- a/solr/core/src/java/org/apache/solr/handler/admin/MetricsHandler.java+++ b/solr/core/src/java/org/apache/solr/handler/admin/MetricsHandler.java@@ -55,6 +55,7 @@ public class MetricsHandler extends RequestHandlerBase implements PermissionNamepublic static final String COMPACT_PARAM = "compact";public static final String PREFIX_PARAM = "prefix";public static final String REGEX_PARAM = "regex";+ public static final String PROPERTY_PARAM = "property";public static final String REGISTRY_PARAM = "registry";public static final String GROUP_PARAM = "group";public static final String TYPE_PARAM = "type";@@ -84,6 +85,7 @@ public class MetricsHandler extends RequestHandlerBase implements PermissionNameboolean compact = req.getParams().getBool(COMPACT_PARAM, false);MetricFilter mustMatchFilter = parseMustMatchFilter(req);+ MetricUtils.PropertyFilter propertyFilter = parsePropertyFilter(req);List<MetricType> metricTypes = parseMetricTypes(req);List<MetricFilter> metricFilters = metricTypes.stream().map(MetricType::asMetricFilter).collect(Collectors.toList());Set<String> requestedRegistries = parseRegistries(req);@@ -91,8 +93,12 @@ public class MetricsHandler extends RequestHandlerBase implements PermissionNameNamedList response = new SimpleOrderedMap();for (String registryName : requestedRegistries) {MetricRegistry registry = metricManager.registry(registryName);- response.add(registryName, MetricUtils.toNamedList(registry, metricFilters, mustMatchFilter, false,- false, compact));+ SimpleOrderedMap result = new SimpleOrderedMap();+ MetricUtils.toMaps(registry, metricFilters, mustMatchFilter, propertyFilter, false,+ false, compact, false, (k, v) -> result.add(k, v));+ if (result.size() > 0) {+ response.add(registryName, result);+ }}rsp.getValues().add("metrics", response);}@@ -105,7 +111,7 @@ public class MetricsHandler extends RequestHandlerBase implements PermissionNamefor (String prefix : prefixes) {prefixSet.addAll(StrUtils.splitSmart(prefix, ','));}- prefixFilter = new SolrMetricManager.PrefixFilter((String[])prefixSet.toArray(new String[prefixSet.size()]));+ prefixFilter = new SolrMetricManager.PrefixFilter(prefixSet);}String[] regexes = req.getParams().getParams(REGEX_PARAM);MetricFilter regexFilter = null;@@ -116,11 +122,35 @@ public class MetricsHandler extends RequestHandlerBase implements PermissionNameif (prefixFilter == null && regexFilter == null) {mustMatchFilter = MetricFilter.ALL;} else {- mustMatchFilter = new SolrMetricManager.OrFilter(prefixFilter, regexFilter);+ if (prefixFilter == null) {+ mustMatchFilter = regexFilter;+ } else if (regexFilter == null) {+ mustMatchFilter = prefixFilter;+ } else {+ mustMatchFilter = new SolrMetricManager.OrFilter(prefixFilter, regexFilter);+ }}return mustMatchFilter;}+ private MetricUtils.PropertyFilter parsePropertyFilter(SolrQueryRequest req) {+ String[] props = req.getParams().getParams(PROPERTY_PARAM);+ if (props == null || props.length == 0) {+ return MetricUtils.PropertyFilter.ALL;+ }+ final Set<String> filter = new HashSet<>();+ for (String prop : props) {+ if (prop != null && !prop.trim().isEmpty()) {+ filter.add(prop.trim());+ }+ }+ if (filter.isEmpty()) {+ return MetricUtils.PropertyFilter.ALL;+ } else {+ return (name) -> filter.contains(name);+ }+ }+private Set<String> parseRegistries(SolrQueryRequest req) {String[] groupStr = req.getParams().getParams(GROUP_PARAM);String[] registryStr = req.getParams().getParams(REGISTRY_PARAM);diff --git a/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrReporter.java b/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrReporter.javaindex 0bca68f52df..192387791a0 100644--- a/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrReporter.java+++ b/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrReporter.java@@ -361,7 +361,7 @@ public class SolrReporter extends ScheduledReporter {}final String effectiveGroup = group;MetricUtils.toSolrInputDocuments(metricManager.registry(registryName), Collections.singletonList(report.filter), MetricFilter.ALL,- skipHistograms, skipAggregateValues, false, metadata, doc -> {+ MetricUtils.PropertyFilter.ALL, skipHistograms, skipAggregateValues, false, metadata, doc -> {doc.setField(REGISTRY_ID, registryName);doc.setField(GROUP_ID, effectiveGroup);if (effectiveLabel != null) {diff --git a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.javaindex 24bcf3dc38a..39ccadc68bb 100644--- a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java+++ b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java@@ -40,6 +40,7 @@ import java.util.ArrayList;import java.util.Arrays;import java.util.Locale;import java.util.Properties;+import java.util.Set;import java.util.concurrent.atomic.AtomicBoolean;import java.util.concurrent.atomic.AtomicReference;import java.util.regex.Matcher;@@ -67,6 +68,7 @@ import org.apache.solr.core.SolrInfoBean;import org.apache.solr.core.SolrResourceLoader;import org.apache.solr.core.SolrXmlConfig;import org.apache.solr.metrics.AltBufferPoolMetricSet;+import org.apache.solr.metrics.MetricsMap;import org.apache.solr.metrics.OperatingSystemMetricSet;import org.apache.solr.metrics.SolrMetricManager;import org.apache.solr.request.SolrRequestInfo;@@ -184,6 +186,7 @@ public class SolrDispatchFilter extends BaseSolrFilter {private void setupJvmMetrics() {SolrMetricManager metricManager = cores.getMetricManager();+ final Set<String> hiddenSysProps = cores.getConfig().getHiddenSysProps();try {String registry = SolrMetricManager.getRegistryName(SolrInfoBean.Group.jvm);metricManager.registerAll(registry, new AltBufferPoolMetricSet(), true, "buffers");@@ -192,6 +195,14 @@ public class SolrDispatchFilter extends BaseSolrFilter {metricManager.registerAll(registry, new GarbageCollectorMetricSet(), true, "gc");metricManager.registerAll(registry, new MemoryUsageGaugeSet(), true, "memory");metricManager.registerAll(registry, new ThreadStatesGaugeSet(), true, "threads"); // todo should we use CachedThreadStatesGaugeSet instead?+ MetricsMap sysprops = new MetricsMap((detailed, map) -> {+ System.getProperties().forEach((k, v) -> {+ if (!hiddenSysProps.contains(k)) {+ map.put(String.valueOf(k), v);+ }+ });+ });+ metricManager.registerGauge(null, registry, sysprops, true, "properties", "system");} catch (Exception e) {log.warn("Error registering JVM metrics", e);}diff --git a/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java b/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.javaindex 2900857a912..a190a0f0085 100644--- a/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java+++ b/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java@@ -25,6 +25,7 @@ import java.lang.management.OperatingSystemMXBean;import java.lang.management.PlatformManagedObject;import java.lang.reflect.InvocationTargetException;import java.util.Collection;+import java.util.Collections;import java.util.HashMap;import java.util.LinkedHashMap;import java.util.List;@@ -47,7 +48,6 @@ import com.codahale.metrics.Snapshot;import com.codahale.metrics.Timer;import org.apache.solr.common.SolrInputDocument;import org.apache.solr.common.util.NamedList;-import org.apache.solr.common.util.SimpleOrderedMap;import org.apache.solr.core.SolrInfoBean;import org.apache.solr.metrics.AggregateMetric;import org.slf4j.Logger;@@ -85,6 +85,20 @@ public class MetricUtils {static final String P999 = "p999";static final String P999_MS = P999 + MS;+ /**+ * This filter can limit what properties of a metric are returned.+ */+ public interface PropertyFilter {+ PropertyFilter ALL = (name) -> true;++ /**+ * Return only properties that match.+ * @param name property name+ * @return true if this property should be returned, false otherwise.+ */+ boolean accept(String name);+ }+/*** Adds metrics from a Timer to a NamedList, using well-known back-compat names.* @param lst The NamedList to add the metrics data to@@ -113,30 +127,6 @@ public class MetricUtils {return ns / TimeUnit.MILLISECONDS.toNanos(1);}- /**- * Returns a NamedList representation of the given metric registry. Only those metrics- * are converted to NamedList which match at least one of the given MetricFilter instances.- *- * @param registry the {@link MetricRegistry} to be converted to NamedList- * @param shouldMatchFilters a list of {@link MetricFilter} instances.- * A metric must match <em>any one</em> of the filters from this list to be- * included in the output- * @param mustMatchFilter a {@link MetricFilter}.- * A metric <em>must</em> match this filter to be included in the output.- * @param skipHistograms discard any {@link Histogram}-s and histogram parts of {@link Timer}-s.- * @param compact use compact representation for counters and gauges.- * @return a {@link NamedList}- */- public static NamedList toNamedList(MetricRegistry registry, List<MetricFilter> shouldMatchFilters,- MetricFilter mustMatchFilter, boolean skipHistograms,- boolean skipAggregateValues, boolean compact) {- NamedList result = new SimpleOrderedMap();- toMaps(registry, shouldMatchFilters, mustMatchFilter, skipHistograms, skipAggregateValues, compact, false, (k, v) -> {- result.add(k, v);- });- return result;- }-/*** Provides a representation of the given metric registry as {@link SolrInputDocument}-s.Only those metrics@@ -148,6 +138,7 @@ public class MetricUtils {* included in the output* @param mustMatchFilter a {@link MetricFilter}.* A metric <em>must</em> match this filter to be included in the output.+ * @param propertyFilter limit what properties of a metric are returned* @param skipHistograms discard any {@link Histogram}-s and histogram parts of {@link Timer}-s.* @param skipAggregateValues discard internal values of {@link AggregateMetric}-s.* @param compact use compact representation for counters and gauges.@@ -156,11 +147,11 @@ public class MetricUtils {* @param consumer consumer that accepts produced {@link SolrInputDocument}-s*/public static void toSolrInputDocuments(MetricRegistry registry, List<MetricFilter> shouldMatchFilters,- MetricFilter mustMatchFilter, boolean skipHistograms,+ MetricFilter mustMatchFilter, PropertyFilter propertyFilter, boolean skipHistograms,boolean skipAggregateValues, boolean compact,Map<String, Object> metadata, Consumer<SolrInputDocument> consumer) {boolean addMetadata = metadata != null && !metadata.isEmpty();- toMaps(registry, shouldMatchFilters, mustMatchFilter, skipHistograms, skipAggregateValues, compact, false, (k, v) -> {+ toMaps(registry, shouldMatchFilters, mustMatchFilter, propertyFilter, skipHistograms, skipAggregateValues, compact, false, (k, v) -> {SolrInputDocument doc = new SolrInputDocument();doc.setField(METRIC_NAME, k);toSolrInputDocument(null, doc, v);@@ -199,6 +190,7 @@ public class MetricUtils {* @param registry source of metrics* @param shouldMatchFilters metrics must match any of these filters* @param mustMatchFilter metrics must match this filter+ * @param propertyFilter limit what properties of a metric are returned* @param skipHistograms discard any {@link Histogram}-s and histogram parts of {@link Timer}-s.* @param skipAggregateValues discard internal values of {@link AggregateMetric}-s.* @param compact use compact representation for counters and gauges.@@ -206,10 +198,11 @@ public class MetricUtils {* only the selected (name "." key, value) pairs will be produced.* @param consumer consumer that accepts produced objects*/- static void toMaps(MetricRegistry registry, List<MetricFilter> shouldMatchFilters,- MetricFilter mustMatchFilter, boolean skipHistograms, boolean skipAggregateValues,- boolean compact, boolean simple,- BiConsumer<String, Object> consumer) {+ public static void toMaps(MetricRegistry registry, List<MetricFilter> shouldMatchFilters,+ MetricFilter mustMatchFilter, PropertyFilter propertyFilter,+ boolean skipHistograms, boolean skipAggregateValues,+ boolean compact, boolean simple,+ BiConsumer<String, Object> consumer) {final Map<String, Metric> metrics = registry.getMetrics();final SortedSet<String> names = registry.getNames();names.stream()@@ -217,7 +210,7 @@ public class MetricUtils {.filter(s -> mustMatchFilter.matches(s, metrics.get(s))).forEach(n -> {Metric metric = metrics.get(n);- convertMetric(n, metric, skipHistograms, skipAggregateValues, compact, simple, consumer);+ convertMetric(n, metric, propertyFilter, skipHistograms, skipAggregateValues, compact, simple, consumer);});}@@ -254,7 +247,7 @@ public class MetricUtils {names.stream().forEach(n -> {Metric metric = metrics.get(n);- convertMetric(n, metric, skipHistograms, skipAggregateValues, compact, simple, consumer);+ convertMetric(n, metric, PropertyFilter.ALL, skipHistograms, skipAggregateValues, compact, simple, consumer);});}@@ -262,6 +255,7 @@ public class MetricUtils {* Convert a single instance of metric into a map or flattened object.* @param n metric name* @param metric metric instance+ * @param propertyFilter limit what properties of a metric are returned* @param skipHistograms discard any {@link Histogram}-s and histogram parts of {@link Timer}-s.* @param skipAggregateValues discard internal values of {@link AggregateMetric}-s.* @param compact use compact representation for counters and gauges.@@ -269,15 +263,15 @@ public class MetricUtils {* only the selected (name "." key, value) pairs will be produced.* @param consumer consumer that accepts produced objects*/- static void convertMetric(String n, Metric metric, boolean skipHistograms, boolean skipAggregateValues,+ static void convertMetric(String n, Metric metric, PropertyFilter propertyFilter, boolean skipHistograms, boolean skipAggregateValues,boolean compact, boolean simple, BiConsumer<String, Object> consumer) {if (metric instanceof Counter) {Counter counter = (Counter) metric;- consumer.accept(n, convertCounter(counter, compact));+ convertCounter(n, counter, propertyFilter, compact, consumer);} else if (metric instanceof Gauge) {Gauge gauge = (Gauge) metric;try {- convertGauge(n, gauge, simple, compact, consumer);+ convertGauge(n, gauge, propertyFilter, simple, compact, consumer);} catch (InternalError ie) {if (n.startsWith("memory.") && ie.getMessage().contains("Memory Pool not found")) {LOG.warn("Error converting gauge '" + n + "', possible JDK bug: SOLR-10362", ie);@@ -288,17 +282,17 @@ public class MetricUtils {}} else if (metric instanceof Meter) {Meter meter = (Meter) metric;- convertMeter(n, meter, simple, consumer);+ convertMeter(n, meter, propertyFilter, simple, consumer);} else if (metric instanceof Timer) {Timer timer = (Timer) metric;- convertTimer(n, timer, skipHistograms, simple, consumer);+ convertTimer(n, timer, propertyFilter, skipHistograms, simple, consumer);} else if (metric instanceof Histogram) {if (!skipHistograms) {Histogram histogram = (Histogram) metric;- convertHistogram(n, histogram, simple, consumer);+ convertHistogram(n, histogram, propertyFilter, simple, consumer);}} else if (metric instanceof AggregateMetric) {- convertAggregateMetric(n, (AggregateMetric)metric, skipAggregateValues, simple, consumer);+ convertAggregateMetric(n, (AggregateMetric)metric, propertyFilter, skipAggregateValues, simple, consumer);}}@@ -306,23 +300,32 @@ public class MetricUtils {* Convert an instance of {@link AggregateMetric}.* @param name metric name* @param metric an instance of {@link AggregateMetric}+ * @param propertyFilter limit what properties of a metric are returned* @param skipAggregateValues discard internal values of {@link AggregateMetric}-s.* @param simple use simplified representation for complex metrics - instead of a (name, map)* only the selected (name "." key, value) pairs will be produced.* @param consumer consumer that accepts produced objects*/static void convertAggregateMetric(String name, AggregateMetric metric,+ PropertyFilter propertyFilter,boolean skipAggregateValues, boolean simple, BiConsumer<String, Object> consumer) {if (simple) {- consumer.accept(name + "." + MEAN, metric.getMean());+ if (propertyFilter.accept(MEAN)) {+ consumer.accept(name + "." + MEAN, metric.getMean());+ }} else {Map<String, Object> response = new LinkedHashMap<>();- response.put("count", metric.size());- response.put(MAX, metric.getMax());- response.put(MIN, metric.getMin());- response.put(MEAN, metric.getMean());- response.put(STDDEV, metric.getStdDev());- response.put(SUM, metric.getSum());+ BiConsumer<String, Object> filter = (k, v) -> {+ if (propertyFilter.accept(k)) {+ response.put(k, v);+ }+ };+ filter.accept("count", metric.size());+ filter.accept(MAX, metric.getMax());+ filter.accept(MIN, metric.getMin());+ filter.accept(MEAN, metric.getMean());+ filter.accept(STDDEV, metric.getStdDev());+ filter.accept(SUM, metric.getSum());if (!(metric.isEmpty() || skipAggregateValues)) {Map<String, Object> values = new LinkedHashMap<>();response.put(VALUES, values);@@ -333,7 +336,9 @@ public class MetricUtils {values.put(k, map);});}- consumer.accept(name, response);+ if (!response.isEmpty()) {+ consumer.accept(name, response);+ }}}@@ -342,21 +347,29 @@ public class MetricUtils {* based values that don't require unit conversion.* @param name metric name* @param histogram an instance of {@link Histogram}+ * @param propertyFilter limit what properties of a metric are returned* @param simple use simplified representation for complex metrics - instead of a (name, map)* only the selected (name "." key, value) pairs will be produced.* @param consumer consumer that accepts produced objects*/- static void convertHistogram(String name, Histogram histogram,+ static void convertHistogram(String name, Histogram histogram, PropertyFilter propertyFilter,boolean simple, BiConsumer<String, Object> consumer) {Snapshot snapshot = histogram.getSnapshot();if (simple) {- consumer.accept(name + "." + MEAN, snapshot.getMean());+ if (propertyFilter.accept(MEAN)) {+ consumer.accept(name + "." + MEAN, snapshot.getMean());+ }} else {Map<String, Object> response = new LinkedHashMap<>();- response.put("count", histogram.getCount());+ String prop = "count";+ if (propertyFilter.accept(prop)) {+ response.put(prop, histogram.getCount());+ }// non-time based values- addSnapshot(response, snapshot, false);- consumer.accept(name, response);+ addSnapshot(response, snapshot, propertyFilter, false);+ if (!response.isEmpty()) {+ consumer.accept(name, response);+ }}}@@ -370,43 +383,59 @@ public class MetricUtils {}// some snapshots represent time in ns, other snapshots represent raw values (eg. chunk size)- static void addSnapshot(Map<String, Object> response, Snapshot snapshot, boolean ms) {- response.put((ms ? MIN_MS: MIN), nsToMs(ms, snapshot.getMin()));- response.put((ms ? MAX_MS: MAX), nsToMs(ms, snapshot.getMax()));- response.put((ms ? MEAN_MS : MEAN), nsToMs(ms, snapshot.getMean()));- response.put((ms ? MEDIAN_MS: MEDIAN), nsToMs(ms, snapshot.getMedian()));- response.put((ms ? STDDEV_MS: STDDEV), nsToMs(ms, snapshot.getStdDev()));- response.put((ms ? P75_MS: P75), nsToMs(ms, snapshot.get75thPercentile()));- response.put((ms ? P95_MS: P95), nsToMs(ms, snapshot.get95thPercentile()));- response.put((ms ? P99_MS: P99), nsToMs(ms, snapshot.get99thPercentile()));- response.put((ms ? P999_MS: P999), nsToMs(ms, snapshot.get999thPercentile()));+ static void addSnapshot(Map<String, Object> response, Snapshot snapshot, PropertyFilter propertyFilter, boolean ms) {+ BiConsumer<String, Object> filter = (k, v) -> {+ if (propertyFilter.accept(k)) {+ response.put(k, v);+ }+ };+ filter.accept((ms ? MIN_MS: MIN), nsToMs(ms, snapshot.getMin()));+ filter.accept((ms ? MAX_MS: MAX), nsToMs(ms, snapshot.getMax()));+ filter.accept((ms ? MEAN_MS : MEAN), nsToMs(ms, snapshot.getMean()));+ filter.accept((ms ? MEDIAN_MS: MEDIAN), nsToMs(ms, snapshot.getMedian()));+ filter.accept((ms ? STDDEV_MS: STDDEV), nsToMs(ms, snapshot.getStdDev()));+ filter.accept((ms ? P75_MS: P75), nsToMs(ms, snapshot.get75thPercentile()));+ filter.accept((ms ? P95_MS: P95), nsToMs(ms, snapshot.get95thPercentile()));+ filter.accept((ms ? P99_MS: P99), nsToMs(ms, snapshot.get99thPercentile()));+ filter.accept((ms ? P999_MS: P999), nsToMs(ms, snapshot.get999thPercentile()));}/*** Convert a {@link Timer} to a map.* @param name metric name* @param timer timer instance+ * @param propertyFilter limit what properties of a metric are returned* @param skipHistograms if true then discard the histogram part of the timer.* @param simple use simplified representation for complex metrics - instead of a (name, map)* only the selected (name "." key, value) pairs will be produced.* @param consumer consumer that accepts produced objects*/- public static void convertTimer(String name, Timer timer, boolean skipHistograms,+ public static void convertTimer(String name, Timer timer, PropertyFilter propertyFilter, boolean skipHistograms,boolean simple, BiConsumer<String, Object> consumer) {if (simple) {- consumer.accept(name + ".meanRate", timer.getMeanRate());+ String prop = "meanRate";+ if (propertyFilter.accept(prop)) {+ consumer.accept(name + "." + prop, timer.getMeanRate());+ }} else {Map<String, Object> response = new LinkedHashMap<>();- response.put("count", timer.getCount());- response.put("meanRate", timer.getMeanRate());- response.put("1minRate", timer.getOneMinuteRate());- response.put("5minRate", timer.getFiveMinuteRate());- response.put("15minRate", timer.getFifteenMinuteRate());+ BiConsumer<String,Object> filter = (k, v) -> {+ if (propertyFilter.accept(k)) {+ response.put(k, v);+ }+ };+ filter.accept("count", timer.getCount());+ filter.accept("meanRate", timer.getMeanRate());+ filter.accept("1minRate", timer.getOneMinuteRate());+ filter.accept("5minRate", timer.getFiveMinuteRate());+ filter.accept("15minRate", timer.getFifteenMinuteRate());if (!skipHistograms) {// time-based values in nanoseconds- addSnapshot(response, timer.getSnapshot(), true);+ addSnapshot(response, timer.getSnapshot(), propertyFilter, true);+ }+ if (!response.isEmpty()) {+ consumer.accept(name, response);}- consumer.accept(name, response);}}@@ -414,21 +443,31 @@ public class MetricUtils {* Convert a {@link Meter} to a map.* @param name metric name* @param meter meter instance+ * @param propertyFilter limit what properties of a metric are returned* @param simple use simplified representation for complex metrics - instead of a (name, map)* only the selected (name "." key, value) pairs will be produced.* @param consumer consumer that accepts produced objects*/- static void convertMeter(String name, Meter meter, boolean simple, BiConsumer<String, Object> consumer) {+ static void convertMeter(String name, Meter meter, PropertyFilter propertyFilter, boolean simple, BiConsumer<String, Object> consumer) {if (simple) {- consumer.accept(name + ".count", meter.getCount());+ if (propertyFilter.accept("count")) {+ consumer.accept(name + ".count", meter.getCount());+ }} else {Map<String, Object> response = new LinkedHashMap<>();- response.put("count", meter.getCount());- response.put("meanRate", meter.getMeanRate());- response.put("1minRate", meter.getOneMinuteRate());- response.put("5minRate", meter.getFiveMinuteRate());- response.put("15minRate", meter.getFifteenMinuteRate());- consumer.accept(name, response);+ BiConsumer<String, Object> filter = (k, v) -> {+ if (propertyFilter.accept(k)) {+ response.put(k, v);+ }+ };+ filter.accept("count", meter.getCount());+ filter.accept("meanRate", meter.getMeanRate());+ filter.accept("1minRate", meter.getOneMinuteRate());+ filter.accept("5minRate", meter.getFiveMinuteRate());+ filter.accept("15minRate", meter.getFifteenMinuteRate());+ if (!response.isEmpty()) {+ consumer.accept(name, response);+ }}}@@ -436,44 +475,78 @@ public class MetricUtils {* Convert a {@link Gauge}.* @param name metric name* @param gauge gauge instance+ * @param propertyFilter limit what properties of a metric are returned* @param simple use simplified representation for complex metrics - instead of a (name, map)* only the selected (name "." key, value) pairs will be produced.* @param compact if true then only return {@link Gauge#getValue()}. If false* then return a map with a "value" field.* @param consumer consumer that accepts produced objects*/- static void convertGauge(String name, Gauge gauge, boolean simple, boolean compact,+ static void convertGauge(String name, Gauge gauge, PropertyFilter propertyFilter, boolean simple, boolean compact,BiConsumer<String, Object> consumer) {if (compact || simple) {Object o = gauge.getValue();- if (simple && (o instanceof Map)) {- for (Map.Entry<?, ?> entry : ((Map<?, ?>)o).entrySet()) {- consumer.accept(name + "." + entry.getKey().toString(), entry.getValue());+ if (o instanceof Map) {+ if (simple) {+ for (Map.Entry<?, ?> entry : ((Map<?, ?>)o).entrySet()) {+ String prop = entry.getKey().toString();+ if (propertyFilter.accept(prop)) {+ consumer.accept(name + "." + prop, entry.getValue());+ }+ }+ } else {+ Map<String, Object> val = new HashMap<>();+ for (Map.Entry<?, ?> entry : ((Map<?, ?>)o).entrySet()) {+ String prop = entry.getKey().toString();+ if (propertyFilter.accept(prop)) {+ val.put(prop, entry.getValue());+ }+ }+ if (!val.isEmpty()) {+ consumer.accept(name, val);+ }}} else {consumer.accept(name, o);}} else {+ Object o = gauge.getValue();Map<String, Object> response = new LinkedHashMap<>();- response.put("value", gauge.getValue());- consumer.accept(name, response);+ if (o instanceof Map) {+ for (Map.Entry<?, ?> entry : ((Map<?, ?>)o).entrySet()) {+ String prop = entry.getKey().toString();+ if (propertyFilter.accept(prop)) {+ response.put(prop, entry.getValue());+ }+ }+ if (!response.isEmpty()) {+ consumer.accept(name, Collections.singletonMap("value", response));+ }+ } else {+ if (propertyFilter.accept("value")) {+ response.put("value", o);+ consumer.accept(name, response);+ }+ }}}/*** Convert a {@link Counter}* @param counter counter instance+ * @param propertyFilter limit what properties of a metric are returned* @param compact if true then only return {@link Counter#getCount()}. If false* then return a map with a "count" field.- * @return map or object*/- static Object convertCounter(Counter counter, boolean compact) {+ static void convertCounter(String name, Counter counter, PropertyFilter propertyFilter, boolean compact, BiConsumer<String, Object> consumer) {if (compact) {- return counter.getCount();+ consumer.accept(name, counter.getCount());} else {- Map<String, Object> response = new LinkedHashMap<>();- response.put("count", counter.getCount());- return response;+ if (propertyFilter.accept("count")) {+ Map<String, Object> response = new LinkedHashMap<>();+ response.put("count", counter.getCount());+ consumer.accept(name, response);+ }}}diff --git a/solr/core/src/test-files/solr/solr-hiddensysprops.xml b/solr/core/src/test-files/solr/solr-hiddensysprops.xmlnew file mode 100644index 00000000000..20e5aec2175--- /dev/null+++ b/solr/core/src/test-files/solr/solr-hiddensysprops.xml@@ -0,0 +1,31 @@+<?xml version="1.0" encoding="UTF-8" ?>+<!--+ 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.+-->++<solr>+ <metrics>+ <hiddenSysProps>+ <str>foo</str>+ <str>bar</str>+ <str>baz</str>+ </hiddenSysProps>+ <!-- this reporter doesn't specify 'group' or 'registry', it will be instantiated for any group. -->+ <reporter name="universal" class="org.apache.solr.metrics.reporters.MockMetricReporter">+ <str name="configurable">configured</str>+ </reporter>+ </metrics>+</solr>diff --git a/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.javaindex f9fc8743d69..09584e0bd94 100644--- a/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java+++ b/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java@@ -34,10 +34,11 @@ import org.junit.Test;public class MetricsHandlerTest extends SolrTestCaseJ4 {@BeforeClasspublic static void beforeClass() throws Exception {- // this is needed to enable default SolrJmxReporter in TestHarness- ManagementFactory.getPlatformMBeanServer();initCore("solrconfig.xml", "schema.xml");+ // manually register some metrics in solr.jvm and solr.jetty - TestHarness doesn't init them+ h.getCoreContainer().getMetricManager().counter(null, "solr.jvm", "foo");+ h.getCoreContainer().getMetricManager().counter(null, "solr.jetty", "foo");}@Test@@ -49,9 +50,6 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {NamedList values = resp.getValues();assertNotNull(values.get("metrics"));values = (NamedList) values.get("metrics");- assertNotNull(values.get("solr.jetty"));- assertNotNull(values.get("solr.jvm"));- assertNotNull(values.get("solr.node"));NamedList nl = (NamedList) values.get("solr.core.collection1");assertNotNull(nl);Object o = nl.get("SEARCHER.new.errors");@@ -128,10 +126,7 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {values = resp.getValues();assertNotNull(values.get("metrics"));values = (NamedList) values.get("metrics");- assertEquals(4, values.size());- assertEquals(0, ((NamedList)values.get("solr.jvm")).size());- assertEquals(0, ((NamedList)values.get("solr.jetty")).size());- assertEquals(0, ((NamedList)values.get("solr.core.collection1")).size());+ assertEquals(1, values.size());assertEquals(11, ((NamedList)values.get("solr.node")).size());assertNotNull(values.get("solr.node"));values = (NamedList) values.get("solr.node");@@ -151,21 +146,30 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {assertNotNull(values.get("CONTAINER.threadPool.coreLoadExecutor.completed"));resp = new SolrQueryResponse();- handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", CommonParams.WT, "json", "group", "jvm", "prefix", "CONTAINER.cores"), resp);+ handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", CommonParams.WT, "json", "prefix", "CACHE.core.fieldCache", "property", "entries_count", "compact", "true"), resp);values = resp.getValues();assertNotNull(values.get("metrics"));values = (NamedList) values.get("metrics");+ assertNotNull(values.get("solr.core.collection1"));+ values = (NamedList) values.get("solr.core.collection1");assertEquals(1, values.size());- assertEquals(0, ((NamedList)values.get("solr.jvm")).size());- assertNull(values.get("solr.node"));+ Map m = (Map)values.get("CACHE.core.fieldCache");+ assertNotNull(m);+ assertNotNull(m.get("entries_count"));++ resp = new SolrQueryResponse();+ handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", CommonParams.WT, "json", "group", "jvm", "prefix", "CONTAINER.cores"), resp);+ values = resp.getValues();+ assertNotNull(values.get("metrics"));+ values = (NamedList) values.get("metrics");+ assertEquals(0, values.size());resp = new SolrQueryResponse();handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", CommonParams.WT, "json", "group", "node", "type", "timer", "prefix", "CONTAINER.cores"), resp);values = resp.getValues();assertNotNull(values.get("metrics"));SimpleOrderedMap map = (SimpleOrderedMap) values.get("metrics");- assertEquals(1, map.size());- assertEquals(0, ((NamedList)map.get("solr.node")).size());+ assertEquals(0, map.size());}@Test@@ -183,4 +187,41 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {assertNotNull(o); // counter typeassertTrue(o instanceof Number);}++ @Test+ public void testPropertyFilter() throws Exception {+ MetricsHandler handler = new MetricsHandler(h.getCoreContainer());++ SolrQueryResponse resp = new SolrQueryResponse();+ handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", CommonParams.WT, "json",+ MetricsHandler.COMPACT_PARAM, "true", "group", "core", "prefix", "CACHE.searcher"), resp);+ NamedList values = resp.getValues();+ assertNotNull(values.get("metrics"));+ values = (NamedList) values.get("metrics");+ NamedList nl = (NamedList) values.get("solr.core.collection1");+ assertNotNull(nl);+ assertTrue(nl.size() > 0);+ nl.forEach((k, v) -> {+ assertTrue(v instanceof Map);+ Map map = (Map)v;+ assertTrue(map.size() > 2);+ });++ resp = new SolrQueryResponse();+ handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", CommonParams.WT, "json",+ MetricsHandler.COMPACT_PARAM, "true", "group", "core", "prefix", "CACHE.searcher",+ "property", "inserts", "property", "size"), resp);+ values = resp.getValues();+ values = (NamedList) values.get("metrics");+ nl = (NamedList) values.get("solr.core.collection1");+ assertNotNull(nl);+ assertTrue(nl.size() > 0);+ nl.forEach((k, v) -> {+ assertTrue(v instanceof Map);+ Map map = (Map)v;+ assertEquals(2, map.size());+ assertNotNull(map.get("inserts"));+ assertNotNull(map.get("size"));+ });+ }}diff --git a/solr/core/src/test/org/apache/solr/metrics/JvmMetricsTest.java b/solr/core/src/test/org/apache/solr/metrics/JvmMetricsTest.javaindex a656f843ba7..55f552b32c4 100644--- a/solr/core/src/test/org/apache/solr/metrics/JvmMetricsTest.java+++ b/solr/core/src/test/org/apache/solr/metrics/JvmMetricsTest.java@@ -16,11 +16,29 @@*/package org.apache.solr.metrics;+import java.nio.file.Path;+import java.nio.file.Paths;+import java.util.Arrays;import java.util.Map;import com.codahale.metrics.Gauge;import com.codahale.metrics.Metric;+import org.apache.commons.io.FileUtils;import org.apache.solr.SolrJettyTestBase;+import org.apache.solr.client.solrj.SolrClient;+import org.apache.solr.client.solrj.SolrQuery;+import org.apache.solr.client.solrj.SolrRequest;+import org.apache.solr.client.solrj.impl.HttpSolrClient;+import org.apache.solr.client.solrj.request.GenericSolrRequest;+import org.apache.solr.client.solrj.response.QueryResponse;+import org.apache.solr.common.params.CommonParams;+import org.apache.solr.common.util.NamedList;+import org.apache.solr.core.NodeConfig;+import org.apache.solr.core.SolrResourceLoader;+import org.apache.solr.core.SolrXmlConfig;+import org.apache.solr.handler.admin.MetricsHandler;+import org.apache.solr.request.SolrQueryRequest;+import org.apache.solr.response.SolrQueryResponse;import org.junit.BeforeClass;import org.junit.Test;@@ -88,6 +106,46 @@ public class JvmMetricsTest extends SolrJettyTestBase {}}+ @Test+ public void testSystemProperties() throws Exception {+ if (System.getProperty("basicauth") == null) {+ // make sure it's set+ System.setProperty("basicauth", "foo:bar");+ }+ SolrMetricManager metricManager = jetty.getCoreContainer().getMetricManager();+ Map<String,Metric> metrics = metricManager.registry("solr.jvm").getMetrics();+ MetricsMap map = (MetricsMap)metrics.get("system.properties");+ assertNotNull(map);+ Map<String,Object> values = map.getValue();+ System.getProperties().forEach((k, v) -> {+ if (NodeConfig.NodeConfigBuilder.DEFAULT_HIDDEN_SYS_PROPS.contains(k)) {+ assertNull("hidden property " + k + " present!", values.get(k));+ } else {+ assertEquals(v, values.get(String.valueOf(k)));+ }+ });+ }++ @Test+ public void testHiddenSysProps() throws Exception {+ Path home = Paths.get(TEST_HOME());+ SolrResourceLoader loader = new SolrResourceLoader(home);++ // default config+ String solrXml = FileUtils.readFileToString(Paths.get(home.toString(), "solr.xml").toFile(), "UTF-8");+ NodeConfig config = SolrXmlConfig.fromString(loader, solrXml);+ NodeConfig.NodeConfigBuilder.DEFAULT_HIDDEN_SYS_PROPS.forEach(s -> {+ assertTrue(s, config.getHiddenSysProps().contains(s));+ });++ // custom config+ solrXml = FileUtils.readFileToString(Paths.get(home.toString(), "solr-hiddensysprops.xml").toFile(), "UTF-8");+ NodeConfig config2 = SolrXmlConfig.fromString(loader, solrXml);+ Arrays.asList("foo", "bar", "baz").forEach(s -> {+ assertTrue(s, config2.getHiddenSysProps().contains(s));+ });+ }+@Testpublic void testSetupJvmMetrics() throws Exception {SolrMetricManager metricManager = jetty.getCoreContainer().getMetricManager();@@ -99,5 +157,6 @@ public class JvmMetricsTest extends SolrJettyTestBase {assertTrue(metrics.toString(), metrics.entrySet().stream().filter(e -> e.getKey().startsWith("gc.")).count() > 0);assertTrue(metrics.toString(), metrics.entrySet().stream().filter(e -> e.getKey().startsWith("memory.")).count() > 0);assertTrue(metrics.toString(), metrics.entrySet().stream().filter(e -> e.getKey().startsWith("threads.")).count() > 0);+ assertTrue(metrics.toString(), metrics.entrySet().stream().filter(e -> e.getKey().startsWith("system.")).count() > 0);}}diff --git a/solr/core/src/test/org/apache/solr/util/stats/MetricUtilsTest.java b/solr/core/src/test/org/apache/solr/util/stats/MetricUtilsTest.javaindex b852a28502a..4eb11691c67 100644--- a/solr/core/src/test/org/apache/solr/util/stats/MetricUtilsTest.java+++ b/solr/core/src/test/org/apache/solr/util/stats/MetricUtilsTest.java@@ -47,7 +47,7 @@ public class MetricUtilsTest extends SolrTestCaseJ4 {}// obtain timer metricsMap<String,Object> map = new HashMap<>();- MetricUtils.convertTimer("", timer, false, false, (k, v) -> {+ MetricUtils.convertTimer("", timer, MetricUtils.PropertyFilter.ALL, false, false, (k, v) -> {map.putAll((Map<String,Object>)v);});NamedList lst = new NamedList(map);@@ -89,7 +89,7 @@ public class MetricUtilsTest extends SolrTestCaseJ4 {Gauge<Long> error = () -> {throw new InternalError("Memory Pool not found error");};registry.register("memory.expected.error", error);MetricUtils.toMaps(registry, Collections.singletonList(MetricFilter.ALL), MetricFilter.ALL,- false, false, false, false, (k, o) -> {+ MetricUtils.PropertyFilter.ALL, false, false, false, false, (k, o) -> {Map v = (Map)o;if (k.startsWith("counter")) {assertEquals(1L, v.get("count"));@@ -119,7 +119,7 @@ public class MetricUtilsTest extends SolrTestCaseJ4 {});// test compact formatMetricUtils.toMaps(registry, Collections.singletonList(MetricFilter.ALL), MetricFilter.ALL,- false, false, true, false, (k, o) -> {+ MetricUtils.PropertyFilter.ALL, false, false, true, false, (k, o) -> {if (k.startsWith("counter")) {assertTrue(o instanceof Long);assertEquals(1L, o);