From 3c3095a85ebb77bd2869a1dd3169bc5966c96f8a Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Tue, 2 Apr 2024 13:31:57 -0400 Subject: [PATCH 01/25] Init commit for dropwizard to prometheus --- solr/core/build.gradle | 9 ++ .../java/org/apache/solr/core/SolrCore.java | 19 +--- .../solr/handler/admin/MetricsHandler.java | 101 +++++++++++++++--- .../response/PrometheusResponseWriter.java | 46 ++++++++ 4 files changed, 146 insertions(+), 29 deletions(-) create mode 100644 solr/core/src/java/org/apache/solr/response/PrometheusResponseWriter.java diff --git a/solr/core/build.gradle b/solr/core/build.gradle index 1c043353ec9..4eac5c2e9a3 100644 --- a/solr/core/build.gradle +++ b/solr/core/build.gradle @@ -153,6 +153,15 @@ dependencies { implementation 'org.apache.logging.log4j:log4j-core' runtimeOnly 'org.apache.logging.log4j:log4j-slf4j2-impl' + // Prometheus client + implementation 'io.prometheus:simpleclient' + implementation 'io.prometheus:simpleclient_common' + implementation 'io.prometheus:simpleclient_dropwizard' + implementation 'io.prometheus:prometheus-metrics-exposition-formats:1.1.0' + implementation 'io.prometheus:prometheus-metrics-simpleclient-bridge:1.1.0' + implementation 'io.prometheus:prometheus-metrics-core:1.1.0' + implementation 'io.prometheus:prometheus-metrics-instrumentation-jvm:1.1.0' + // For faster XML processing than the JDK implementation 'org.codehaus.woodstox:stax2-api' implementation 'com.fasterxml.woodstox:woodstox-core' diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java index c72d9debc55..3179461e02f 100644 --- a/solr/core/src/java/org/apache/solr/core/SolrCore.java +++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java @@ -17,6 +17,7 @@ package org.apache.solr.core; import static org.apache.solr.common.params.CommonParams.PATH; +import static org.apache.solr.handler.admin.MetricsHandler.PROMETHEUS_METRICS_WT; import com.codahale.metrics.Counter; import com.codahale.metrics.Timer; @@ -122,22 +123,7 @@ import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.request.SolrRequestHandler; import org.apache.solr.request.SolrRequestInfo; -import org.apache.solr.response.BinaryResponseWriter; -import org.apache.solr.response.CSVResponseWriter; -import org.apache.solr.response.CborResponseWriter; -import org.apache.solr.response.GeoJSONResponseWriter; -import org.apache.solr.response.GraphMLResponseWriter; -import org.apache.solr.response.JacksonJsonWriter; -import org.apache.solr.response.PHPResponseWriter; -import org.apache.solr.response.PHPSerializedResponseWriter; -import org.apache.solr.response.PythonResponseWriter; -import org.apache.solr.response.QueryResponseWriter; -import org.apache.solr.response.RawResponseWriter; -import org.apache.solr.response.RubyResponseWriter; -import org.apache.solr.response.SchemaXmlResponseWriter; -import org.apache.solr.response.SmileResponseWriter; -import org.apache.solr.response.SolrQueryResponse; -import org.apache.solr.response.XMLResponseWriter; +import org.apache.solr.response.*; import org.apache.solr.response.transform.TransformerFactory; import org.apache.solr.rest.ManagedResourceStorage; import org.apache.solr.rest.ManagedResourceStorage.StorageIO; @@ -3032,6 +3018,7 @@ public PluginBag getResponseWriters() { m.put("csv", new CSVResponseWriter()); m.put("schema.xml", new SchemaXmlResponseWriter()); m.put("smile", new SmileResponseWriter()); + m.put(PROMETHEUS_METRICS_WT, new PrometheusResponseWriter()); m.put(ReplicationHandler.FILE_STREAM, getFileStreamWriter()); DEFAULT_RESPONSE_WRITERS = Collections.unmodifiableMap(m); try { 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.java index 7490278ffc8..03b820f5a8b 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 @@ -38,8 +38,11 @@ import java.util.function.Predicate; import java.util.regex.Pattern; import java.util.stream.Collectors; + +import io.prometheus.metrics.model.registry.PrometheusRegistry; import org.apache.solr.common.MapWriter; import org.apache.solr.common.SolrException; +import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.CommonTestInjection; import org.apache.solr.common.util.NamedList; @@ -68,6 +71,7 @@ public class MetricsHandler extends RequestHandlerBase implements PermissionName public static final String KEY_PARAM = "key"; public static final String EXPR_PARAM = "expr"; public static final String TYPE_PARAM = "type"; + public static final String PROMETHEUS_METRICS_WT = "prometheus"; public static final String ALL = "all"; @@ -117,12 +121,21 @@ public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throw } private void handleRequest(SolrParams params, BiConsumer consumer) - throws Exception { + throws Exception { + NamedList response; + if (!enabled) { consumer.accept("error", "metrics collection is disabled"); return; } boolean compact = params.getBool(COMPACT_PARAM, true); + + Set requestedRegistries = parseRegistries(params); + if (PROMETHEUS_METRICS_WT.equals(params.get(CommonParams.WT))) { + response = handlePrometheusRegistry(params, requestedRegistries); + consumer.accept("metrics", response); + return; + } String[] keys = params.getParams(KEY_PARAM); if (keys != null && keys.length > 0) { handleKeyRequest(keys, consumer); @@ -133,32 +146,94 @@ private void handleRequest(SolrParams params, BiConsumer consume handleExprRequest(exprs, consumer); return; } + + response = handleDropwizardRegistry(params, requestedRegistries); + + consumer.accept("metrics", response); + + } + + private NamedList handleDropwizardRegistry(SolrParams params, Set requestedRegistries) { + boolean compact = params.getBool(COMPACT_PARAM, true); MetricFilter mustMatchFilter = parseMustMatchFilter(params); Predicate propertyFilter = parsePropertyFilter(params); List metricTypes = parseMetricTypes(params); List metricFilters = - metricTypes.stream().map(MetricType::asMetricFilter).collect(Collectors.toList()); - Set requestedRegistries = parseRegistries(params); + metricTypes.stream().map(MetricType::asMetricFilter).collect(Collectors.toList()); + metricTypes.stream().map(MetricType::asMetricFilter).collect(Collectors.toList()); NamedList response = new SimpleOrderedMap<>(); for (String registryName : requestedRegistries) { MetricRegistry registry = metricManager.registry(registryName); SimpleOrderedMap result = new SimpleOrderedMap<>(); + MetricUtils.toMaps( - registry, - metricFilters, - mustMatchFilter, - propertyFilter, - false, - false, - compact, - false, - (k, v) -> result.add(k, v)); + registry, + metricFilters, + mustMatchFilter, + propertyFilter, + false, + false, + compact, + false, + (k, v) -> result.add(k, v)); if (result.size() > 0) { response.add(registryName, result); } } - consumer.accept("metrics", response); + return response; + } + + private NamedList handlePrometheusRegistry(SolrParams params, Set requestedRegistries) { + NamedList response = new SimpleOrderedMap<>(); + boolean compact = params.getBool(COMPACT_PARAM, true); + MetricFilter mustMatchFilter = parseMustMatchFilter(params); + Predicate propertyFilter = parsePropertyFilter(params); + List metricTypes = parseMetricTypes(params); + List metricFilters = + metricTypes.stream().map(MetricType::asMetricFilter).collect(Collectors.toList()); + for (String registryName : requestedRegistries) { + MetricRegistry dropWizardRegistry = metricManager.registry(registryName); + SimpleOrderedMap result = new SimpleOrderedMap<>(); + PrometheusRegistry prometheusRegistry = new PrometheusRegistry(); + if(registryName.equals("solr.core.demo")){ + MetricUtils.toMaps( + dropWizardRegistry, + metricFilters, + mustMatchFilter, + propertyFilter, + false, + false, + compact, + false, + (k, v) -> { + result.add(k, v); + }); + } + Map registryMap = result.asShallowMap(); + String[] splitRegistryName = registryName.split("\\."); + String coreName; + if (splitRegistryName.length == 3) { + coreName = splitRegistryName[2]; + } else if (splitRegistryName.length == 5) { + coreName = "NoCoreNameFound"; + } else { + coreName = "NoCoreNameFound"; + } + io.prometheus.metrics.core.metrics.Counter requestsTotal = io.prometheus.metrics.core.metrics.Counter.builder().name("solr_metrics_core_requests_total").help("Total number of requests to Solr").labelNames("category", "handler", "collection").register(prometheusRegistry); + for (Map.Entry entry : registryMap.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + if (key.endsWith("requests")) { + String[] splitString = key.split("\\."); + if( value instanceof Long ) { + requestsTotal.labelValues(splitString[0], splitString[1], coreName).inc((long) value); + } + } + } + response.add(registryName, prometheusRegistry); + } + return response; } private static class MetricsExpr { diff --git a/solr/core/src/java/org/apache/solr/response/PrometheusResponseWriter.java b/solr/core/src/java/org/apache/solr/response/PrometheusResponseWriter.java new file mode 100644 index 00000000000..834265bdaf1 --- /dev/null +++ b/solr/core/src/java/org/apache/solr/response/PrometheusResponseWriter.java @@ -0,0 +1,46 @@ +package org.apache.solr.response; + +import io.prometheus.client.CollectorRegistry; + +import io.prometheus.metrics.expositionformats.TextFormatUtil; +import io.prometheus.metrics.model.registry.PrometheusRegistry; +import io.prometheus.metrics.model.snapshots.MetricSnapshots; +import org.apache.solr.common.SolrException; +import org.apache.solr.common.params.SolrParams; +import org.apache.solr.common.util.NamedList; +import org.apache.solr.common.util.SimpleOrderedMap; +import org.apache.solr.handler.admin.MetricsHandler; +import org.apache.solr.request.SolrQueryRequest; +import org.w3c.dom.Text; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import io.prometheus.metrics.expositionformats.PrometheusTextFormatWriter; + +@SuppressWarnings (value="unchecked") +public class PrometheusResponseWriter extends RawResponseWriter { + @Override + public void write(OutputStream out, SolrQueryRequest request, SolrQueryResponse response) + throws IOException { + + NamedList prometheusRegistries = (NamedList) response.getValues().get("metrics"); + Map registryMap = prometheusRegistries.asShallowMap(); + PrometheusTextFormatWriter prometheusTextFormatWriter = new PrometheusTextFormatWriter(true); + registryMap.forEach((name, registry) -> { + try { + PrometheusRegistry prometheusRegistry = (PrometheusRegistry) registry; + prometheusTextFormatWriter.write(out, prometheusRegistry.scrape()); + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + + } + +} \ No newline at end of file From 749227dff5d9930a5d3c4c1553f404aed21342d5 Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Tue, 2 Apr 2024 13:32:31 -0400 Subject: [PATCH 02/25] Add request times --- .../solr/handler/admin/MetricsHandler.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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.java index 03b820f5a8b..84c7bd843f7 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 @@ -39,7 +39,9 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; +import io.prometheus.metrics.core.metrics.Summary; import io.prometheus.metrics.model.registry.PrometheusRegistry; +import io.prometheus.metrics.model.snapshots.Unit; import org.apache.solr.common.MapWriter; import org.apache.solr.common.SolrException; import org.apache.solr.common.params.CommonParams; @@ -220,14 +222,18 @@ private NamedList handlePrometheusRegistry(SolrParams params, Set entry : registryMap.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); - if (key.endsWith("requests")) { - String[] splitString = key.split("\\."); - if( value instanceof Long ) { - requestsTotal.labelValues(splitString[0], splitString[1], coreName).inc((long) value); + Map rawMetrics = dropWizardRegistry.getMetrics(); + Metric metric = rawMetrics.get(key); + if (key.endsWith("requestTimes")) { + if (metric instanceof Timer) { + String[] splitString = key.split("\\."); + requestsTotal.labelValues(splitString[0], splitString[1], coreName).inc(((Timer) metric).getCount()); + requestTimesMeanRate.labelValues(splitString[0], splitString[1], coreName).set(((Timer) metric).getMeanRate()); } } } From c58d2dace228835b9b3641b4b0c16f81c024ac51 Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Tue, 2 Apr 2024 14:13:55 -0400 Subject: [PATCH 03/25] Refactor Prometheus metrics into utils --- .../solr/handler/admin/MetricsHandler.java | 35 ++---------- .../apache/solr/util/stats/MetricUtils.java | 56 +++++++++++++++++++ 2 files changed, 60 insertions(+), 31 deletions(-) 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.java index 84c7bd843f7..d7ea3a1186c 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 @@ -197,47 +197,20 @@ private NamedList handlePrometheusRegistry(SolrParams params, Set result = new SimpleOrderedMap<>(); - PrometheusRegistry prometheusRegistry = new PrometheusRegistry(); if(registryName.equals("solr.core.demo")){ - MetricUtils.toMaps( + MetricUtils.toPrometheusRegistry( dropWizardRegistry, + registryName, metricFilters, mustMatchFilter, propertyFilter, false, false, compact, - false, - (k, v) -> { - result.add(k, v); + (registry) -> { + response.add(registryName, registry); }); } - Map registryMap = result.asShallowMap(); - String[] splitRegistryName = registryName.split("\\."); - String coreName; - if (splitRegistryName.length == 3) { - coreName = splitRegistryName[2]; - } else if (splitRegistryName.length == 5) { - coreName = "NoCoreNameFound"; - } else { - coreName = "NoCoreNameFound"; - } - io.prometheus.metrics.core.metrics.Counter requestsTotal = io.prometheus.metrics.core.metrics.Counter.builder().name("solr_metrics_core_requests_total").help("Total number of requests to Solr").labelNames("category", "handler", "collection").withoutExemplars().register(prometheusRegistry); - io.prometheus.metrics.core.metrics.Gauge requestTimesMeanRate = io.prometheus.metrics.core.metrics.Gauge.builder().name("solr_metrics_core_query_mean_rate").help("Mean reate for Solr Query").labelNames("category", "handler", "collection").unit(Unit.SECONDS).withoutExemplars().register(prometheusRegistry); - for (Map.Entry entry : registryMap.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - Map rawMetrics = dropWizardRegistry.getMetrics(); - Metric metric = rawMetrics.get(key); - if (key.endsWith("requestTimes")) { - if (metric instanceof Timer) { - String[] splitString = key.split("\\."); - requestsTotal.labelValues(splitString[0], splitString[1], coreName).inc(((Timer) metric).getCount()); - requestTimesMeanRate.labelValues(splitString[0], splitString[1], coreName).set(((Timer) metric).getMeanRate()); - } - } - } - response.add(registryName, prometheusRegistry); } return response; } 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.java index 1e14ae452fa..32c6108e005 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 @@ -45,6 +45,9 @@ import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Predicate; + +import io.prometheus.metrics.model.registry.PrometheusRegistry; +import io.prometheus.metrics.model.snapshots.Unit; import org.apache.solr.common.ConditionalKeyMapWriter; import org.apache.solr.common.IteratorWriter; import org.apache.solr.common.MapWriter; @@ -165,6 +168,59 @@ public static void toSolrInputDocuments( }); } + public static void toPrometheusRegistry( + MetricRegistry registry, + String registryName, + List shouldMatchFilters, + MetricFilter mustMatchFilter, + Predicate propertyFilter, + boolean skipHistograms, + boolean skipAggregateValues, + boolean compact, + Consumer consumer) { + PrometheusRegistry prometheusRegistry = new PrometheusRegistry(); + Map rawMetrics = registry.getMetrics(); + io.prometheus.metrics.core.metrics.Counter requestsTotal = io.prometheus.metrics.core.metrics.Counter.builder() + .name("solr_metrics_core_requests_total") + .help("Total number of requests to Solr") + .labelNames("category", "handler", "collection") + .withoutExemplars().register(prometheusRegistry); + io.prometheus.metrics.core.metrics.Gauge requestTimesMeanRate = io.prometheus.metrics.core.metrics.Gauge.builder() + .name("solr_metrics_core_query_mean_rate") + .help("Mean reate for Solr Query") + .labelNames("category", "handler", "collection") + .unit(Unit.SECONDS).withoutExemplars().register(prometheusRegistry); + toMaps( + registry, + shouldMatchFilters, + mustMatchFilter, + propertyFilter, + skipHistograms, + skipAggregateValues, + compact, + false, + (metricName, metric) -> { + String[] splitRegistryName = registryName.split("\\."); + String coreName; + if (splitRegistryName.length == 3) { + coreName = splitRegistryName[2]; + } else if (splitRegistryName.length == 5) { + coreName = "NoCoreNameFound"; + } else { + coreName = "NoCoreNameFound"; + } + Metric rawMetric = rawMetrics.get(metricName); + if (metricName.endsWith("requestTimes")) { + if (rawMetric instanceof Timer) { + String[] splitString = metricName.split("\\."); + requestsTotal.labelValues(splitString[0], splitString[1], coreName).inc(((Timer) rawMetric).getCount()); + requestTimesMeanRate.labelValues(splitString[0], splitString[1], coreName).set(((Timer) rawMetric).getMeanRate()); + } + } + }); + consumer.accept(prometheusRegistry); + } + /** * Fill in a SolrInputDocument with values from a converted metric, recursively. * From 936aaeb27584ea75c08087c5a34fcccf8c76f0f3 Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Tue, 2 Apr 2024 16:10:53 -0400 Subject: [PATCH 04/25] Create base SolrPrometheusMetrics class --- .../prometheus/SolrPrometheusCoreMetrics.java | 36 ++++++++++++ .../prometheus/SolrPrometheusMetrics.java | 58 +++++++++++++++++++ .../apache/solr/util/stats/MetricUtils.java | 32 +++++----- 3 files changed, 107 insertions(+), 19 deletions(-) create mode 100644 solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java create mode 100644 solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusMetrics.java diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java new file mode 100644 index 00000000000..dc2f30a4c2c --- /dev/null +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java @@ -0,0 +1,36 @@ +package org.apache.solr.metrics.prometheus; + +import com.codahale.metrics.Metric; +import com.codahale.metrics.Timer; +import io.prometheus.metrics.core.metrics.Counter; +import io.prometheus.metrics.core.metrics.Gauge; +import io.prometheus.metrics.model.registry.PrometheusRegistry; +import io.prometheus.metrics.model.snapshots.Unit; + +import java.util.Map; + +public class SolrPrometheusCoreMetrics extends SolrPrometheusMetrics { + public static final String CORE_REQUESTS_TOTAL = "solr_metrics_core_query_requests_total"; + public static final String CORE_REQUESTS_QUERY_MEAN_RATE = "solr_metrics_core_query_mean_rate"; + + public SolrPrometheusCoreMetrics(PrometheusRegistry prometheusRegistry) { + super(prometheusRegistry); + } + + @Override + public SolrPrometheusCoreMetrics registerDefaultMetrics() { + registerCounter(CORE_REQUESTS_TOTAL, "Solr requests Total", "category", "handler", "collection"); + registerGauge(CORE_REQUESTS_QUERY_MEAN_RATE, "Solr requests Mean rate", "category", "handler", "collection"); + return this; + } + + public void convertDropwizardMetric(String metricName, String coreName, Metric dropwizardMetric) { + System.out.println(dropwizardMetric.toString()); + if (dropwizardMetric instanceof Timer) { + String[] splitString = metricName.split("\\."); + getMetricCounter(CORE_REQUESTS_TOTAL).labelValues(splitString[0], splitString[1], coreName).inc(((Timer) dropwizardMetric).getCount()); + getMetricGauge(CORE_REQUESTS_QUERY_MEAN_RATE).labelValues(splitString[0], splitString[1], coreName).set(((Timer) dropwizardMetric).getMeanRate()); + } + } + +} diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusMetrics.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusMetrics.java new file mode 100644 index 00000000000..d0531ce51c6 --- /dev/null +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusMetrics.java @@ -0,0 +1,58 @@ +package org.apache.solr.metrics.prometheus; + +import io.prometheus.metrics.core.metrics.Counter; +import io.prometheus.metrics.core.metrics.Gauge; +import io.prometheus.metrics.model.registry.PrometheusRegistry; +import io.prometheus.metrics.model.snapshots.Unit; + +import java.util.Map; + +public abstract class SolrPrometheusMetrics { + PrometheusRegistry prometheusRegistry; + String registryName; + private Map metricCounters; + private Map metricGauges; + + public SolrPrometheusMetrics(PrometheusRegistry prometheusRegistry) { + this.prometheusRegistry = prometheusRegistry; + } + + public PrometheusRegistry getPrometheusRegistry() { + return prometheusRegistry; + } + + public String getRegistryName() { + return registryName; + } + + public Counter getMetricCounter(String metricName) { + return metricCounters.get(metricName); + } + + public Gauge getMetricGauge(String metricName) { + return metricGauges.get(metricName); + } + + abstract SolrPrometheusMetrics registerDefaultMetrics(); + + protected Counter registerCounter(String metricName, String help, String ...labelNames) { + Counter metricCounter = io.prometheus.metrics.core.metrics.Counter.builder() + .name(metricName) + .help(help) + .labelNames(labelNames) + .withoutExemplars().register(prometheusRegistry); + metricCounters.put(metricName, metricCounter); + return metricCounter; + } + + protected Gauge registerGauge(String metricName, String help, String ...labelNames) { + Gauge metricGauge = io.prometheus.metrics.core.metrics.Gauge.builder() + .name(metricName) + .help(help) + .labelNames(labelNames) + .unit(Unit.SECONDS).withoutExemplars().register(prometheusRegistry); + metricGauges.put(metricName, metricGauge); + return metricGauge; + } + +} 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.java index 32c6108e005..345f673f7d8 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 @@ -56,9 +56,13 @@ import org.apache.solr.core.SolrInfoBean; import org.apache.solr.metrics.AggregateMetric; import org.apache.solr.metrics.SolrMetricManager; +import org.apache.solr.metrics.prometheus.SolrPrometheusCoreMetrics; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.solr.metrics.prometheus.SolrPrometheusCoreMetrics.CORE_REQUESTS_QUERY_MEAN_RATE; +import static org.apache.solr.metrics.prometheus.SolrPrometheusCoreMetrics.CORE_REQUESTS_TOTAL; + /** Metrics specific utility functions. */ public class MetricUtils { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -178,18 +182,8 @@ public static void toPrometheusRegistry( boolean skipAggregateValues, boolean compact, Consumer consumer) { - PrometheusRegistry prometheusRegistry = new PrometheusRegistry(); - Map rawMetrics = registry.getMetrics(); - io.prometheus.metrics.core.metrics.Counter requestsTotal = io.prometheus.metrics.core.metrics.Counter.builder() - .name("solr_metrics_core_requests_total") - .help("Total number of requests to Solr") - .labelNames("category", "handler", "collection") - .withoutExemplars().register(prometheusRegistry); - io.prometheus.metrics.core.metrics.Gauge requestTimesMeanRate = io.prometheus.metrics.core.metrics.Gauge.builder() - .name("solr_metrics_core_query_mean_rate") - .help("Mean reate for Solr Query") - .labelNames("category", "handler", "collection") - .unit(Unit.SECONDS).withoutExemplars().register(prometheusRegistry); + Map dropwizardMetrics = registry.getMetrics(); + SolrPrometheusCoreMetrics solrPrometheusCoreMetrics = new SolrPrometheusCoreMetrics(new PrometheusRegistry()).registerDefaultMetrics(); toMaps( registry, shouldMatchFilters, @@ -209,16 +203,12 @@ public static void toPrometheusRegistry( } else { coreName = "NoCoreNameFound"; } - Metric rawMetric = rawMetrics.get(metricName); + Metric dropwizardMetric = dropwizardMetrics.get(metricName); if (metricName.endsWith("requestTimes")) { - if (rawMetric instanceof Timer) { - String[] splitString = metricName.split("\\."); - requestsTotal.labelValues(splitString[0], splitString[1], coreName).inc(((Timer) rawMetric).getCount()); - requestTimesMeanRate.labelValues(splitString[0], splitString[1], coreName).set(((Timer) rawMetric).getMeanRate()); - } + solrPrometheusCoreMetrics.convertDropwizardMetric(metricName, coreName, dropwizardMetric); } }); - consumer.accept(prometheusRegistry); + consumer.accept(solrPrometheusCoreMetrics.getPrometheusRegistry()); } /** @@ -623,6 +613,10 @@ public static void convertTimer( } } + public static void convertTimerToPrometheus() { + + } + /** * Convert a {@link Meter} to a map. * From 428fe2acc1c71dd524a4f0fa70f9ed1d50813466 Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Wed, 3 Apr 2024 12:59:31 -0400 Subject: [PATCH 05/25] Add new prometheus metric types --- .../prometheus/SolrPrometheusCoreMetrics.java | 37 +++++++++++------ .../prometheus/SolrPrometheusMetrics.java | 41 +++++++++++++++---- .../response/PrometheusResponseWriter.java | 2 +- .../apache/solr/util/stats/MetricUtils.java | 20 ++++----- 4 files changed, 68 insertions(+), 32 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java index dc2f30a4c2c..0aa53518f75 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java @@ -1,17 +1,18 @@ package org.apache.solr.metrics.prometheus; -import com.codahale.metrics.Metric; -import com.codahale.metrics.Timer; -import io.prometheus.metrics.core.metrics.Counter; -import io.prometheus.metrics.core.metrics.Gauge; +import com.codahale.metrics.*; import io.prometheus.metrics.model.registry.PrometheusRegistry; +import io.prometheus.metrics.model.snapshots.Quantiles; import io.prometheus.metrics.model.snapshots.Unit; import java.util.Map; public class SolrPrometheusCoreMetrics extends SolrPrometheusMetrics { - public static final String CORE_REQUESTS_TOTAL = "solr_metrics_core_query_requests_total"; - public static final String CORE_REQUESTS_QUERY_MEAN_RATE = "solr_metrics_core_query_mean_rate"; + public static final String CORE_REQUESTS_TOTAL = "solr_metrics_core_requests_total"; + public static final String CORE_REQUESTS_TOTAL_TIME = "solr_metrics_core_requests_total_time"; + public static final String CORE_REQUESTS_QUERY_MEAN_RATE = "solr_metrics_core_mean_rate"; + public static final String CORE_REQUEST_TIMES_HIST = "solr_metrics_request_times_histogram"; + public static final String CORE_REQUEST_TIMES_SUM = "solr_metrics_request_times_summary"; public SolrPrometheusCoreMetrics(PrometheusRegistry prometheusRegistry) { super(prometheusRegistry); @@ -19,18 +20,30 @@ public SolrPrometheusCoreMetrics(PrometheusRegistry prometheusRegistry) { @Override public SolrPrometheusCoreMetrics registerDefaultMetrics() { - registerCounter(CORE_REQUESTS_TOTAL, "Solr requests Total", "category", "handler", "collection"); + registerCounter(CORE_REQUESTS_TOTAL, "Solr requests Total", "category", "handler", "collection", "type"); + registerCounter(CORE_REQUESTS_TOTAL_TIME, "Solr requests Total", "category", "handler", "collection", "type"); registerGauge(CORE_REQUESTS_QUERY_MEAN_RATE, "Solr requests Mean rate", "category", "handler", "collection"); + registerHistogram(CORE_REQUEST_TIMES_HIST, "Solr Requests times", "category", "handler", "collection", "type"); + registerSummary(CORE_REQUEST_TIMES_SUM, "Solr Request Times Summary", "category", "handler", "collection", "type"); return this; } public void convertDropwizardMetric(String metricName, String coreName, Metric dropwizardMetric) { System.out.println(dropwizardMetric.toString()); - if (dropwizardMetric instanceof Timer) { - String[] splitString = metricName.split("\\."); - getMetricCounter(CORE_REQUESTS_TOTAL).labelValues(splitString[0], splitString[1], coreName).inc(((Timer) dropwizardMetric).getCount()); - getMetricGauge(CORE_REQUESTS_QUERY_MEAN_RATE).labelValues(splitString[0], splitString[1], coreName).set(((Timer) dropwizardMetric).getMeanRate()); + String[] splitString = metricName.split("\\."); + if (dropwizardMetric instanceof Meter) { + getMetricCounter(CORE_REQUESTS_TOTAL).labelValues(splitString[0], splitString[1], coreName, splitString[2]).inc(((Meter) dropwizardMetric).getCount()); + } else if (dropwizardMetric instanceof Timer) { + System.out.println("GET TIME"); +// getMetricHistogram(CORE_REQUEST_TIMES_HIST).labelValues(splitString[0], splitString[1], coreName, splitString[2]).observe(((Timer) dropwizardMetric).getOneMinuteRate()); + } else if (dropwizardMetric instanceof Counter) { + if (metricName.endsWith("requests")) { + getMetricCounter(CORE_REQUESTS_TOTAL).labelValues(splitString[0], splitString[1], coreName, splitString[2]).inc(((Counter) dropwizardMetric).getCount()); + } else if (metricName.endsWith("totalTime")) { + getMetricCounter(CORE_REQUESTS_TOTAL_TIME).labelValues(splitString[0], splitString[1], coreName, splitString[2]).inc(((Counter) dropwizardMetric).getCount()); + } + } else if (dropwizardMetric instanceof Gauge) { + } } - } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusMetrics.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusMetrics.java index d0531ce51c6..9dbd79256fb 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusMetrics.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusMetrics.java @@ -2,19 +2,28 @@ import io.prometheus.metrics.core.metrics.Counter; import io.prometheus.metrics.core.metrics.Gauge; +import io.prometheus.metrics.core.metrics.Histogram; +import io.prometheus.metrics.core.metrics.Summary; import io.prometheus.metrics.model.registry.PrometheusRegistry; import io.prometheus.metrics.model.snapshots.Unit; +import java.util.HashMap; import java.util.Map; public abstract class SolrPrometheusMetrics { PrometheusRegistry prometheusRegistry; String registryName; - private Map metricCounters; - private Map metricGauges; + private final Map metricCounters; + private final Map metricGauges; + private final Map metricHistograms; + private final Map metricSummaries; public SolrPrometheusMetrics(PrometheusRegistry prometheusRegistry) { this.prometheusRegistry = prometheusRegistry; + this.metricCounters = new HashMap<>(); + this.metricGauges = new HashMap<>(); + this.metricHistograms = new HashMap<>(); + this.metricSummaries = new HashMap<>(); } public PrometheusRegistry getPrometheusRegistry() { @@ -32,27 +41,43 @@ public Counter getMetricCounter(String metricName) { public Gauge getMetricGauge(String metricName) { return metricGauges.get(metricName); } + public Histogram getMetricHistogram(String metricName) { return metricHistograms.get(metricName); } + + public Summary getMetricSummary(String metricName) { return metricSummaries.get(metricName); } abstract SolrPrometheusMetrics registerDefaultMetrics(); - protected Counter registerCounter(String metricName, String help, String ...labelNames) { + protected void registerCounter(String metricName, String help, String ...labelNames) { Counter metricCounter = io.prometheus.metrics.core.metrics.Counter.builder() .name(metricName) .help(help) .labelNames(labelNames) - .withoutExemplars().register(prometheusRegistry); + .register(prometheusRegistry); metricCounters.put(metricName, metricCounter); - return metricCounter; } - protected Gauge registerGauge(String metricName, String help, String ...labelNames) { + protected void registerGauge(String metricName, String help, String ...labelNames) { Gauge metricGauge = io.prometheus.metrics.core.metrics.Gauge.builder() .name(metricName) .help(help) .labelNames(labelNames) - .unit(Unit.SECONDS).withoutExemplars().register(prometheusRegistry); + .unit(Unit.SECONDS).register(prometheusRegistry); metricGauges.put(metricName, metricGauge); - return metricGauge; + } + + protected void registerHistogram(String metricName, String help, String ...labelNames) { + Histogram metricHistogram = Histogram.builder() + .name(metricName) + .help(help) + .labelNames(labelNames) + .unit(Unit.SECONDS) + .register(prometheusRegistry); + metricHistograms.put(metricName, metricHistogram); + } + + protected void registerSummary(String metricName, String help, String ...labelNames) { + Summary metricSummary = Summary.builder().name(metricName).help(help).labelNames(labelNames).unit(Unit.SECONDS).register(prometheusRegistry); + metricSummaries.put(metricName, metricSummary); } } diff --git a/solr/core/src/java/org/apache/solr/response/PrometheusResponseWriter.java b/solr/core/src/java/org/apache/solr/response/PrometheusResponseWriter.java index 834265bdaf1..033c1fa46dd 100644 --- a/solr/core/src/java/org/apache/solr/response/PrometheusResponseWriter.java +++ b/solr/core/src/java/org/apache/solr/response/PrometheusResponseWriter.java @@ -31,7 +31,7 @@ public void write(OutputStream out, SolrQueryRequest request, SolrQueryResponse NamedList prometheusRegistries = (NamedList) response.getValues().get("metrics"); Map registryMap = prometheusRegistries.asShallowMap(); - PrometheusTextFormatWriter prometheusTextFormatWriter = new PrometheusTextFormatWriter(true); + PrometheusTextFormatWriter prometheusTextFormatWriter = new PrometheusTextFormatWriter(false); registryMap.forEach((name, registry) -> { try { PrometheusRegistry prometheusRegistry = (PrometheusRegistry) registry; 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.java index 345f673f7d8..cbdd7bd76db 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 @@ -35,11 +35,7 @@ import java.lang.management.OperatingSystemMXBean; import java.lang.management.PlatformManagedObject; import java.lang.reflect.InvocationTargetException; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.SortedSet; +import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import java.util.function.BiConsumer; @@ -184,6 +180,9 @@ public static void toPrometheusRegistry( Consumer consumer) { Map dropwizardMetrics = registry.getMetrics(); SolrPrometheusCoreMetrics solrPrometheusCoreMetrics = new SolrPrometheusCoreMetrics(new PrometheusRegistry()).registerDefaultMetrics(); + +// Set category = new HashSet<>(); + Map> categories = new HashMap<>(); toMaps( registry, shouldMatchFilters, @@ -204,9 +203,12 @@ public static void toPrometheusRegistry( coreName = "NoCoreNameFound"; } Metric dropwizardMetric = dropwizardMetrics.get(metricName); - if (metricName.endsWith("requestTimes")) { - solrPrometheusCoreMetrics.convertDropwizardMetric(metricName, coreName, dropwizardMetric); + String[] splitString = metricName.split("\\."); + if(!categories.containsKey(splitString[0])) { + categories.put(splitString[0], new ArrayList<>()); } + categories.get(splitString[0]).add(metricName); + solrPrometheusCoreMetrics.convertDropwizardMetric(metricName, coreName, dropwizardMetric); }); consumer.accept(solrPrometheusCoreMetrics.getPrometheusRegistry()); } @@ -613,10 +615,6 @@ public static void convertTimer( } } - public static void convertTimerToPrometheus() { - - } - /** * Convert a {@link Meter} to a map. * From b418f6838df0cd156ab2465fdc03e2c6e29fa45b Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Fri, 5 Apr 2024 16:50:44 -0400 Subject: [PATCH 06/25] Convert TLOG and Cache to Prometheus --- .../prometheus/SolrPrometheusCoreMetrics.java | 95 ++++++++++++++++--- .../prometheus/SolrPrometheusMetrics.java | 2 +- .../apache/solr/util/stats/MetricUtils.java | 9 +- 3 files changed, 90 insertions(+), 16 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java index 0aa53518f75..922ffeb1b50 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java @@ -5,14 +5,21 @@ import io.prometheus.metrics.model.snapshots.Quantiles; import io.prometheus.metrics.model.snapshots.Unit; +import java.util.HashMap; +import java.util.HashSet; import java.util.Map; +import java.util.Set; public class SolrPrometheusCoreMetrics extends SolrPrometheusMetrics { public static final String CORE_REQUESTS_TOTAL = "solr_metrics_core_requests_total"; public static final String CORE_REQUESTS_TOTAL_TIME = "solr_metrics_core_requests_total_time"; public static final String CORE_REQUESTS_QUERY_MEAN_RATE = "solr_metrics_core_mean_rate"; + public static final String CORE_UPDATE_HANDLER = "solr_metrics_core_update_handler_metrics"; + public static final String CORE_HANDLER_HANDLER_START = "solr_metrics_core_handler_start"; public static final String CORE_REQUEST_TIMES_HIST = "solr_metrics_request_times_histogram"; public static final String CORE_REQUEST_TIMES_SUM = "solr_metrics_request_times_summary"; + public static final String CORE_CACHE_SEARCHER_METRICS = "solr_metrics_core_cache_gauge"; + public static final String CORE_TLOG_METRICS = "solr_metrics_tlog_replicas"; public SolrPrometheusCoreMetrics(PrometheusRegistry prometheusRegistry) { super(prometheusRegistry); @@ -22,7 +29,11 @@ public SolrPrometheusCoreMetrics(PrometheusRegistry prometheusRegistry) { public SolrPrometheusCoreMetrics registerDefaultMetrics() { registerCounter(CORE_REQUESTS_TOTAL, "Solr requests Total", "category", "handler", "collection", "type"); registerCounter(CORE_REQUESTS_TOTAL_TIME, "Solr requests Total", "category", "handler", "collection", "type"); + registerCounter(CORE_TLOG_METRICS, "Solr TLOG Metrics", "collection", "item", "type"); registerGauge(CORE_REQUESTS_QUERY_MEAN_RATE, "Solr requests Mean rate", "category", "handler", "collection"); + registerGauge(CORE_HANDLER_HANDLER_START, "Handler Start Time", "category", "handler", "collection", "type"); + registerGauge(CORE_UPDATE_HANDLER, "Handler Start Time", "category", "handler", "collection", "type"); + registerGauge(CORE_CACHE_SEARCHER_METRICS, "Search Cache Metrics", "collection", "cacheType", "item"); registerHistogram(CORE_REQUEST_TIMES_HIST, "Solr Requests times", "category", "handler", "collection", "type"); registerSummary(CORE_REQUEST_TIMES_SUM, "Solr Request Times Summary", "category", "handler", "collection", "type"); return this; @@ -31,19 +42,79 @@ public SolrPrometheusCoreMetrics registerDefaultMetrics() { public void convertDropwizardMetric(String metricName, String coreName, Metric dropwizardMetric) { System.out.println(dropwizardMetric.toString()); String[] splitString = metricName.split("\\."); - if (dropwizardMetric instanceof Meter) { - getMetricCounter(CORE_REQUESTS_TOTAL).labelValues(splitString[0], splitString[1], coreName, splitString[2]).inc(((Meter) dropwizardMetric).getCount()); - } else if (dropwizardMetric instanceof Timer) { - System.out.println("GET TIME"); -// getMetricHistogram(CORE_REQUEST_TIMES_HIST).labelValues(splitString[0], splitString[1], coreName, splitString[2]).observe(((Timer) dropwizardMetric).getOneMinuteRate()); - } else if (dropwizardMetric instanceof Counter) { - if (metricName.endsWith("requests")) { - getMetricCounter(CORE_REQUESTS_TOTAL).labelValues(splitString[0], splitString[1], coreName, splitString[2]).inc(((Counter) dropwizardMetric).getCount()); - } else if (metricName.endsWith("totalTime")) { - getMetricCounter(CORE_REQUESTS_TOTAL_TIME).labelValues(splitString[0], splitString[1], coreName, splitString[2]).inc(((Counter) dropwizardMetric).getCount()); + Set notFound = new HashSet<>(); + switch (splitString[0]) { + case "ADMIN": + case "QUERY": + case "UPDATE": + case "REPLICATION": { + if (dropwizardMetric instanceof Meter) { + getMetricCounter(CORE_REQUESTS_TOTAL).labelValues(splitString[0], splitString[1], coreName, splitString[2]).inc(((Meter) dropwizardMetric).getCount()); + } else if (dropwizardMetric instanceof Counter) { + if (metricName.endsWith("requests")) { + getMetricCounter(CORE_REQUESTS_TOTAL).labelValues(splitString[0], splitString[1], coreName, splitString[2]).inc(((Counter) dropwizardMetric).getCount()); + } else if (metricName.endsWith("totalTime")) { + getMetricCounter(CORE_REQUESTS_TOTAL_TIME).labelValues(splitString[0], splitString[1], coreName, splitString[2]).inc(((Counter) dropwizardMetric).getCount()); + } + } else if (dropwizardMetric instanceof Gauge) { + Object obj = ((Gauge) dropwizardMetric).getValue(); + double value; + if (obj instanceof Number) { + value = ((Number) obj).doubleValue(); + } else { + System.out.println("FAILED"); + break; + } + if (metricName.endsWith("handlerStart")){ + getMetricGauge(CORE_HANDLER_HANDLER_START).labelValues(splitString[0], splitString[1], coreName, splitString[2]).set(value); + } else { + getMetricGauge(CORE_UPDATE_HANDLER).labelValues(splitString[0], splitString[1], coreName, splitString[2]).set(value); + } + } else { + notFound.add(metricName); + } + break; + } + case "CORE": { + System.out.println("Not possible to migrate string values to prometheus"); + break; + } + case "TLOG": { + if (dropwizardMetric instanceof Meter) { + getMetricCounter(CORE_TLOG_METRICS).labelValues(coreName, splitString[1], splitString[2]).inc(((Meter) dropwizardMetric).getCount()); + } else { + System.out.println("Not possible to migrate string values to prometheus"); + break; + } + break; + } + case "SEARCHER": + case "HIGHLIGHTER": + case "INDEX": + case "CACHE": { + if (dropwizardMetric instanceof Gauge) { + Object obj = ((Gauge) dropwizardMetric).getValue(); + if (obj instanceof Number) { + double value; + value = ((Number) obj).doubleValue(); + } else if (obj instanceof HashMap) { + HashMap itemsMap = (HashMap) obj; + for (Object item : itemsMap.keySet()) { + if (itemsMap.get(item) instanceof Number) { + getMetricGauge(CORE_CACHE_SEARCHER_METRICS).labelValues(coreName, splitString[2], (String) item).set( ((Number) itemsMap.get(item)).doubleValue()); + } else { + System.out.println("This is not an number"); + } + } + } else { + break; + } + } + break; + } + default: { + System.out.println(splitString[0]); } - } else if (dropwizardMetric instanceof Gauge) { - } } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusMetrics.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusMetrics.java index 9dbd79256fb..1b6857be631 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusMetrics.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusMetrics.java @@ -61,7 +61,7 @@ protected void registerGauge(String metricName, String help, String ...labelName .name(metricName) .help(help) .labelNames(labelNames) - .unit(Unit.SECONDS).register(prometheusRegistry); + .register(prometheusRegistry); metricGauges.put(metricName, metricGauge); } 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.java index cbdd7bd76db..c9225e39910 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 @@ -182,7 +182,7 @@ public static void toPrometheusRegistry( SolrPrometheusCoreMetrics solrPrometheusCoreMetrics = new SolrPrometheusCoreMetrics(new PrometheusRegistry()).registerDefaultMetrics(); // Set category = new HashSet<>(); - Map> categories = new HashMap<>(); + Map> categories = new HashMap<>(); toMaps( registry, shouldMatchFilters, @@ -205,9 +205,12 @@ public static void toPrometheusRegistry( Metric dropwizardMetric = dropwizardMetrics.get(metricName); String[] splitString = metricName.split("\\."); if(!categories.containsKey(splitString[0])) { - categories.put(splitString[0], new ArrayList<>()); + categories.put(splitString[0], new HashMap<>()); } - categories.get(splitString[0]).add(metricName); + if(!categories.get(splitString[0]).containsKey(metricName)) { + categories.get(splitString[0]).put(metricName, dropwizardMetric); + } +// categories.get(splitString[0]).add(metricName); solrPrometheusCoreMetrics.convertDropwizardMetric(metricName, coreName, dropwizardMetric); }); consumer.accept(solrPrometheusCoreMetrics.getPrometheusRegistry()); From 178ee25a7ac28bf9b5db0b88490fc3224dfec5d9 Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Mon, 8 Apr 2024 16:34:14 -0400 Subject: [PATCH 07/25] Add highlighter conversion --- .../solr/handler/admin/MetricsHandler.java | 2 +- .../prometheus/SolrPrometheusCoreMetrics.java | 45 +++++++++++++++++-- 2 files changed, 42 insertions(+), 5 deletions(-) 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.java index d7ea3a1186c..6227ff62a3f 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 @@ -197,7 +197,7 @@ private NamedList handlePrometheusRegistry(SolrParams params, Set result = new SimpleOrderedMap<>(); - if(registryName.equals("solr.core.demo")){ + if(registryName.startsWith("solr.core")){ MetricUtils.toPrometheusRegistry( dropWizardRegistry, registryName, diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java index 922ffeb1b50..ed816f023ea 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java @@ -20,6 +20,8 @@ public class SolrPrometheusCoreMetrics extends SolrPrometheusMetrics { public static final String CORE_REQUEST_TIMES_SUM = "solr_metrics_request_times_summary"; public static final String CORE_CACHE_SEARCHER_METRICS = "solr_metrics_core_cache_gauge"; public static final String CORE_TLOG_METRICS = "solr_metrics_tlog_replicas"; + public static final String CORE_SEARCHER_METRICS = "solr_metrics_core_searcher"; + public static final String CORE_HIGHLIGHER_METRICS = "solr_metrics_core_highlighter_requests"; public SolrPrometheusCoreMetrics(PrometheusRegistry prometheusRegistry) { super(prometheusRegistry); @@ -29,10 +31,12 @@ public SolrPrometheusCoreMetrics(PrometheusRegistry prometheusRegistry) { public SolrPrometheusCoreMetrics registerDefaultMetrics() { registerCounter(CORE_REQUESTS_TOTAL, "Solr requests Total", "category", "handler", "collection", "type"); registerCounter(CORE_REQUESTS_TOTAL_TIME, "Solr requests Total", "category", "handler", "collection", "type"); - registerCounter(CORE_TLOG_METRICS, "Solr TLOG Metrics", "collection", "item", "type"); + registerCounter(CORE_TLOG_METRICS, "Solr TLOG Metrics", "collection", "type", "item"); + registerCounter(CORE_HIGHLIGHER_METRICS, "Solr Highlighter Metrics", "collection", "type", "item"); registerGauge(CORE_REQUESTS_QUERY_MEAN_RATE, "Solr requests Mean rate", "category", "handler", "collection"); registerGauge(CORE_HANDLER_HANDLER_START, "Handler Start Time", "category", "handler", "collection", "type"); registerGauge(CORE_UPDATE_HANDLER, "Handler Start Time", "category", "handler", "collection", "type"); + registerGauge(CORE_SEARCHER_METRICS, "SearcherMetrics", "collecton", "searcherItem"); registerGauge(CORE_CACHE_SEARCHER_METRICS, "Search Cache Metrics", "collection", "cacheType", "item"); registerHistogram(CORE_REQUEST_TIMES_HIST, "Solr Requests times", "category", "handler", "collection", "type"); registerSummary(CORE_REQUEST_TIMES_SUM, "Solr Request Times Summary", "category", "handler", "collection", "type"); @@ -88,9 +92,6 @@ public void convertDropwizardMetric(String metricName, String coreName, Metric d } break; } - case "SEARCHER": - case "HIGHLIGHTER": - case "INDEX": case "CACHE": { if (dropwizardMetric instanceof Gauge) { Object obj = ((Gauge) dropwizardMetric).getValue(); @@ -112,6 +113,42 @@ public void convertDropwizardMetric(String metricName, String coreName, Metric d } break; } + case "SEARCHER":{ + if (dropwizardMetric instanceof Gauge) { + Object obj = ((Gauge) dropwizardMetric).getValue(); + double value; + if (obj instanceof Number) { + value = ((Number) obj).doubleValue(); + getMetricGauge(CORE_SEARCHER_METRICS).labelValues(coreName, splitString[2]).set(value); + } else if (obj instanceof Boolean) { + value = ((Boolean) obj) ? 1 : 0; + } else if (obj instanceof HashMap) { + HashMap itemsMap = (HashMap) obj; + for (Object item : itemsMap.keySet()) { + if (itemsMap.get(item) instanceof Number) { + getMetricGauge(CORE_SEARCHER_METRICS).labelValues(coreName, splitString[2]).set( ((Number) itemsMap.get(item)).doubleValue()); + } else { + System.out.println("This is not an number"); + } + } + } else { + System.out.println("Other type"); + break; + } + } + break; + } + case "HIGHLIGHTER": { + if (dropwizardMetric instanceof Counter) { + getMetricCounter(CORE_HIGHLIGHER_METRICS).labelValues(coreName, splitString[1], splitString[2]).inc(((Counter) dropwizardMetric).getCount()); + } else { + System.out.println("Non existent type"); + } + break; + } + case "INDEX": { + break; + } default: { System.out.println(splitString[0]); } From bd5d699d1c09dc32b5f4b04c4ecc39d9efdd7f91 Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Mon, 8 Apr 2024 16:43:20 -0400 Subject: [PATCH 08/25] Convert INDEX metrics --- .../prometheus/SolrPrometheusCoreMetrics.java | 14 ++++++++++++-- .../org/apache/solr/util/stats/MetricUtils.java | 2 -- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java index ed816f023ea..02eb9daa5a1 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java @@ -22,6 +22,7 @@ public class SolrPrometheusCoreMetrics extends SolrPrometheusMetrics { public static final String CORE_TLOG_METRICS = "solr_metrics_tlog_replicas"; public static final String CORE_SEARCHER_METRICS = "solr_metrics_core_searcher"; public static final String CORE_HIGHLIGHER_METRICS = "solr_metrics_core_highlighter_requests"; + public static final String CORE_INDEX_METRICS = "solr_metrics_index"; public SolrPrometheusCoreMetrics(PrometheusRegistry prometheusRegistry) { super(prometheusRegistry); @@ -36,8 +37,9 @@ public SolrPrometheusCoreMetrics registerDefaultMetrics() { registerGauge(CORE_REQUESTS_QUERY_MEAN_RATE, "Solr requests Mean rate", "category", "handler", "collection"); registerGauge(CORE_HANDLER_HANDLER_START, "Handler Start Time", "category", "handler", "collection", "type"); registerGauge(CORE_UPDATE_HANDLER, "Handler Start Time", "category", "handler", "collection", "type"); - registerGauge(CORE_SEARCHER_METRICS, "SearcherMetrics", "collecton", "searcherItem"); - registerGauge(CORE_CACHE_SEARCHER_METRICS, "Search Cache Metrics", "collection", "cacheType", "item"); + registerGauge(CORE_SEARCHER_METRICS, "SearcherMetrics", "collection", "searcherItem"); + registerGauge(CORE_CACHE_SEARCHER_METRICS, "Searcher Cache Metrics", "collection", "cacheType", "item"); + registerGauge(CORE_INDEX_METRICS, "Index Metrics", "collection", "type"); registerHistogram(CORE_REQUEST_TIMES_HIST, "Solr Requests times", "category", "handler", "collection", "type"); registerSummary(CORE_REQUEST_TIMES_SUM, "Solr Request Times Summary", "category", "handler", "collection", "type"); return this; @@ -147,6 +149,14 @@ public void convertDropwizardMetric(String metricName, String coreName, Metric d break; } case "INDEX": { + if (dropwizardMetric instanceof Gauge) { + Object obj = ((Gauge) dropwizardMetric).getValue(); + double value; + if (obj instanceof Number) { + value = ((Number) obj).doubleValue(); + getMetricGauge(CORE_INDEX_METRICS).labelValues(coreName, splitString[1]).set(value); + } + } break; } default: { 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.java index c9225e39910..34d2b7b34da 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 @@ -181,7 +181,6 @@ public static void toPrometheusRegistry( Map dropwizardMetrics = registry.getMetrics(); SolrPrometheusCoreMetrics solrPrometheusCoreMetrics = new SolrPrometheusCoreMetrics(new PrometheusRegistry()).registerDefaultMetrics(); -// Set category = new HashSet<>(); Map> categories = new HashMap<>(); toMaps( registry, @@ -210,7 +209,6 @@ public static void toPrometheusRegistry( if(!categories.get(splitString[0]).containsKey(metricName)) { categories.get(splitString[0]).put(metricName, dropwizardMetric); } -// categories.get(splitString[0]).add(metricName); solrPrometheusCoreMetrics.convertDropwizardMetric(metricName, coreName, dropwizardMetric); }); consumer.accept(solrPrometheusCoreMetrics.getPrometheusRegistry()); From adee5925d7d533ed24a908c904c454d8bdd695f8 Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Fri, 12 Apr 2024 10:26:47 -0400 Subject: [PATCH 09/25] Refactor handler conversion logic --- .../prometheus/SolrCoreHandlerMetric.java | 41 +++++ .../metrics/prometheus/SolrCoreMetric.java | 6 + .../prometheus/SolrPrometheusCoreMetrics.java | 167 ------------------ .../SolrPrometheusCoreRegistry.java | 142 +++++++++++++++ ...trics.java => SolrPrometheusRegistry.java} | 44 ++--- .../apache/solr/util/stats/MetricUtils.java | 28 ++- 6 files changed, 225 insertions(+), 203 deletions(-) create mode 100644 solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java create mode 100644 solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java delete mode 100644 solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java create mode 100644 solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java rename solr/core/src/java/org/apache/solr/metrics/prometheus/{SolrPrometheusMetrics.java => SolrPrometheusRegistry.java} (55%) diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java new file mode 100644 index 00000000000..06914739b1a --- /dev/null +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java @@ -0,0 +1,41 @@ +package org.apache.solr.metrics.prometheus; + +import com.codahale.metrics.Counter; +import com.codahale.metrics.Gauge; +import com.codahale.metrics.Meter; +import com.codahale.metrics.Metric; + +public class SolrCoreHandlerMetric implements SolrCoreMetric { +// public PrometheusRegistry solrPrometheusCoreRegistry; + public Metric dropwizardMetric; +// public String coreName; + public static final String CORE_REQUESTS_TOTAL = "solr_metrics_core_requests_total"; + public static final String CORE_REQUESTS_TOTAL_TIME = "solr_metrics_core_requests_total_time"; + public static final String CORE_HANDLER_HANDLER_START = "solr_metrics_core_handler_start"; + public static final String CORE_UPDATE_HANDLER = "solr_metrics_core_update_handler_metrics"; + public SolrCoreHandlerMetric(Metric dropwizardMetric) { + this.dropwizardMetric = dropwizardMetric; + } + + @Override + public void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry, String metricName) { + String coreName = solrPrometheusCoreRegistry.coreName; + String[] splitString = metricName.split("\\."); + if (dropwizardMetric instanceof Meter) { + solrPrometheusCoreRegistry.exportMeter((Meter) dropwizardMetric, CORE_REQUESTS_TOTAL, splitString[0], splitString[1], coreName, splitString[2]); + } else if (dropwizardMetric instanceof Counter) { + if (metricName.endsWith("requests")) { + solrPrometheusCoreRegistry.exportCounter((Counter) dropwizardMetric, CORE_REQUESTS_TOTAL, splitString[0], splitString[1], coreName, splitString[2]); + } else if (metricName.endsWith("totalTime")) { + solrPrometheusCoreRegistry.exportCounter((Counter) dropwizardMetric, CORE_REQUESTS_TOTAL_TIME, splitString[0], splitString[1], coreName, splitString[2]); + } + } else if (dropwizardMetric instanceof Gauge) { + if (metricName.endsWith("handlerStart")) { + solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_HANDLER_HANDLER_START, splitString[0], splitString[1], coreName, splitString[2]); + } else { + solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_UPDATE_HANDLER, splitString[0], splitString[1], coreName, splitString[2]); + } + } + } + +} diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java new file mode 100644 index 00000000000..407b51242e8 --- /dev/null +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java @@ -0,0 +1,6 @@ +package org.apache.solr.metrics.prometheus; + +@FunctionalInterface +public interface SolrCoreMetric { + void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry, String metricName); +} diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java deleted file mode 100644 index 02eb9daa5a1..00000000000 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreMetrics.java +++ /dev/null @@ -1,167 +0,0 @@ -package org.apache.solr.metrics.prometheus; - -import com.codahale.metrics.*; -import io.prometheus.metrics.model.registry.PrometheusRegistry; -import io.prometheus.metrics.model.snapshots.Quantiles; -import io.prometheus.metrics.model.snapshots.Unit; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -public class SolrPrometheusCoreMetrics extends SolrPrometheusMetrics { - public static final String CORE_REQUESTS_TOTAL = "solr_metrics_core_requests_total"; - public static final String CORE_REQUESTS_TOTAL_TIME = "solr_metrics_core_requests_total_time"; - public static final String CORE_REQUESTS_QUERY_MEAN_RATE = "solr_metrics_core_mean_rate"; - public static final String CORE_UPDATE_HANDLER = "solr_metrics_core_update_handler_metrics"; - public static final String CORE_HANDLER_HANDLER_START = "solr_metrics_core_handler_start"; - public static final String CORE_REQUEST_TIMES_HIST = "solr_metrics_request_times_histogram"; - public static final String CORE_REQUEST_TIMES_SUM = "solr_metrics_request_times_summary"; - public static final String CORE_CACHE_SEARCHER_METRICS = "solr_metrics_core_cache_gauge"; - public static final String CORE_TLOG_METRICS = "solr_metrics_tlog_replicas"; - public static final String CORE_SEARCHER_METRICS = "solr_metrics_core_searcher"; - public static final String CORE_HIGHLIGHER_METRICS = "solr_metrics_core_highlighter_requests"; - public static final String CORE_INDEX_METRICS = "solr_metrics_index"; - - public SolrPrometheusCoreMetrics(PrometheusRegistry prometheusRegistry) { - super(prometheusRegistry); - } - - @Override - public SolrPrometheusCoreMetrics registerDefaultMetrics() { - registerCounter(CORE_REQUESTS_TOTAL, "Solr requests Total", "category", "handler", "collection", "type"); - registerCounter(CORE_REQUESTS_TOTAL_TIME, "Solr requests Total", "category", "handler", "collection", "type"); - registerCounter(CORE_TLOG_METRICS, "Solr TLOG Metrics", "collection", "type", "item"); - registerCounter(CORE_HIGHLIGHER_METRICS, "Solr Highlighter Metrics", "collection", "type", "item"); - registerGauge(CORE_REQUESTS_QUERY_MEAN_RATE, "Solr requests Mean rate", "category", "handler", "collection"); - registerGauge(CORE_HANDLER_HANDLER_START, "Handler Start Time", "category", "handler", "collection", "type"); - registerGauge(CORE_UPDATE_HANDLER, "Handler Start Time", "category", "handler", "collection", "type"); - registerGauge(CORE_SEARCHER_METRICS, "SearcherMetrics", "collection", "searcherItem"); - registerGauge(CORE_CACHE_SEARCHER_METRICS, "Searcher Cache Metrics", "collection", "cacheType", "item"); - registerGauge(CORE_INDEX_METRICS, "Index Metrics", "collection", "type"); - registerHistogram(CORE_REQUEST_TIMES_HIST, "Solr Requests times", "category", "handler", "collection", "type"); - registerSummary(CORE_REQUEST_TIMES_SUM, "Solr Request Times Summary", "category", "handler", "collection", "type"); - return this; - } - - public void convertDropwizardMetric(String metricName, String coreName, Metric dropwizardMetric) { - System.out.println(dropwizardMetric.toString()); - String[] splitString = metricName.split("\\."); - Set notFound = new HashSet<>(); - switch (splitString[0]) { - case "ADMIN": - case "QUERY": - case "UPDATE": - case "REPLICATION": { - if (dropwizardMetric instanceof Meter) { - getMetricCounter(CORE_REQUESTS_TOTAL).labelValues(splitString[0], splitString[1], coreName, splitString[2]).inc(((Meter) dropwizardMetric).getCount()); - } else if (dropwizardMetric instanceof Counter) { - if (metricName.endsWith("requests")) { - getMetricCounter(CORE_REQUESTS_TOTAL).labelValues(splitString[0], splitString[1], coreName, splitString[2]).inc(((Counter) dropwizardMetric).getCount()); - } else if (metricName.endsWith("totalTime")) { - getMetricCounter(CORE_REQUESTS_TOTAL_TIME).labelValues(splitString[0], splitString[1], coreName, splitString[2]).inc(((Counter) dropwizardMetric).getCount()); - } - } else if (dropwizardMetric instanceof Gauge) { - Object obj = ((Gauge) dropwizardMetric).getValue(); - double value; - if (obj instanceof Number) { - value = ((Number) obj).doubleValue(); - } else { - System.out.println("FAILED"); - break; - } - if (metricName.endsWith("handlerStart")){ - getMetricGauge(CORE_HANDLER_HANDLER_START).labelValues(splitString[0], splitString[1], coreName, splitString[2]).set(value); - } else { - getMetricGauge(CORE_UPDATE_HANDLER).labelValues(splitString[0], splitString[1], coreName, splitString[2]).set(value); - } - } else { - notFound.add(metricName); - } - break; - } - case "CORE": { - System.out.println("Not possible to migrate string values to prometheus"); - break; - } - case "TLOG": { - if (dropwizardMetric instanceof Meter) { - getMetricCounter(CORE_TLOG_METRICS).labelValues(coreName, splitString[1], splitString[2]).inc(((Meter) dropwizardMetric).getCount()); - } else { - System.out.println("Not possible to migrate string values to prometheus"); - break; - } - break; - } - case "CACHE": { - if (dropwizardMetric instanceof Gauge) { - Object obj = ((Gauge) dropwizardMetric).getValue(); - if (obj instanceof Number) { - double value; - value = ((Number) obj).doubleValue(); - } else if (obj instanceof HashMap) { - HashMap itemsMap = (HashMap) obj; - for (Object item : itemsMap.keySet()) { - if (itemsMap.get(item) instanceof Number) { - getMetricGauge(CORE_CACHE_SEARCHER_METRICS).labelValues(coreName, splitString[2], (String) item).set( ((Number) itemsMap.get(item)).doubleValue()); - } else { - System.out.println("This is not an number"); - } - } - } else { - break; - } - } - break; - } - case "SEARCHER":{ - if (dropwizardMetric instanceof Gauge) { - Object obj = ((Gauge) dropwizardMetric).getValue(); - double value; - if (obj instanceof Number) { - value = ((Number) obj).doubleValue(); - getMetricGauge(CORE_SEARCHER_METRICS).labelValues(coreName, splitString[2]).set(value); - } else if (obj instanceof Boolean) { - value = ((Boolean) obj) ? 1 : 0; - } else if (obj instanceof HashMap) { - HashMap itemsMap = (HashMap) obj; - for (Object item : itemsMap.keySet()) { - if (itemsMap.get(item) instanceof Number) { - getMetricGauge(CORE_SEARCHER_METRICS).labelValues(coreName, splitString[2]).set( ((Number) itemsMap.get(item)).doubleValue()); - } else { - System.out.println("This is not an number"); - } - } - } else { - System.out.println("Other type"); - break; - } - } - break; - } - case "HIGHLIGHTER": { - if (dropwizardMetric instanceof Counter) { - getMetricCounter(CORE_HIGHLIGHER_METRICS).labelValues(coreName, splitString[1], splitString[2]).inc(((Counter) dropwizardMetric).getCount()); - } else { - System.out.println("Non existent type"); - } - break; - } - case "INDEX": { - if (dropwizardMetric instanceof Gauge) { - Object obj = ((Gauge) dropwizardMetric).getValue(); - double value; - if (obj instanceof Number) { - value = ((Number) obj).doubleValue(); - getMetricGauge(CORE_INDEX_METRICS).labelValues(coreName, splitString[1]).set(value); - } - } - break; - } - default: { - System.out.println(splitString[0]); - } - } - } -} diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java new file mode 100644 index 00000000000..a5b67dd50db --- /dev/null +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java @@ -0,0 +1,142 @@ +package org.apache.solr.metrics.prometheus; + +import com.codahale.metrics.*; +import io.prometheus.metrics.model.registry.PrometheusRegistry; + +import java.util.HashMap; + +import static org.apache.solr.metrics.prometheus.SolrCoreHandlerMetric.*; + +public class SolrPrometheusCoreRegistry extends SolrPrometheusRegistry { + public static final String CORE_REQUESTS_QUERY_MEAN_RATE = "solr_metrics_core_mean_rate"; + public static final String CORE_CACHE_SEARCHER_METRICS = "solr_metrics_core_cache_gauge"; + public static final String CORE_TLOG_METRICS = "solr_metrics_tlog_replicas"; + public static final String CORE_SEARCHER_METRICS = "solr_metrics_core_searcher"; + public static final String CORE_HIGHLIGHER_METRICS = "solr_metrics_core_highlighter_requests"; + public static final String CORE_INDEX_METRICS = "solr_metrics_index"; + public final String coreName; + + public SolrPrometheusCoreRegistry(PrometheusRegistry prometheusRegistry, String coreName) { + super(prometheusRegistry); + this.coreName = coreName; + } + + @Override + public SolrPrometheusCoreRegistry registerDefaultMetrics() { + createCounter(CORE_REQUESTS_TOTAL, "Solr requests Total", "category", "handler", "collection", "type"); + createCounter(CORE_REQUESTS_TOTAL_TIME, "Solr requests Total", "category", "handler", "collection", "type"); + createCounter(CORE_TLOG_METRICS, "Solr TLOG Metrics", "collection", "type", "item"); + createCounter(CORE_HIGHLIGHER_METRICS, "Solr Highlighter Metrics", "collection", "type", "item"); + createGauge(CORE_REQUESTS_QUERY_MEAN_RATE, "Solr requests Mean rate", "category", "handler", "collection"); + createGauge(CORE_HANDLER_HANDLER_START, "Handler Start Time", "category", "handler", "collection", "type"); + createGauge(CORE_UPDATE_HANDLER, "Handler Start Time", "category", "handler", "collection", "type"); + createGauge(CORE_SEARCHER_METRICS, "SearcherMetrics", "collection", "searcherItem"); + createGauge(CORE_CACHE_SEARCHER_METRICS, "Searcher Cache Metrics", "collection", "cacheType", "item"); + createGauge(CORE_INDEX_METRICS, "Index Metrics", "collection", "type"); + return this; + } + + public void convertDropwizardMetric(String metricName, Metric dropwizardMetric) { + String metricCategory = metricName.split("\\.")[0]; + String[] parsedMetric = metricName.split("\\."); + // categorize the metric from SolrCoreMetric to correct object + // Call toPrometheus function() + switch (metricCategory) { + case "ADMIN": + case "QUERY": + case "UPDATE": + case "REPLICATION": { + SolrCoreHandlerMetric solrCoreHandlerMetric = new SolrCoreHandlerMetric(dropwizardMetric); + solrCoreHandlerMetric.toPrometheus(this, metricName); + break; + } + case "CORE": { + System.out.println("Not possible to migrate string values to prometheus"); + break; + } + case "TLOG": { + if (dropwizardMetric instanceof Meter) { + getMetricCounter(CORE_TLOG_METRICS).labelValues(coreName, parsedMetric[1], parsedMetric[2]).inc(((Meter) dropwizardMetric).getCount()); + } else { + System.out.println("Not possible to migrate string values to prometheus"); + break; + } + break; + } + case "CACHE": { + if (dropwizardMetric instanceof Gauge) { + Object obj = ((Gauge) dropwizardMetric).getValue(); + if (obj instanceof Number) { + double value; + value = ((Number) obj).doubleValue(); + } else if (obj instanceof HashMap) { + HashMap itemsMap = (HashMap) obj; + for (Object item : itemsMap.keySet()) { + if (itemsMap.get(item) instanceof Number) { + getMetricGauge(CORE_CACHE_SEARCHER_METRICS).labelValues(coreName, parsedMetric[2], (String) item).set( ((Number) itemsMap.get(item)).doubleValue()); + } else { + System.out.println("This is not an number"); + } + } + } else { + break; + } + } + break; + } + case "SEARCHER":{ + if (dropwizardMetric instanceof Gauge) { + Object obj = ((Gauge) dropwizardMetric).getValue(); + double value; + if (obj instanceof Number) { + value = ((Number) obj).doubleValue(); + getMetricGauge(CORE_SEARCHER_METRICS).labelValues(coreName, parsedMetric[2]).set(value); + } else if (obj instanceof Boolean) { + value = ((Boolean) obj) ? 1 : 0; + } else if (obj instanceof HashMap) { + HashMap itemsMap = (HashMap) obj; + for (Object item : itemsMap.keySet()) { + if (itemsMap.get(item) instanceof Number) { + getMetricGauge(CORE_SEARCHER_METRICS).labelValues(coreName, parsedMetric[2]).set( ((Number) itemsMap.get(item)).doubleValue()); + } else { + System.out.println("This is not an number"); + } + } + } else { + System.out.println("Other type"); + break; + } + } + break; + } + case "HIGHLIGHTER": { + if (dropwizardMetric instanceof Counter) { + getMetricCounter(CORE_HIGHLIGHER_METRICS).labelValues(coreName, parsedMetric[1], parsedMetric[2]).inc(((Counter) dropwizardMetric).getCount()); + } else { + System.out.println("Non existent type"); + } + break; + } + case "INDEX": { + if (dropwizardMetric instanceof Gauge) { + Object obj = ((Gauge) dropwizardMetric).getValue(); + double value; + if (obj instanceof Number) { + value = ((Number) obj).doubleValue(); + getMetricGauge(CORE_INDEX_METRICS).labelValues(coreName, parsedMetric[1]).set(value); + } + } + break; + } + default: { + System.out.println(parsedMetric[0]); + } + } + } + + + private void convertHandlerMetrics(Metric dropwizardMetric, String metricName) { + + } + +} diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusMetrics.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java similarity index 55% rename from solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusMetrics.java rename to solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java index 1b6857be631..ffa1de1b016 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusMetrics.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java @@ -1,16 +1,19 @@ package org.apache.solr.metrics.prometheus; +import com.codahale.metrics.Meter; +import com.codahale.metrics.Metric; import io.prometheus.metrics.core.metrics.Counter; import io.prometheus.metrics.core.metrics.Gauge; import io.prometheus.metrics.core.metrics.Histogram; import io.prometheus.metrics.core.metrics.Summary; import io.prometheus.metrics.model.registry.PrometheusRegistry; +import io.prometheus.metrics.model.snapshots.CounterSnapshot; import io.prometheus.metrics.model.snapshots.Unit; import java.util.HashMap; import java.util.Map; -public abstract class SolrPrometheusMetrics { +public abstract class SolrPrometheusRegistry { PrometheusRegistry prometheusRegistry; String registryName; private final Map metricCounters; @@ -18,7 +21,7 @@ public abstract class SolrPrometheusMetrics { private final Map metricHistograms; private final Map metricSummaries; - public SolrPrometheusMetrics(PrometheusRegistry prometheusRegistry) { + public SolrPrometheusRegistry(PrometheusRegistry prometheusRegistry) { this.prometheusRegistry = prometheusRegistry; this.metricCounters = new HashMap<>(); this.metricGauges = new HashMap<>(); @@ -45,39 +48,40 @@ public Gauge getMetricGauge(String metricName) { public Summary getMetricSummary(String metricName) { return metricSummaries.get(metricName); } - abstract SolrPrometheusMetrics registerDefaultMetrics(); + abstract SolrPrometheusRegistry registerDefaultMetrics(); - protected void registerCounter(String metricName, String help, String ...labelNames) { - Counter metricCounter = io.prometheus.metrics.core.metrics.Counter.builder() + protected Counter createCounter(String metricName, String help, String ...labelNames) { + Counter counter = io.prometheus.metrics.core.metrics.Counter.builder() .name(metricName) .help(help) .labelNames(labelNames) .register(prometheusRegistry); - metricCounters.put(metricName, metricCounter); + metricCounters.put(metricName, counter); + return counter; } - protected void registerGauge(String metricName, String help, String ...labelNames) { - Gauge metricGauge = io.prometheus.metrics.core.metrics.Gauge.builder() + protected Gauge createGauge(String metricName, String help, String ...labelNames) { + Gauge gauge = io.prometheus.metrics.core.metrics.Gauge.builder() .name(metricName) .help(help) .labelNames(labelNames) .register(prometheusRegistry); - metricGauges.put(metricName, metricGauge); + metricGauges.put(metricName, gauge); + return gauge; } - protected void registerHistogram(String metricName, String help, String ...labelNames) { - Histogram metricHistogram = Histogram.builder() - .name(metricName) - .help(help) - .labelNames(labelNames) - .unit(Unit.SECONDS) - .register(prometheusRegistry); - metricHistograms.put(metricName, metricHistogram); + protected void exportMeter(Meter dropwizardMetric, String prometheusMetricName, String ...labels) { + getMetricCounter(prometheusMetricName).labelValues(labels).inc(dropwizardMetric.getCount()); } - protected void registerSummary(String metricName, String help, String ...labelNames) { - Summary metricSummary = Summary.builder().name(metricName).help(help).labelNames(labelNames).unit(Unit.SECONDS).register(prometheusRegistry); - metricSummaries.put(metricName, metricSummary); + protected void exportCounter(com.codahale.metrics.Counter prometheusMetricName, String metricName, String ...labels) { + getMetricCounter(metricName).labelValues(labels).inc(prometheusMetricName.getCount()); + } + + protected void exportGauge(com.codahale.metrics.Gauge dropwizardMetric, String prometheusMetricName, String ...labels){ + if (dropwizardMetric instanceof Number) { + getMetricGauge(prometheusMetricName).labelValues(labels).set(((Number) dropwizardMetric).doubleValue()); + } } } 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.java index 34d2b7b34da..ce72c3df9b1 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 @@ -43,7 +43,6 @@ import java.util.function.Predicate; import io.prometheus.metrics.model.registry.PrometheusRegistry; -import io.prometheus.metrics.model.snapshots.Unit; import org.apache.solr.common.ConditionalKeyMapWriter; import org.apache.solr.common.IteratorWriter; import org.apache.solr.common.MapWriter; @@ -52,13 +51,10 @@ import org.apache.solr.core.SolrInfoBean; import org.apache.solr.metrics.AggregateMetric; import org.apache.solr.metrics.SolrMetricManager; -import org.apache.solr.metrics.prometheus.SolrPrometheusCoreMetrics; +import org.apache.solr.metrics.prometheus.SolrPrometheusCoreRegistry; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.apache.solr.metrics.prometheus.SolrPrometheusCoreMetrics.CORE_REQUESTS_QUERY_MEAN_RATE; -import static org.apache.solr.metrics.prometheus.SolrPrometheusCoreMetrics.CORE_REQUESTS_TOTAL; - /** Metrics specific utility functions. */ public class MetricUtils { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -179,7 +175,16 @@ public static void toPrometheusRegistry( boolean compact, Consumer consumer) { Map dropwizardMetrics = registry.getMetrics(); - SolrPrometheusCoreMetrics solrPrometheusCoreMetrics = new SolrPrometheusCoreMetrics(new PrometheusRegistry()).registerDefaultMetrics(); + String[] splitRegistryName = registryName.split("\\."); + String coreName; + if (splitRegistryName.length == 3) { + coreName = splitRegistryName[2]; + } else if (splitRegistryName.length == 5) { + coreName = "NoCoreNameFound"; + } else { + coreName = "NoCoreNameFound"; + } + SolrPrometheusCoreRegistry solrPrometheusCoreMetrics = new SolrPrometheusCoreRegistry(new PrometheusRegistry(), coreName).registerDefaultMetrics(); Map> categories = new HashMap<>(); toMaps( @@ -192,15 +197,6 @@ public static void toPrometheusRegistry( compact, false, (metricName, metric) -> { - String[] splitRegistryName = registryName.split("\\."); - String coreName; - if (splitRegistryName.length == 3) { - coreName = splitRegistryName[2]; - } else if (splitRegistryName.length == 5) { - coreName = "NoCoreNameFound"; - } else { - coreName = "NoCoreNameFound"; - } Metric dropwizardMetric = dropwizardMetrics.get(metricName); String[] splitString = metricName.split("\\."); if(!categories.containsKey(splitString[0])) { @@ -209,7 +205,7 @@ public static void toPrometheusRegistry( if(!categories.get(splitString[0]).containsKey(metricName)) { categories.get(splitString[0]).put(metricName, dropwizardMetric); } - solrPrometheusCoreMetrics.convertDropwizardMetric(metricName, coreName, dropwizardMetric); + solrPrometheusCoreMetrics.convertDropwizardMetric(metricName, dropwizardMetric); }); consumer.accept(solrPrometheusCoreMetrics.getPrometheusRegistry()); } From a88af56a5b2ce8402e251ce0b6fdf1cacccc8aa4 Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Fri, 12 Apr 2024 14:32:20 -0400 Subject: [PATCH 10/25] Create the SolrCoreMetric abstract class --- .../prometheus/SolrCoreCacheMetric.java | 40 ++++++ .../prometheus/SolrCoreHandlerMetric.java | 5 +- .../prometheus/SolrCoreHighlighterMetric.java | 21 +++ .../prometheus/SolrCoreIndexMetric.java | 21 +++ .../metrics/prometheus/SolrCoreMetric.java | 8 +- .../prometheus/SolrCoreNoOpMetric.java | 14 ++ .../prometheus/SolrCoreSearcherMetric.java | 21 +++ .../prometheus/SolrCoreTlogMetric.java | 23 +++ .../SolrPrometheusCoreRegistry.java | 134 ++++++------------ .../prometheus/SolrPrometheusRegistry.java | 14 +- .../apache/solr/util/stats/MetricUtils.java | 2 +- 11 files changed, 203 insertions(+), 100 deletions(-) create mode 100644 solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java create mode 100644 solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java create mode 100644 solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java create mode 100644 solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java create mode 100644 solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java create mode 100644 solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java new file mode 100644 index 00000000000..f3de1904e04 --- /dev/null +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java @@ -0,0 +1,40 @@ +package org.apache.solr.metrics.prometheus; + +import com.codahale.metrics.Gauge; +import com.codahale.metrics.Metric; + +import java.util.HashMap; + +public class SolrCoreCacheMetric extends SolrCoreMetric { + public static final String CORE_CACHE_SEARCHER_METRICS = "solr_metrics_core_cache_gauge"; + + public SolrCoreCacheMetric(Metric dropwizardMetric) { + this.dropwizardMetric = dropwizardMetric; + } + @Override + void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry, String metricName) { + String coreName = solrPrometheusCoreRegistry.coreName; + String[] splitString = metricName.split("\\."); + solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_CACHE_SEARCHER_METRICS, coreName, splitString[2]); +// if (dropwizardMetric instanceof Gauge) { +// Object obj = ((Gauge) dropwizardMetric).getValue(); +// if (obj instanceof Number) { +// double value; +// value = ((Number) obj).doubleValue(); +// } else if (obj instanceof HashMap) { +// HashMap itemsMap = (HashMap) obj; +// for (Object item : itemsMap.keySet()) { +// if (itemsMap.get(item) instanceof Number) { +//// getMetricGauge(CORE_CACHE_SEARCHER_METRICS).labelValues(coreName, parsedMetric[2], (String) item).set( ((Number) itemsMap.get(item)).doubleValue()); +// getMetricGauge(CORE_CACHE_SEARCHER_METRICS).labelValues(coreName, parsedMetric[2], (String) item).set( ((Number) itemsMap.get(item)).doubleValue()); +// } else { +// System.out.println("This is not an number"); +// } +// } +// } else { +// break; +// } +// } + + } +} diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java index 06914739b1a..2238f97e170 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java @@ -5,10 +5,7 @@ import com.codahale.metrics.Meter; import com.codahale.metrics.Metric; -public class SolrCoreHandlerMetric implements SolrCoreMetric { -// public PrometheusRegistry solrPrometheusCoreRegistry; - public Metric dropwizardMetric; -// public String coreName; +public class SolrCoreHandlerMetric extends SolrCoreMetric { public static final String CORE_REQUESTS_TOTAL = "solr_metrics_core_requests_total"; public static final String CORE_REQUESTS_TOTAL_TIME = "solr_metrics_core_requests_total_time"; public static final String CORE_HANDLER_HANDLER_START = "solr_metrics_core_handler_start"; diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java new file mode 100644 index 00000000000..f5406218b10 --- /dev/null +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java @@ -0,0 +1,21 @@ +package org.apache.solr.metrics.prometheus; + +import com.codahale.metrics.Counter; +import com.codahale.metrics.Metric; + +public class SolrCoreHighlighterMetric extends SolrCoreMetric { + public static final String CORE_HIGHLIGHER_METRICS = "solr_metrics_core_highlighter_requests"; + + public SolrCoreHighlighterMetric(Metric dropwizardMetric) { + this.dropwizardMetric = dropwizardMetric; + } + + @Override + void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry, String metricName) { + String coreName = solrPrometheusCoreRegistry.coreName; + String[] splitString = metricName.split("\\."); + if (dropwizardMetric instanceof Counter) { + solrPrometheusCoreRegistry.exportCounter((Counter) dropwizardMetric, CORE_HIGHLIGHER_METRICS, coreName, splitString[1], splitString[2]); + } + } +} diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java new file mode 100644 index 00000000000..8de30748b7d --- /dev/null +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java @@ -0,0 +1,21 @@ +package org.apache.solr.metrics.prometheus; + +import com.codahale.metrics.Gauge; +import com.codahale.metrics.Metric; + +public class SolrCoreIndexMetric extends SolrCoreMetric { + public static final String CORE_INDEX_METRICS = "solr_metrics_index"; + + public SolrCoreIndexMetric(Metric dropwizardMetric) { + this.dropwizardMetric = dropwizardMetric; + } + + @Override + void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry, String metricName) { + String coreName = solrPrometheusCoreRegistry.coreName; + String[] splitString = metricName.split("\\."); + if (dropwizardMetric instanceof Gauge) { + solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_INDEX_METRICS, coreName, splitString[1]); + } + } +} diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java index 407b51242e8..5b26d17f0ae 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java @@ -1,6 +1,8 @@ package org.apache.solr.metrics.prometheus; -@FunctionalInterface -public interface SolrCoreMetric { - void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry, String metricName); +import com.codahale.metrics.Metric; + +public abstract class SolrCoreMetric { + public Metric dropwizardMetric; + abstract void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry, String metricName); } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java new file mode 100644 index 00000000000..6ee5cb5e1d6 --- /dev/null +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java @@ -0,0 +1,14 @@ +package org.apache.solr.metrics.prometheus; + +import com.codahale.metrics.Metric; + +public class SolrCoreNoOpMetric extends SolrCoreMetric { + + public SolrCoreNoOpMetric(Metric dropwizardMetric) { + this.dropwizardMetric = dropwizardMetric; + } + @Override + void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry, String metricName) { + System.out.println("Cannot export string metrics"); + } +} diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java new file mode 100644 index 00000000000..018909a283e --- /dev/null +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java @@ -0,0 +1,21 @@ +package org.apache.solr.metrics.prometheus; + +import com.codahale.metrics.Gauge; +import com.codahale.metrics.Metric; + +public class SolrCoreSearcherMetric extends SolrCoreMetric { + public static final String CORE_SEARCHER_METRICS = "solr_metrics_core_searcher"; + + public SolrCoreSearcherMetric(Metric dropwizardMetric) { + this.dropwizardMetric = dropwizardMetric; + } + + @Override + void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry, String metricName) { + String coreName = solrPrometheusCoreRegistry.coreName; + String[] splitString = metricName.split("\\."); + if (dropwizardMetric instanceof Gauge) { + solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_SEARCHER_METRICS, coreName, splitString[2]); + } + } +} diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java new file mode 100644 index 00000000000..7b72832a2ea --- /dev/null +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java @@ -0,0 +1,23 @@ +package org.apache.solr.metrics.prometheus; + +import com.codahale.metrics.Meter; +import com.codahale.metrics.Metric; + +public class SolrCoreTlogMetric extends SolrCoreMetric { + public static final String CORE_TLOG_METRICS = "solr_metrics_tlog_replicas"; + + public SolrCoreTlogMetric(Metric dropwizardMetric) { + this.dropwizardMetric = dropwizardMetric; + } + + @Override + public void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry, String metricName) { + String coreName = solrPrometheusCoreRegistry.coreName; + String[] splitString = metricName.split("\\."); + if (dropwizardMetric instanceof Meter) { + solrPrometheusCoreRegistry.exportMeter((Meter) dropwizardMetric, CORE_TLOG_METRICS, coreName, splitString[1], splitString[2]); + } else { + System.out.println("Not possible to migrate string values to prometheus"); + } + } +} diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java index a5b67dd50db..9d039249571 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java @@ -3,17 +3,14 @@ import com.codahale.metrics.*; import io.prometheus.metrics.model.registry.PrometheusRegistry; -import java.util.HashMap; - +import static org.apache.solr.metrics.prometheus.SolrCoreCacheMetric.CORE_CACHE_SEARCHER_METRICS; import static org.apache.solr.metrics.prometheus.SolrCoreHandlerMetric.*; +import static org.apache.solr.metrics.prometheus.SolrCoreHighlighterMetric.CORE_HIGHLIGHER_METRICS; +import static org.apache.solr.metrics.prometheus.SolrCoreIndexMetric.CORE_INDEX_METRICS; +import static org.apache.solr.metrics.prometheus.SolrCoreSearcherMetric.CORE_SEARCHER_METRICS; +import static org.apache.solr.metrics.prometheus.SolrCoreTlogMetric.CORE_TLOG_METRICS; public class SolrPrometheusCoreRegistry extends SolrPrometheusRegistry { - public static final String CORE_REQUESTS_QUERY_MEAN_RATE = "solr_metrics_core_mean_rate"; - public static final String CORE_CACHE_SEARCHER_METRICS = "solr_metrics_core_cache_gauge"; - public static final String CORE_TLOG_METRICS = "solr_metrics_tlog_replicas"; - public static final String CORE_SEARCHER_METRICS = "solr_metrics_core_searcher"; - public static final String CORE_HIGHLIGHER_METRICS = "solr_metrics_core_highlighter_requests"; - public static final String CORE_INDEX_METRICS = "solr_metrics_index"; public final String coreName; public SolrPrometheusCoreRegistry(PrometheusRegistry prometheusRegistry, String coreName) { @@ -27,116 +24,73 @@ public SolrPrometheusCoreRegistry registerDefaultMetrics() { createCounter(CORE_REQUESTS_TOTAL_TIME, "Solr requests Total", "category", "handler", "collection", "type"); createCounter(CORE_TLOG_METRICS, "Solr TLOG Metrics", "collection", "type", "item"); createCounter(CORE_HIGHLIGHER_METRICS, "Solr Highlighter Metrics", "collection", "type", "item"); - createGauge(CORE_REQUESTS_QUERY_MEAN_RATE, "Solr requests Mean rate", "category", "handler", "collection"); createGauge(CORE_HANDLER_HANDLER_START, "Handler Start Time", "category", "handler", "collection", "type"); createGauge(CORE_UPDATE_HANDLER, "Handler Start Time", "category", "handler", "collection", "type"); createGauge(CORE_SEARCHER_METRICS, "SearcherMetrics", "collection", "searcherItem"); - createGauge(CORE_CACHE_SEARCHER_METRICS, "Searcher Cache Metrics", "collection", "cacheType", "item"); +// createGauge(CORE_CACHE_SEARCHER_METRICS, "Searcher Cache Metrics", "collection", "cacheType", "item"); + createGauge(CORE_CACHE_SEARCHER_METRICS, "Searcher Cache Metrics", "collection", "cacheType"); createGauge(CORE_INDEX_METRICS, "Index Metrics", "collection", "type"); return this; } - public void convertDropwizardMetric(String metricName, Metric dropwizardMetric) { + public void exportDropwizardMetric(String metricName, Metric dropwizardMetric) { String metricCategory = metricName.split("\\.")[0]; - String[] parsedMetric = metricName.split("\\."); - // categorize the metric from SolrCoreMetric to correct object - // Call toPrometheus function() + SolrCoreMetric solrCoreMetric = categorizeCorePrefix(dropwizardMetric, metricCategory); + solrCoreMetric.toPrometheus(this, metricName); + } + + private SolrCoreMetric categorizeCorePrefix(Metric dropwizardMetric, String metricCategory) { switch (metricCategory) { case "ADMIN": case "QUERY": case "UPDATE": case "REPLICATION": { - SolrCoreHandlerMetric solrCoreHandlerMetric = new SolrCoreHandlerMetric(dropwizardMetric); - solrCoreHandlerMetric.toPrometheus(this, metricName); - break; - } - case "CORE": { - System.out.println("Not possible to migrate string values to prometheus"); - break; + return new SolrCoreHandlerMetric(dropwizardMetric); } case "TLOG": { - if (dropwizardMetric instanceof Meter) { - getMetricCounter(CORE_TLOG_METRICS).labelValues(coreName, parsedMetric[1], parsedMetric[2]).inc(((Meter) dropwizardMetric).getCount()); - } else { - System.out.println("Not possible to migrate string values to prometheus"); - break; - } - break; + return new SolrCoreTlogMetric(dropwizardMetric); } case "CACHE": { - if (dropwizardMetric instanceof Gauge) { - Object obj = ((Gauge) dropwizardMetric).getValue(); - if (obj instanceof Number) { - double value; - value = ((Number) obj).doubleValue(); - } else if (obj instanceof HashMap) { - HashMap itemsMap = (HashMap) obj; - for (Object item : itemsMap.keySet()) { - if (itemsMap.get(item) instanceof Number) { - getMetricGauge(CORE_CACHE_SEARCHER_METRICS).labelValues(coreName, parsedMetric[2], (String) item).set( ((Number) itemsMap.get(item)).doubleValue()); - } else { - System.out.println("This is not an number"); - } - } - } else { - break; - } - } - break; + return new SolrCoreCacheMetric(dropwizardMetric); } case "SEARCHER":{ - if (dropwizardMetric instanceof Gauge) { - Object obj = ((Gauge) dropwizardMetric).getValue(); - double value; - if (obj instanceof Number) { - value = ((Number) obj).doubleValue(); - getMetricGauge(CORE_SEARCHER_METRICS).labelValues(coreName, parsedMetric[2]).set(value); - } else if (obj instanceof Boolean) { - value = ((Boolean) obj) ? 1 : 0; - } else if (obj instanceof HashMap) { - HashMap itemsMap = (HashMap) obj; - for (Object item : itemsMap.keySet()) { - if (itemsMap.get(item) instanceof Number) { - getMetricGauge(CORE_SEARCHER_METRICS).labelValues(coreName, parsedMetric[2]).set( ((Number) itemsMap.get(item)).doubleValue()); - } else { - System.out.println("This is not an number"); - } - } - } else { - System.out.println("Other type"); - break; - } - } - break; + return new SolrCoreSearcherMetric(dropwizardMetric); } case "HIGHLIGHTER": { - if (dropwizardMetric instanceof Counter) { - getMetricCounter(CORE_HIGHLIGHER_METRICS).labelValues(coreName, parsedMetric[1], parsedMetric[2]).inc(((Counter) dropwizardMetric).getCount()); - } else { - System.out.println("Non existent type"); - } - break; + return new SolrCoreHighlighterMetric(dropwizardMetric); } case "INDEX": { - if (dropwizardMetric instanceof Gauge) { - Object obj = ((Gauge) dropwizardMetric).getValue(); - double value; - if (obj instanceof Number) { - value = ((Number) obj).doubleValue(); - getMetricGauge(CORE_INDEX_METRICS).labelValues(coreName, parsedMetric[1]).set(value); - } - } - break; + return new SolrCoreIndexMetric(dropwizardMetric); } + case "CORE": default: { - System.out.println(parsedMetric[0]); + return new SolrCoreNoOpMetric(dropwizardMetric); } } } +} - private void convertHandlerMetrics(Metric dropwizardMetric, String metricName) { - - } -} +// if (dropwizardMetric instanceof Gauge) { +// Object obj = ((Gauge) dropwizardMetric).getValue(); +// double value; +// if (obj instanceof Number) { +// value = ((Number) obj).doubleValue(); +// getMetricGauge(CORE_SEARCHER_METRICS).labelValues(coreName, parsedMetric[2]).set(value); +// } else if (obj instanceof Boolean) { +// value = ((Boolean) obj) ? 1 : 0; +// } else if (obj instanceof HashMap) { +// HashMap itemsMap = (HashMap) obj; +// for (Object item : itemsMap.keySet()) { +// if (itemsMap.get(item) instanceof Number) { +// getMetricGauge(CORE_SEARCHER_METRICS).labelValues(coreName, parsedMetric[2]).set( ((Number) itemsMap.get(item)).doubleValue()); +// } else { +// System.out.println("This is not an number"); +// } +// } +// } else { +// System.out.println("Other type"); +// break; +// } +// } \ No newline at end of file diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java index ffa1de1b016..5abf3ef1315 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java @@ -74,13 +74,23 @@ protected void exportMeter(Meter dropwizardMetric, String prometheusMetricName, getMetricCounter(prometheusMetricName).labelValues(labels).inc(dropwizardMetric.getCount()); } - protected void exportCounter(com.codahale.metrics.Counter prometheusMetricName, String metricName, String ...labels) { - getMetricCounter(metricName).labelValues(labels).inc(prometheusMetricName.getCount()); + protected void exportCounter(com.codahale.metrics.Counter dropwizardMetric, String prometheusMetricName, String ...labels) { + getMetricCounter(prometheusMetricName).labelValues(labels).inc(dropwizardMetric.getCount()); } + protected void exportGauge(com.codahale.metrics.Gauge dropwizardMetric, String prometheusMetricName, String ...labels){ if (dropwizardMetric instanceof Number) { getMetricGauge(prometheusMetricName).labelValues(labels).set(((Number) dropwizardMetric).doubleValue()); + } else if (dropwizardMetric instanceof HashMap) { + HashMap itemsMap = (HashMap) dropwizardMetric; + for (Object item : itemsMap.keySet()) { + if (itemsMap.get(item) instanceof Number) { + getMetricGauge(prometheusMetricName).labelValues(labels).set( ((Number) itemsMap.get(item)).doubleValue()); + } else { + System.out.println("This is not an number"); + } + } } } 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.java index ce72c3df9b1..c78fe1007c3 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 @@ -205,7 +205,7 @@ public static void toPrometheusRegistry( if(!categories.get(splitString[0]).containsKey(metricName)) { categories.get(splitString[0]).put(metricName, dropwizardMetric); } - solrPrometheusCoreMetrics.convertDropwizardMetric(metricName, dropwizardMetric); + solrPrometheusCoreMetrics.exportDropwizardMetric(metricName, dropwizardMetric); }); consumer.accept(solrPrometheusCoreMetrics.getPrometheusRegistry()); } From ddfad4a889ffddac3b42a776585a7940620ec92d Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Fri, 12 Apr 2024 15:16:51 -0400 Subject: [PATCH 11/25] Fix broken Gauges not registering metrics --- .../prometheus/SolrCoreCacheMetric.java | 4 ++- .../prometheus/SolrCoreSearcherMetric.java | 9 +++++- .../SolrPrometheusCoreRegistry.java | 30 ++----------------- .../prometheus/SolrPrometheusRegistry.java | 11 +++---- 4 files changed, 20 insertions(+), 34 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java index f3de1904e04..c00bfe5bcd6 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java @@ -15,7 +15,9 @@ public SolrCoreCacheMetric(Metric dropwizardMetric) { void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry, String metricName) { String coreName = solrPrometheusCoreRegistry.coreName; String[] splitString = metricName.split("\\."); - solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_CACHE_SEARCHER_METRICS, coreName, splitString[2]); + if (dropwizardMetric instanceof Gauge) { + solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_CACHE_SEARCHER_METRICS, coreName, splitString[2]); + } // if (dropwizardMetric instanceof Gauge) { // Object obj = ((Gauge) dropwizardMetric).getValue(); // if (obj instanceof Number) { diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java index 018909a283e..d2ae01463ce 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java @@ -3,8 +3,11 @@ import com.codahale.metrics.Gauge; import com.codahale.metrics.Metric; +import static org.apache.solr.metrics.prometheus.SolrCoreCacheMetric.CORE_CACHE_SEARCHER_METRICS; + public class SolrCoreSearcherMetric extends SolrCoreMetric { public static final String CORE_SEARCHER_METRICS = "solr_metrics_core_searcher"; + public static final String CORE_SEARCHER_CACHE_METRICS = "solr_metrics_core_searcher_cache"; public SolrCoreSearcherMetric(Metric dropwizardMetric) { this.dropwizardMetric = dropwizardMetric; @@ -15,7 +18,11 @@ void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry, String String coreName = solrPrometheusCoreRegistry.coreName; String[] splitString = metricName.split("\\."); if (dropwizardMetric instanceof Gauge) { - solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_SEARCHER_METRICS, coreName, splitString[2]); + if (metricName.endsWith("liveDocsCache")) { + solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_CACHE_SEARCHER_METRICS, coreName, splitString[2]); + } else { + solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_SEARCHER_METRICS, coreName, splitString[2]); + } } } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java index 9d039249571..deeeb3c5ec6 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java @@ -7,6 +7,7 @@ import static org.apache.solr.metrics.prometheus.SolrCoreHandlerMetric.*; import static org.apache.solr.metrics.prometheus.SolrCoreHighlighterMetric.CORE_HIGHLIGHER_METRICS; import static org.apache.solr.metrics.prometheus.SolrCoreIndexMetric.CORE_INDEX_METRICS; +import static org.apache.solr.metrics.prometheus.SolrCoreSearcherMetric.CORE_SEARCHER_CACHE_METRICS; import static org.apache.solr.metrics.prometheus.SolrCoreSearcherMetric.CORE_SEARCHER_METRICS; import static org.apache.solr.metrics.prometheus.SolrCoreTlogMetric.CORE_TLOG_METRICS; @@ -27,8 +28,7 @@ public SolrPrometheusCoreRegistry registerDefaultMetrics() { createGauge(CORE_HANDLER_HANDLER_START, "Handler Start Time", "category", "handler", "collection", "type"); createGauge(CORE_UPDATE_HANDLER, "Handler Start Time", "category", "handler", "collection", "type"); createGauge(CORE_SEARCHER_METRICS, "SearcherMetrics", "collection", "searcherItem"); -// createGauge(CORE_CACHE_SEARCHER_METRICS, "Searcher Cache Metrics", "collection", "cacheType", "item"); - createGauge(CORE_CACHE_SEARCHER_METRICS, "Searcher Cache Metrics", "collection", "cacheType"); + createGauge(CORE_CACHE_SEARCHER_METRICS, "Searcher Cache Metrics", "collection", "cacheType", "item"); createGauge(CORE_INDEX_METRICS, "Index Metrics", "collection", "type"); return this; } @@ -69,28 +69,4 @@ private SolrCoreMetric categorizeCorePrefix(Metric dropwizardMetric, String metr } } -} - - -// if (dropwizardMetric instanceof Gauge) { -// Object obj = ((Gauge) dropwizardMetric).getValue(); -// double value; -// if (obj instanceof Number) { -// value = ((Number) obj).doubleValue(); -// getMetricGauge(CORE_SEARCHER_METRICS).labelValues(coreName, parsedMetric[2]).set(value); -// } else if (obj instanceof Boolean) { -// value = ((Boolean) obj) ? 1 : 0; -// } else if (obj instanceof HashMap) { -// HashMap itemsMap = (HashMap) obj; -// for (Object item : itemsMap.keySet()) { -// if (itemsMap.get(item) instanceof Number) { -// getMetricGauge(CORE_SEARCHER_METRICS).labelValues(coreName, parsedMetric[2]).set( ((Number) itemsMap.get(item)).doubleValue()); -// } else { -// System.out.println("This is not an number"); -// } -// } -// } else { -// System.out.println("Other type"); -// break; -// } -// } \ No newline at end of file +} \ No newline at end of file diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java index 5abf3ef1315..86f8368e9b3 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java @@ -44,9 +44,6 @@ public Counter getMetricCounter(String metricName) { public Gauge getMetricGauge(String metricName) { return metricGauges.get(metricName); } - public Histogram getMetricHistogram(String metricName) { return metricHistograms.get(metricName); } - - public Summary getMetricSummary(String metricName) { return metricSummaries.get(metricName); } abstract SolrPrometheusRegistry registerDefaultMetrics(); @@ -79,14 +76,18 @@ protected void exportCounter(com.codahale.metrics.Counter dropwizardMetric, Stri } - protected void exportGauge(com.codahale.metrics.Gauge dropwizardMetric, String prometheusMetricName, String ...labels){ + protected void exportGauge(com.codahale.metrics.Gauge dropwizardMetricRaw, String prometheusMetricName, String ...labels) { + Object dropwizardMetric = (dropwizardMetricRaw).getValue(); if (dropwizardMetric instanceof Number) { getMetricGauge(prometheusMetricName).labelValues(labels).set(((Number) dropwizardMetric).doubleValue()); } else if (dropwizardMetric instanceof HashMap) { HashMap itemsMap = (HashMap) dropwizardMetric; for (Object item : itemsMap.keySet()) { if (itemsMap.get(item) instanceof Number) { - getMetricGauge(prometheusMetricName).labelValues(labels).set( ((Number) itemsMap.get(item)).doubleValue()); + String[] newLabels = new String[labels.length + 1]; + System.arraycopy(labels, 0, newLabels, 0, labels.length); + newLabels[labels.length] = (String) item; + getMetricGauge(prometheusMetricName).labelValues(newLabels).set(((Number) itemsMap.get(item)).doubleValue()); } else { System.out.println("This is not an number"); } From c4cc0862f2ae70f493be8e5be00106da9157514b Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Fri, 12 Apr 2024 15:31:15 -0400 Subject: [PATCH 12/25] Remove comments --- .../prometheus/SolrCoreCacheMetric.java | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java index c00bfe5bcd6..dbd64c05897 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java @@ -18,25 +18,5 @@ void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry, String if (dropwizardMetric instanceof Gauge) { solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_CACHE_SEARCHER_METRICS, coreName, splitString[2]); } -// if (dropwizardMetric instanceof Gauge) { -// Object obj = ((Gauge) dropwizardMetric).getValue(); -// if (obj instanceof Number) { -// double value; -// value = ((Number) obj).doubleValue(); -// } else if (obj instanceof HashMap) { -// HashMap itemsMap = (HashMap) obj; -// for (Object item : itemsMap.keySet()) { -// if (itemsMap.get(item) instanceof Number) { -//// getMetricGauge(CORE_CACHE_SEARCHER_METRICS).labelValues(coreName, parsedMetric[2], (String) item).set( ((Number) itemsMap.get(item)).doubleValue()); -// getMetricGauge(CORE_CACHE_SEARCHER_METRICS).labelValues(coreName, parsedMetric[2], (String) item).set( ((Number) itemsMap.get(item)).doubleValue()); -// } else { -// System.out.println("This is not an number"); -// } -// } -// } else { -// break; -// } -// } - } } From f3f6545b99ddd9453b1a0f7abd00d3815c70bf83 Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Fri, 12 Apr 2024 16:22:28 -0400 Subject: [PATCH 13/25] Refactor SolrCoreMetric categorization objects --- .../solr/handler/admin/MetricsHandler.java | 6 ++-- .../prometheus/SolrCoreCacheMetric.java | 17 +++++---- .../prometheus/SolrCoreHandlerMetric.java | 25 ++++++++----- .../prometheus/SolrCoreHighlighterMetric.java | 13 ++++--- .../prometheus/SolrCoreIndexMetric.java | 12 ++++--- .../metrics/prometheus/SolrCoreMetric.java | 4 ++- .../prometheus/SolrCoreNoOpMetric.java | 6 ++-- .../prometheus/SolrCoreSearcherMetric.java | 18 ++++++---- .../prometheus/SolrCoreTlogMetric.java | 14 +++++--- .../SolrPrometheusCoreRegistry.java | 35 +++++++++---------- .../apache/solr/util/stats/MetricUtils.java | 2 ++ 11 files changed, 91 insertions(+), 61 deletions(-) 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.java index 6227ff62a3f..ba716926fbe 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 @@ -196,8 +196,9 @@ private NamedList handlePrometheusRegistry(SolrParams params, Set result = new SimpleOrderedMap<>(); - if(registryName.startsWith("solr.core")){ + + // Currently only export Solr Core registries + if ( registryName.startsWith("solr.core") ) { MetricUtils.toPrometheusRegistry( dropWizardRegistry, registryName, @@ -211,6 +212,7 @@ private NamedList handlePrometheusRegistry(SolrParams params, Set) dropwizardMetric, CORE_CACHE_SEARCHER_METRICS, coreName, splitString[2]); + String cacheType = parseMetric[2]; + solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_CACHE_SEARCHER_METRICS, coreName, cacheType); + } else { + System.out.println("This Metric does not exist"); } } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java index 2238f97e170..66bd3fa94ce 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java @@ -10,28 +10,35 @@ public class SolrCoreHandlerMetric extends SolrCoreMetric { public static final String CORE_REQUESTS_TOTAL_TIME = "solr_metrics_core_requests_total_time"; public static final String CORE_HANDLER_HANDLER_START = "solr_metrics_core_handler_start"; public static final String CORE_UPDATE_HANDLER = "solr_metrics_core_update_handler_metrics"; - public SolrCoreHandlerMetric(Metric dropwizardMetric) { + public SolrCoreHandlerMetric(Metric dropwizardMetric, String coreName, String metricName) { this.dropwizardMetric = dropwizardMetric; + this.coreName = coreName; + this.metricName = metricName; } @Override - public void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry, String metricName) { - String coreName = solrPrometheusCoreRegistry.coreName; - String[] splitString = metricName.split("\\."); + public void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + String[] parsedMetric = metricName.split("\\."); + String category = parsedMetric[0]; + String handler = parsedMetric[1]; + String type = parsedMetric[2]; + if (dropwizardMetric instanceof Meter) { - solrPrometheusCoreRegistry.exportMeter((Meter) dropwizardMetric, CORE_REQUESTS_TOTAL, splitString[0], splitString[1], coreName, splitString[2]); + solrPrometheusCoreRegistry.exportMeter((Meter) dropwizardMetric, CORE_REQUESTS_TOTAL, coreName, category, handler, type); } else if (dropwizardMetric instanceof Counter) { if (metricName.endsWith("requests")) { - solrPrometheusCoreRegistry.exportCounter((Counter) dropwizardMetric, CORE_REQUESTS_TOTAL, splitString[0], splitString[1], coreName, splitString[2]); + solrPrometheusCoreRegistry.exportCounter((Counter) dropwizardMetric, CORE_REQUESTS_TOTAL, coreName, category, handler, type); } else if (metricName.endsWith("totalTime")) { - solrPrometheusCoreRegistry.exportCounter((Counter) dropwizardMetric, CORE_REQUESTS_TOTAL_TIME, splitString[0], splitString[1], coreName, splitString[2]); + solrPrometheusCoreRegistry.exportCounter((Counter) dropwizardMetric, CORE_REQUESTS_TOTAL_TIME, coreName, category, handler, type); } } else if (dropwizardMetric instanceof Gauge) { if (metricName.endsWith("handlerStart")) { - solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_HANDLER_HANDLER_START, splitString[0], splitString[1], coreName, splitString[2]); + solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_HANDLER_HANDLER_START, coreName, category, handler, type); } else { - solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_UPDATE_HANDLER, splitString[0], splitString[1], coreName, splitString[2]); + solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_UPDATE_HANDLER, coreName, category, handler, type); } + } else { + System.out.println("This Metric does not exist"); } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java index f5406218b10..08b28594390 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java @@ -6,16 +6,19 @@ public class SolrCoreHighlighterMetric extends SolrCoreMetric { public static final String CORE_HIGHLIGHER_METRICS = "solr_metrics_core_highlighter_requests"; - public SolrCoreHighlighterMetric(Metric dropwizardMetric) { + public SolrCoreHighlighterMetric(Metric dropwizardMetric, String coreName, String metricName) { this.dropwizardMetric = dropwizardMetric; + this.coreName = coreName; + this.metricName = metricName; } @Override - void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry, String metricName) { - String coreName = solrPrometheusCoreRegistry.coreName; - String[] splitString = metricName.split("\\."); + void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + String[] parsedMetric = metricName.split("\\."); if (dropwizardMetric instanceof Counter) { - solrPrometheusCoreRegistry.exportCounter((Counter) dropwizardMetric, CORE_HIGHLIGHER_METRICS, coreName, splitString[1], splitString[2]); + String type = parsedMetric[1]; + String item = parsedMetric[2]; + solrPrometheusCoreRegistry.exportCounter((Counter) dropwizardMetric, CORE_HIGHLIGHER_METRICS, coreName, type, item); } } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java index 8de30748b7d..82215d91a47 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java @@ -6,16 +6,18 @@ public class SolrCoreIndexMetric extends SolrCoreMetric { public static final String CORE_INDEX_METRICS = "solr_metrics_index"; - public SolrCoreIndexMetric(Metric dropwizardMetric) { + public SolrCoreIndexMetric(Metric dropwizardMetric, String coreName, String metricName) { this.dropwizardMetric = dropwizardMetric; + this.coreName = coreName; + this.metricName = metricName; } @Override - void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry, String metricName) { - String coreName = solrPrometheusCoreRegistry.coreName; - String[] splitString = metricName.split("\\."); + void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + String[] parsedMetric = metricName.split("\\."); if (dropwizardMetric instanceof Gauge) { - solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_INDEX_METRICS, coreName, splitString[1]); + String type = parsedMetric[1]; + solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_INDEX_METRICS, coreName, type); } } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java index 5b26d17f0ae..a2dffd59d3d 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java @@ -4,5 +4,7 @@ public abstract class SolrCoreMetric { public Metric dropwizardMetric; - abstract void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry, String metricName); + public String coreName; + public String metricName; + abstract void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry); } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java index 6ee5cb5e1d6..9aacea9fa1d 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java @@ -4,11 +4,13 @@ public class SolrCoreNoOpMetric extends SolrCoreMetric { - public SolrCoreNoOpMetric(Metric dropwizardMetric) { + public SolrCoreNoOpMetric(Metric dropwizardMetric, String coreName, String metricName) { this.dropwizardMetric = dropwizardMetric; + this.coreName = coreName; + this.metricName = metricName; } @Override - void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry, String metricName) { + void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { System.out.println("Cannot export string metrics"); } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java index d2ae01463ce..c37dcfaf2c9 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java @@ -7,22 +7,26 @@ public class SolrCoreSearcherMetric extends SolrCoreMetric { public static final String CORE_SEARCHER_METRICS = "solr_metrics_core_searcher"; - public static final String CORE_SEARCHER_CACHE_METRICS = "solr_metrics_core_searcher_cache"; - public SolrCoreSearcherMetric(Metric dropwizardMetric) { + public SolrCoreSearcherMetric(Metric dropwizardMetric, String coreName, String metricName) { this.dropwizardMetric = dropwizardMetric; + this.coreName = coreName; + this.metricName = metricName; } @Override - void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry, String metricName) { - String coreName = solrPrometheusCoreRegistry.coreName; - String[] splitString = metricName.split("\\."); + void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + String[] parsedMetric = metricName.split("\\."); + String type; if (dropwizardMetric instanceof Gauge) { + type = parsedMetric[2]; if (metricName.endsWith("liveDocsCache")) { - solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_CACHE_SEARCHER_METRICS, coreName, splitString[2]); + solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_CACHE_SEARCHER_METRICS, coreName, type); } else { - solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_SEARCHER_METRICS, coreName, splitString[2]); + solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_SEARCHER_METRICS, coreName, type); } + } else { + System.out.println("This metric does not exist"); } } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java index 7b72832a2ea..f79441afb3d 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java @@ -6,16 +6,20 @@ public class SolrCoreTlogMetric extends SolrCoreMetric { public static final String CORE_TLOG_METRICS = "solr_metrics_tlog_replicas"; - public SolrCoreTlogMetric(Metric dropwizardMetric) { + public SolrCoreTlogMetric(Metric dropwizardMetric, String coreName, String metricName) { this.dropwizardMetric = dropwizardMetric; + this.coreName = coreName; + this.metricName = metricName; } @Override - public void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry, String metricName) { - String coreName = solrPrometheusCoreRegistry.coreName; - String[] splitString = metricName.split("\\."); + public void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + String[] parsedMetric = metricName.split("\\."); + if (dropwizardMetric instanceof Meter) { - solrPrometheusCoreRegistry.exportMeter((Meter) dropwizardMetric, CORE_TLOG_METRICS, coreName, splitString[1], splitString[2]); + String item = parsedMetric[1]; + String type = parsedMetric[2]; + solrPrometheusCoreRegistry.exportMeter((Meter) dropwizardMetric, CORE_TLOG_METRICS, coreName, item, type); } else { System.out.println("Not possible to migrate string values to prometheus"); } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java index deeeb3c5ec6..cc5fbce56a0 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java @@ -7,7 +7,6 @@ import static org.apache.solr.metrics.prometheus.SolrCoreHandlerMetric.*; import static org.apache.solr.metrics.prometheus.SolrCoreHighlighterMetric.CORE_HIGHLIGHER_METRICS; import static org.apache.solr.metrics.prometheus.SolrCoreIndexMetric.CORE_INDEX_METRICS; -import static org.apache.solr.metrics.prometheus.SolrCoreSearcherMetric.CORE_SEARCHER_CACHE_METRICS; import static org.apache.solr.metrics.prometheus.SolrCoreSearcherMetric.CORE_SEARCHER_METRICS; import static org.apache.solr.metrics.prometheus.SolrCoreTlogMetric.CORE_TLOG_METRICS; @@ -21,50 +20,50 @@ public SolrPrometheusCoreRegistry(PrometheusRegistry prometheusRegistry, String @Override public SolrPrometheusCoreRegistry registerDefaultMetrics() { - createCounter(CORE_REQUESTS_TOTAL, "Solr requests Total", "category", "handler", "collection", "type"); - createCounter(CORE_REQUESTS_TOTAL_TIME, "Solr requests Total", "category", "handler", "collection", "type"); + createCounter(CORE_REQUESTS_TOTAL, "Solr requests Total", "collection", "category", "handler", "type"); + createGauge(CORE_HANDLER_HANDLER_START, "Handler Start Time", "collection", "category", "handler", "type"); + createCounter(CORE_REQUESTS_TOTAL_TIME, "Solr requests Total", "collection", "category", "handler", "type"); + createGauge(CORE_UPDATE_HANDLER, "Handler Start Time", "collection", "category", "handler", "type"); createCounter(CORE_TLOG_METRICS, "Solr TLOG Metrics", "collection", "type", "item"); - createCounter(CORE_HIGHLIGHER_METRICS, "Solr Highlighter Metrics", "collection", "type", "item"); - createGauge(CORE_HANDLER_HANDLER_START, "Handler Start Time", "category", "handler", "collection", "type"); - createGauge(CORE_UPDATE_HANDLER, "Handler Start Time", "category", "handler", "collection", "type"); - createGauge(CORE_SEARCHER_METRICS, "SearcherMetrics", "collection", "searcherItem"); createGauge(CORE_CACHE_SEARCHER_METRICS, "Searcher Cache Metrics", "collection", "cacheType", "item"); + createGauge(CORE_SEARCHER_METRICS, "SearcherMetrics", "collection", "searcherItem"); + createCounter(CORE_HIGHLIGHER_METRICS, "Solr Highlighter Metrics", "collection", "type", "item"); createGauge(CORE_INDEX_METRICS, "Index Metrics", "collection", "type"); return this; } public void exportDropwizardMetric(String metricName, Metric dropwizardMetric) { - String metricCategory = metricName.split("\\.")[0]; - SolrCoreMetric solrCoreMetric = categorizeCorePrefix(dropwizardMetric, metricCategory); - solrCoreMetric.toPrometheus(this, metricName); + SolrCoreMetric solrCoreMetric = categorizeCorePrefix(dropwizardMetric, metricName); + solrCoreMetric.toPrometheus(this); } - private SolrCoreMetric categorizeCorePrefix(Metric dropwizardMetric, String metricCategory) { + private SolrCoreMetric categorizeCorePrefix(Metric dropwizardMetric, String metricName) { + String metricCategory = metricName.split("\\.")[0]; switch (metricCategory) { case "ADMIN": case "QUERY": case "UPDATE": case "REPLICATION": { - return new SolrCoreHandlerMetric(dropwizardMetric); + return new SolrCoreHandlerMetric(dropwizardMetric, coreName, metricName); } case "TLOG": { - return new SolrCoreTlogMetric(dropwizardMetric); + return new SolrCoreTlogMetric(dropwizardMetric, coreName, metricName); } case "CACHE": { - return new SolrCoreCacheMetric(dropwizardMetric); + return new SolrCoreCacheMetric(dropwizardMetric, coreName, metricName); } case "SEARCHER":{ - return new SolrCoreSearcherMetric(dropwizardMetric); + return new SolrCoreSearcherMetric(dropwizardMetric, coreName, metricName); } case "HIGHLIGHTER": { - return new SolrCoreHighlighterMetric(dropwizardMetric); + return new SolrCoreHighlighterMetric(dropwizardMetric, coreName, metricName); } case "INDEX": { - return new SolrCoreIndexMetric(dropwizardMetric); + return new SolrCoreIndexMetric(dropwizardMetric, coreName, metricName); } case "CORE": default: { - return new SolrCoreNoOpMetric(dropwizardMetric); + return new SolrCoreNoOpMetric(dropwizardMetric, coreName, metricName); } } } 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.java index c78fe1007c3..3605eac8e7d 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 @@ -199,12 +199,14 @@ public static void toPrometheusRegistry( (metricName, metric) -> { Metric dropwizardMetric = dropwizardMetrics.get(metricName); String[] splitString = metricName.split("\\."); + if(!categories.containsKey(splitString[0])) { categories.put(splitString[0], new HashMap<>()); } if(!categories.get(splitString[0]).containsKey(metricName)) { categories.get(splitString[0]).put(metricName, dropwizardMetric); } + solrPrometheusCoreMetrics.exportDropwizardMetric(metricName, dropwizardMetric); }); consumer.accept(solrPrometheusCoreMetrics.getPrometheusRegistry()); From f2637fec2afcdf1fbfceb8e0bef2a74defeb7061 Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Fri, 12 Apr 2024 17:13:53 -0400 Subject: [PATCH 14/25] Get core name from Solr cloud mode --- .../org/apache/solr/util/stats/MetricUtils.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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.java index 3605eac8e7d..28e0087b806 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 @@ -41,6 +41,7 @@ import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Predicate; +import java.util.stream.Collectors; import io.prometheus.metrics.model.registry.PrometheusRegistry; import org.apache.solr.common.ConditionalKeyMapWriter; @@ -175,12 +176,14 @@ public static void toPrometheusRegistry( boolean compact, Consumer consumer) { Map dropwizardMetrics = registry.getMetrics(); - String[] splitRegistryName = registryName.split("\\."); + String[]rawParsedRegistry = registryName.split("\\."); + List parsedRegistry = new ArrayList<>( + Arrays.asList(rawParsedRegistry)); String coreName; - if (splitRegistryName.length == 3) { - coreName = splitRegistryName[2]; - } else if (splitRegistryName.length == 5) { - coreName = "NoCoreNameFound"; + if (parsedRegistry.size() == 3) { + coreName = parsedRegistry.get(2); + } else if (parsedRegistry.size() == 5) { + coreName =parsedRegistry.stream().skip(1).collect(Collectors.joining("_")); } else { coreName = "NoCoreNameFound"; } From 5083d560eb29602c4639e40a92f87cd37dc7efcf Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Mon, 15 Apr 2024 14:56:13 -0400 Subject: [PATCH 15/25] Refactor registering metric types --- .../prometheus/SolrCoreCacheMetric.java | 20 ++++++-- .../prometheus/SolrCoreHandlerMetric.java | 24 ++++++--- .../prometheus/SolrCoreHighlighterMetric.java | 19 +++++-- .../prometheus/SolrCoreIndexMetric.java | 18 +++++-- .../metrics/prometheus/SolrCoreMetric.java | 6 +++ .../prometheus/SolrCoreNoOpMetric.java | 8 +++ .../prometheus/SolrCoreSearcherMetric.java | 21 ++++++-- .../prometheus/SolrCoreTlogMetric.java | 18 +++++-- .../SolrPrometheusCoreRegistry.java | 23 +-------- .../prometheus/SolrPrometheusRegistry.java | 50 ++++++++++--------- .../apache/solr/util/stats/MetricUtils.java | 6 +-- 11 files changed, 140 insertions(+), 73 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java index da9cfc45b96..0cb3dc4700d 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java @@ -3,6 +3,8 @@ import com.codahale.metrics.Gauge; import com.codahale.metrics.Metric; +import java.util.Map; + public class SolrCoreCacheMetric extends SolrCoreMetric { public static final String CORE_CACHE_SEARCHER_METRICS = "solr_metrics_core_cache_gauge"; @@ -11,13 +13,23 @@ public SolrCoreCacheMetric(Metric dropwizardMetric, String coreName, String metr this.coreName = coreName; this.metricName = metricName; } + @Override - void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { - String[] parseMetric = metricName.split("\\."); + public SolrCoreMetric parseLabels() { + String[] parsedMetric = metricName.split("\\."); + if (dropwizardMetric instanceof Gauge) { + String cacheType = parsedMetric[2]; + labels = Map.of( + "core", coreName, + "cacheType", cacheType); + } + return this; + } + @Override + void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { if (dropwizardMetric instanceof Gauge) { - String cacheType = parseMetric[2]; - solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_CACHE_SEARCHER_METRICS, coreName, cacheType); + solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_CACHE_SEARCHER_METRICS, labels); } else { System.out.println("This Metric does not exist"); } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java index 66bd3fa94ce..97ce6e62536 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java @@ -5,6 +5,9 @@ import com.codahale.metrics.Meter; import com.codahale.metrics.Metric; +import java.util.HashMap; +import java.util.Map; + public class SolrCoreHandlerMetric extends SolrCoreMetric { public static final String CORE_REQUESTS_TOTAL = "solr_metrics_core_requests_total"; public static final String CORE_REQUESTS_TOTAL_TIME = "solr_metrics_core_requests_total_time"; @@ -17,25 +20,34 @@ public SolrCoreHandlerMetric(Metric dropwizardMetric, String coreName, String me } @Override - public void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + public SolrCoreMetric parseLabels() { String[] parsedMetric = metricName.split("\\."); String category = parsedMetric[0]; String handler = parsedMetric[1]; String type = parsedMetric[2]; + this.labels = Map.of( + "core", coreName, + "category", category, + "handler", handler, + "type", type); + return this; + } + @Override + public void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { if (dropwizardMetric instanceof Meter) { - solrPrometheusCoreRegistry.exportMeter((Meter) dropwizardMetric, CORE_REQUESTS_TOTAL, coreName, category, handler, type); + solrPrometheusCoreRegistry.exportMeter((Meter) dropwizardMetric, CORE_REQUESTS_TOTAL, labels); } else if (dropwizardMetric instanceof Counter) { if (metricName.endsWith("requests")) { - solrPrometheusCoreRegistry.exportCounter((Counter) dropwizardMetric, CORE_REQUESTS_TOTAL, coreName, category, handler, type); + solrPrometheusCoreRegistry.exportCounter((Counter) dropwizardMetric, CORE_REQUESTS_TOTAL, labels); } else if (metricName.endsWith("totalTime")) { - solrPrometheusCoreRegistry.exportCounter((Counter) dropwizardMetric, CORE_REQUESTS_TOTAL_TIME, coreName, category, handler, type); + solrPrometheusCoreRegistry.exportCounter((Counter) dropwizardMetric, CORE_REQUESTS_TOTAL_TIME, labels); } } else if (dropwizardMetric instanceof Gauge) { if (metricName.endsWith("handlerStart")) { - solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_HANDLER_HANDLER_START, coreName, category, handler, type); + solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_HANDLER_HANDLER_START, labels); } else { - solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_UPDATE_HANDLER, coreName, category, handler, type); + solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_UPDATE_HANDLER, labels); } } else { System.out.println("This Metric does not exist"); diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java index 08b28594390..3c7da010dd7 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java @@ -3,6 +3,8 @@ import com.codahale.metrics.Counter; import com.codahale.metrics.Metric; +import java.util.Map; + public class SolrCoreHighlighterMetric extends SolrCoreMetric { public static final String CORE_HIGHLIGHER_METRICS = "solr_metrics_core_highlighter_requests"; @@ -13,12 +15,21 @@ public SolrCoreHighlighterMetric(Metric dropwizardMetric, String coreName, Strin } @Override - void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + public SolrCoreMetric parseLabels() { String[] parsedMetric = metricName.split("\\."); + String type = parsedMetric[1]; + String item = parsedMetric[2]; + labels = Map.of( + "core", coreName, + "type", type, + "item", item); + return this; + } + + @Override + void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { if (dropwizardMetric instanceof Counter) { - String type = parsedMetric[1]; - String item = parsedMetric[2]; - solrPrometheusCoreRegistry.exportCounter((Counter) dropwizardMetric, CORE_HIGHLIGHER_METRICS, coreName, type, item); + solrPrometheusCoreRegistry.exportCounter((Counter) dropwizardMetric, CORE_HIGHLIGHER_METRICS, labels); } } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java index 82215d91a47..ce500a878be 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java @@ -3,6 +3,8 @@ import com.codahale.metrics.Gauge; import com.codahale.metrics.Metric; +import java.util.Map; + public class SolrCoreIndexMetric extends SolrCoreMetric { public static final String CORE_INDEX_METRICS = "solr_metrics_index"; @@ -13,11 +15,21 @@ public SolrCoreIndexMetric(Metric dropwizardMetric, String coreName, String metr } @Override - void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { - String[] parsedMetric = metricName.split("\\."); + public SolrCoreMetric parseLabels() { if (dropwizardMetric instanceof Gauge) { + String[] parsedMetric = metricName.split("\\."); String type = parsedMetric[1]; - solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_INDEX_METRICS, coreName, type); + labels = Map.of( + "core", coreName, + "type", type); + } + return this; + } + + @Override + void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + if (dropwizardMetric instanceof Gauge) { + solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_INDEX_METRICS, labels); } } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java index a2dffd59d3d..8fcd9e3a8c3 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java @@ -2,9 +2,15 @@ import com.codahale.metrics.Metric; +import java.util.HashMap; +import java.util.Map; + public abstract class SolrCoreMetric { public Metric dropwizardMetric; public String coreName; public String metricName; + public Map labels; + public Map defaultLabels = Map.of(); + abstract SolrCoreMetric parseLabels(); abstract void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry); } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java index 9aacea9fa1d..862640f1296 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java @@ -2,6 +2,8 @@ import com.codahale.metrics.Metric; +import java.util.Map; + public class SolrCoreNoOpMetric extends SolrCoreMetric { public SolrCoreNoOpMetric(Metric dropwizardMetric, String coreName, String metricName) { @@ -9,6 +11,12 @@ public SolrCoreNoOpMetric(Metric dropwizardMetric, String coreName, String metri this.coreName = coreName; this.metricName = metricName; } + + @Override + public SolrCoreMetric parseLabels() { + return this; + } + @Override void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { System.out.println("Cannot export string metrics"); diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java index c37dcfaf2c9..25dc3da6d99 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java @@ -3,6 +3,8 @@ import com.codahale.metrics.Gauge; import com.codahale.metrics.Metric; +import java.util.Map; + import static org.apache.solr.metrics.prometheus.SolrCoreCacheMetric.CORE_CACHE_SEARCHER_METRICS; public class SolrCoreSearcherMetric extends SolrCoreMetric { @@ -15,15 +17,24 @@ public SolrCoreSearcherMetric(Metric dropwizardMetric, String coreName, String m } @Override - void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + public SolrCoreMetric parseLabels() { String[] parsedMetric = metricName.split("\\."); - String type; if (dropwizardMetric instanceof Gauge) { - type = parsedMetric[2]; + String type = parsedMetric[2]; + labels = Map.of( + "core", coreName, + "type", type); + } + return this; + } + + @Override + void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + if (dropwizardMetric instanceof Gauge) { if (metricName.endsWith("liveDocsCache")) { - solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_CACHE_SEARCHER_METRICS, coreName, type); + solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_CACHE_SEARCHER_METRICS, labels); } else { - solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_SEARCHER_METRICS, coreName, type); + solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_SEARCHER_METRICS, labels); } } else { System.out.println("This metric does not exist"); diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java index f79441afb3d..09f351f61d4 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java @@ -3,6 +3,8 @@ import com.codahale.metrics.Meter; import com.codahale.metrics.Metric; +import java.util.Map; + public class SolrCoreTlogMetric extends SolrCoreMetric { public static final String CORE_TLOG_METRICS = "solr_metrics_tlog_replicas"; @@ -13,13 +15,23 @@ public SolrCoreTlogMetric(Metric dropwizardMetric, String coreName, String metri } @Override - public void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + public SolrCoreMetric parseLabels() { String[] parsedMetric = metricName.split("\\."); - if (dropwizardMetric instanceof Meter) { String item = parsedMetric[1]; String type = parsedMetric[2]; - solrPrometheusCoreRegistry.exportMeter((Meter) dropwizardMetric, CORE_TLOG_METRICS, coreName, item, type); + this.labels = Map.of( + "core", coreName, + "item", item, + "type", type); + } + return this; + } + + @Override + public void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + if (dropwizardMetric instanceof Meter) { + solrPrometheusCoreRegistry.exportMeter((Meter) dropwizardMetric, CORE_TLOG_METRICS, labels); } else { System.out.println("Not possible to migrate string values to prometheus"); } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java index cc5fbce56a0..c807c9cc79b 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java @@ -3,13 +3,6 @@ import com.codahale.metrics.*; import io.prometheus.metrics.model.registry.PrometheusRegistry; -import static org.apache.solr.metrics.prometheus.SolrCoreCacheMetric.CORE_CACHE_SEARCHER_METRICS; -import static org.apache.solr.metrics.prometheus.SolrCoreHandlerMetric.*; -import static org.apache.solr.metrics.prometheus.SolrCoreHighlighterMetric.CORE_HIGHLIGHER_METRICS; -import static org.apache.solr.metrics.prometheus.SolrCoreIndexMetric.CORE_INDEX_METRICS; -import static org.apache.solr.metrics.prometheus.SolrCoreSearcherMetric.CORE_SEARCHER_METRICS; -import static org.apache.solr.metrics.prometheus.SolrCoreTlogMetric.CORE_TLOG_METRICS; - public class SolrPrometheusCoreRegistry extends SolrPrometheusRegistry { public final String coreName; @@ -18,23 +11,9 @@ public SolrPrometheusCoreRegistry(PrometheusRegistry prometheusRegistry, String this.coreName = coreName; } - @Override - public SolrPrometheusCoreRegistry registerDefaultMetrics() { - createCounter(CORE_REQUESTS_TOTAL, "Solr requests Total", "collection", "category", "handler", "type"); - createGauge(CORE_HANDLER_HANDLER_START, "Handler Start Time", "collection", "category", "handler", "type"); - createCounter(CORE_REQUESTS_TOTAL_TIME, "Solr requests Total", "collection", "category", "handler", "type"); - createGauge(CORE_UPDATE_HANDLER, "Handler Start Time", "collection", "category", "handler", "type"); - createCounter(CORE_TLOG_METRICS, "Solr TLOG Metrics", "collection", "type", "item"); - createGauge(CORE_CACHE_SEARCHER_METRICS, "Searcher Cache Metrics", "collection", "cacheType", "item"); - createGauge(CORE_SEARCHER_METRICS, "SearcherMetrics", "collection", "searcherItem"); - createCounter(CORE_HIGHLIGHER_METRICS, "Solr Highlighter Metrics", "collection", "type", "item"); - createGauge(CORE_INDEX_METRICS, "Index Metrics", "collection", "type"); - return this; - } - public void exportDropwizardMetric(String metricName, Metric dropwizardMetric) { SolrCoreMetric solrCoreMetric = categorizeCorePrefix(dropwizardMetric, metricName); - solrCoreMetric.toPrometheus(this); + solrCoreMetric.parseLabels().toPrometheus(this); } private SolrCoreMetric categorizeCorePrefix(Metric dropwizardMetric, String metricName) { diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java index 86f8368e9b3..f45def6d939 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java @@ -1,15 +1,11 @@ package org.apache.solr.metrics.prometheus; import com.codahale.metrics.Meter; -import com.codahale.metrics.Metric; import io.prometheus.metrics.core.metrics.Counter; import io.prometheus.metrics.core.metrics.Gauge; -import io.prometheus.metrics.core.metrics.Histogram; -import io.prometheus.metrics.core.metrics.Summary; import io.prometheus.metrics.model.registry.PrometheusRegistry; -import io.prometheus.metrics.model.snapshots.CounterSnapshot; -import io.prometheus.metrics.model.snapshots.Unit; +import java.util.ArrayList; import java.util.HashMap; import java.util.Map; @@ -18,15 +14,11 @@ public abstract class SolrPrometheusRegistry { String registryName; private final Map metricCounters; private final Map metricGauges; - private final Map metricHistograms; - private final Map metricSummaries; public SolrPrometheusRegistry(PrometheusRegistry prometheusRegistry) { this.prometheusRegistry = prometheusRegistry; this.metricCounters = new HashMap<>(); this.metricGauges = new HashMap<>(); - this.metricHistograms = new HashMap<>(); - this.metricSummaries = new HashMap<>(); } public PrometheusRegistry getPrometheusRegistry() { @@ -45,39 +37,51 @@ public Gauge getMetricGauge(String metricName) { return metricGauges.get(metricName); } - abstract SolrPrometheusRegistry registerDefaultMetrics(); - - protected Counter createCounter(String metricName, String help, String ...labelNames) { + protected void registerCounter(String metricName, String ...labelNames) { Counter counter = io.prometheus.metrics.core.metrics.Counter.builder() .name(metricName) - .help(help) .labelNames(labelNames) .register(prometheusRegistry); metricCounters.put(metricName, counter); - return counter; } - protected Gauge createGauge(String metricName, String help, String ...labelNames) { + protected void registerGauge(String metricName, String ...labelNames) { Gauge gauge = io.prometheus.metrics.core.metrics.Gauge.builder() .name(metricName) - .help(help) .labelNames(labelNames) .register(prometheusRegistry); metricGauges.put(metricName, gauge); - return gauge; } - protected void exportMeter(Meter dropwizardMetric, String prometheusMetricName, String ...labels) { - getMetricCounter(prometheusMetricName).labelValues(labels).inc(dropwizardMetric.getCount()); + protected void exportMeter(Meter dropwizardMetric, String prometheusMetricName, Map labelsMap) { + if (!metricCounters.containsKey(prometheusMetricName)) { + ArrayList labels = new ArrayList<>(labelsMap.keySet()); + registerCounter(prometheusMetricName, labels.toArray(String[]::new)); + } + ArrayList labelValues = new ArrayList<>(labelsMap.values()); + getMetricCounter(prometheusMetricName).labelValues(labelValues.toArray(String[]::new)).inc(dropwizardMetric.getCount()); } - protected void exportCounter(com.codahale.metrics.Counter dropwizardMetric, String prometheusMetricName, String ...labels) { - getMetricCounter(prometheusMetricName).labelValues(labels).inc(dropwizardMetric.getCount()); + protected void exportCounter(com.codahale.metrics.Counter dropwizardMetric, String prometheusMetricName, Map labelsMap) { + if (!metricCounters.containsKey(prometheusMetricName)) { + ArrayList labels = new ArrayList<>(labelsMap.keySet()); + registerCounter(prometheusMetricName, labels.toArray(String[]::new)); + } + ArrayList labelValues = new ArrayList<>(labelsMap.values()); + getMetricCounter(prometheusMetricName).labelValues(labelValues.toArray(String[]::new)).inc(dropwizardMetric.getCount()); } - - protected void exportGauge(com.codahale.metrics.Gauge dropwizardMetricRaw, String prometheusMetricName, String ...labels) { + protected void exportGauge(com.codahale.metrics.Gauge dropwizardMetricRaw, String prometheusMetricName, Map labelsMap) { Object dropwizardMetric = (dropwizardMetricRaw).getValue(); + if (!metricGauges.containsKey(prometheusMetricName)) { + ArrayList labels = new ArrayList<>(labelsMap.keySet()); + if (dropwizardMetric instanceof HashMap) { + labels.add("item"); + } + registerGauge(prometheusMetricName, labels.toArray(String[]::new)); + } + ArrayList labelValues = new ArrayList<>(labelsMap.values()); + String[] labels = labelValues.toArray(String[]::new); if (dropwizardMetric instanceof Number) { getMetricGauge(prometheusMetricName).labelValues(labels).set(((Number) dropwizardMetric).doubleValue()); } else if (dropwizardMetric instanceof HashMap) { 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.java index 28e0087b806..472fc356792 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 @@ -183,11 +183,11 @@ public static void toPrometheusRegistry( if (parsedRegistry.size() == 3) { coreName = parsedRegistry.get(2); } else if (parsedRegistry.size() == 5) { - coreName =parsedRegistry.stream().skip(1).collect(Collectors.joining("_")); + coreName = parsedRegistry.stream().skip(1).collect(Collectors.joining("_")); } else { - coreName = "NoCoreNameFound"; + coreName = registryName; } - SolrPrometheusCoreRegistry solrPrometheusCoreMetrics = new SolrPrometheusCoreRegistry(new PrometheusRegistry(), coreName).registerDefaultMetrics(); + SolrPrometheusCoreRegistry solrPrometheusCoreMetrics = new SolrPrometheusCoreRegistry(new PrometheusRegistry(), coreName); Map> categories = new HashMap<>(); toMaps( From c4ccbe0ddfcdfc9000715f2e9c3303caf9a5f76a Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Mon, 15 Apr 2024 15:58:49 -0400 Subject: [PATCH 16/25] Introduce cloud mode metrics --- .../prometheus/SolrCoreCacheMetric.java | 11 ++++----- .../prometheus/SolrCoreHandlerMetric.java | 14 ++++------- .../prometheus/SolrCoreHighlighterMetric.java | 13 ++++------- .../prometheus/SolrCoreIndexMetric.java | 11 ++++----- .../metrics/prometheus/SolrCoreMetric.java | 16 +++++++++++-- .../prometheus/SolrCoreNoOpMetric.java | 6 ++--- .../prometheus/SolrCoreSearcherMetric.java | 11 ++++----- .../prometheus/SolrCoreTlogMetric.java | 13 ++++------- .../SolrPrometheusCoreRegistry.java | 23 ++++++++++++------- .../apache/solr/util/stats/MetricUtils.java | 4 +++- 10 files changed, 61 insertions(+), 61 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java index 0cb3dc4700d..8d8193f45bd 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java @@ -3,15 +3,14 @@ import com.codahale.metrics.Gauge; import com.codahale.metrics.Metric; +import java.util.HashMap; import java.util.Map; public class SolrCoreCacheMetric extends SolrCoreMetric { public static final String CORE_CACHE_SEARCHER_METRICS = "solr_metrics_core_cache_gauge"; - public SolrCoreCacheMetric(Metric dropwizardMetric, String coreName, String metricName) { - this.dropwizardMetric = dropwizardMetric; - this.coreName = coreName; - this.metricName = metricName; + public SolrCoreCacheMetric(Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { + super(dropwizardMetric, coreName, metricName, cloudMode); } @Override @@ -19,9 +18,7 @@ public SolrCoreMetric parseLabels() { String[] parsedMetric = metricName.split("\\."); if (dropwizardMetric instanceof Gauge) { String cacheType = parsedMetric[2]; - labels = Map.of( - "core", coreName, - "cacheType", cacheType); + labels.put("cacheType", cacheType); } return this; } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java index 97ce6e62536..19ada8b738a 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java @@ -13,10 +13,8 @@ public class SolrCoreHandlerMetric extends SolrCoreMetric { public static final String CORE_REQUESTS_TOTAL_TIME = "solr_metrics_core_requests_total_time"; public static final String CORE_HANDLER_HANDLER_START = "solr_metrics_core_handler_start"; public static final String CORE_UPDATE_HANDLER = "solr_metrics_core_update_handler_metrics"; - public SolrCoreHandlerMetric(Metric dropwizardMetric, String coreName, String metricName) { - this.dropwizardMetric = dropwizardMetric; - this.coreName = coreName; - this.metricName = metricName; + public SolrCoreHandlerMetric(Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { + super(dropwizardMetric, coreName, metricName, cloudMode); } @Override @@ -25,11 +23,9 @@ public SolrCoreMetric parseLabels() { String category = parsedMetric[0]; String handler = parsedMetric[1]; String type = parsedMetric[2]; - this.labels = Map.of( - "core", coreName, - "category", category, - "handler", handler, - "type", type); + labels.put("category", category); + labels.put("handler", handler); + labels.put("type", type); return this; } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java index 3c7da010dd7..f18b3c5af42 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java @@ -3,15 +3,14 @@ import com.codahale.metrics.Counter; import com.codahale.metrics.Metric; +import java.util.HashMap; import java.util.Map; public class SolrCoreHighlighterMetric extends SolrCoreMetric { public static final String CORE_HIGHLIGHER_METRICS = "solr_metrics_core_highlighter_requests"; - public SolrCoreHighlighterMetric(Metric dropwizardMetric, String coreName, String metricName) { - this.dropwizardMetric = dropwizardMetric; - this.coreName = coreName; - this.metricName = metricName; + public SolrCoreHighlighterMetric(Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { + super(dropwizardMetric, coreName, metricName, cloudMode); } @Override @@ -19,10 +18,8 @@ public SolrCoreMetric parseLabels() { String[] parsedMetric = metricName.split("\\."); String type = parsedMetric[1]; String item = parsedMetric[2]; - labels = Map.of( - "core", coreName, - "type", type, - "item", item); + labels.put("type", type); + labels.put("item", item); return this; } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java index ce500a878be..85f25c48c27 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java @@ -3,15 +3,14 @@ import com.codahale.metrics.Gauge; import com.codahale.metrics.Metric; +import java.util.HashMap; import java.util.Map; public class SolrCoreIndexMetric extends SolrCoreMetric { public static final String CORE_INDEX_METRICS = "solr_metrics_index"; - public SolrCoreIndexMetric(Metric dropwizardMetric, String coreName, String metricName) { - this.dropwizardMetric = dropwizardMetric; - this.coreName = coreName; - this.metricName = metricName; + public SolrCoreIndexMetric(Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { + super(dropwizardMetric, coreName, metricName, cloudMode); } @Override @@ -19,9 +18,7 @@ public SolrCoreMetric parseLabels() { if (dropwizardMetric instanceof Gauge) { String[] parsedMetric = metricName.split("\\."); String type = parsedMetric[1]; - labels = Map.of( - "core", coreName, - "type", type); + labels.put("type", type); } return this; } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java index 8fcd9e3a8c3..3cd34182057 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java @@ -9,8 +9,20 @@ public abstract class SolrCoreMetric { public Metric dropwizardMetric; public String coreName; public String metricName; - public Map labels; - public Map defaultLabels = Map.of(); + public Map labels = new HashMap<>(); + + public SolrCoreMetric(Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { + this.dropwizardMetric = dropwizardMetric; + this.coreName = coreName; + 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]); + } + } abstract SolrCoreMetric parseLabels(); abstract void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry); } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java index 862640f1296..41d5ed30b16 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java @@ -6,10 +6,8 @@ public class SolrCoreNoOpMetric extends SolrCoreMetric { - public SolrCoreNoOpMetric(Metric dropwizardMetric, String coreName, String metricName) { - this.dropwizardMetric = dropwizardMetric; - this.coreName = coreName; - this.metricName = metricName; + public SolrCoreNoOpMetric(Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { + super(dropwizardMetric, coreName, metricName, cloudMode); } @Override diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java index 25dc3da6d99..a88e964ff5f 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java @@ -3,6 +3,7 @@ import com.codahale.metrics.Gauge; import com.codahale.metrics.Metric; +import java.util.HashMap; import java.util.Map; import static org.apache.solr.metrics.prometheus.SolrCoreCacheMetric.CORE_CACHE_SEARCHER_METRICS; @@ -10,10 +11,8 @@ public class SolrCoreSearcherMetric extends SolrCoreMetric { public static final String CORE_SEARCHER_METRICS = "solr_metrics_core_searcher"; - public SolrCoreSearcherMetric(Metric dropwizardMetric, String coreName, String metricName) { - this.dropwizardMetric = dropwizardMetric; - this.coreName = coreName; - this.metricName = metricName; + public SolrCoreSearcherMetric(Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { + super(dropwizardMetric, coreName, metricName, cloudMode); } @Override @@ -21,9 +20,7 @@ public SolrCoreMetric parseLabels() { String[] parsedMetric = metricName.split("\\."); if (dropwizardMetric instanceof Gauge) { String type = parsedMetric[2]; - labels = Map.of( - "core", coreName, - "type", type); + labels.put("type", type); } return this; } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java index 09f351f61d4..837c5b9455c 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java @@ -3,15 +3,14 @@ import com.codahale.metrics.Meter; import com.codahale.metrics.Metric; +import java.util.HashMap; import java.util.Map; public class SolrCoreTlogMetric extends SolrCoreMetric { public static final String CORE_TLOG_METRICS = "solr_metrics_tlog_replicas"; - public SolrCoreTlogMetric(Metric dropwizardMetric, String coreName, String metricName) { - this.dropwizardMetric = dropwizardMetric; - this.coreName = coreName; - this.metricName = metricName; + public SolrCoreTlogMetric(Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { + super(dropwizardMetric, coreName, metricName, cloudMode); } @Override @@ -20,10 +19,8 @@ public SolrCoreMetric parseLabels() { if (dropwizardMetric instanceof Meter) { String item = parsedMetric[1]; String type = parsedMetric[2]; - this.labels = Map.of( - "core", coreName, - "item", item, - "type", type); + labels.put("item", item); + labels.put("type", type); } return this; } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java index c807c9cc79b..fa2700915c6 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java @@ -3,12 +3,19 @@ import com.codahale.metrics.*; import io.prometheus.metrics.model.registry.PrometheusRegistry; +import java.util.HashMap; +import java.util.Map; + public class SolrPrometheusCoreRegistry extends SolrPrometheusRegistry { public final String coreName; + public final boolean cloudMode; + - public SolrPrometheusCoreRegistry(PrometheusRegistry prometheusRegistry, String coreName) { + public SolrPrometheusCoreRegistry(PrometheusRegistry prometheusRegistry, String coreName, boolean cloudMode) { super(prometheusRegistry); this.coreName = coreName; + this.cloudMode = cloudMode; + } public void exportDropwizardMetric(String metricName, Metric dropwizardMetric) { @@ -23,26 +30,26 @@ private SolrCoreMetric categorizeCorePrefix(Metric dropwizardMetric, String metr case "QUERY": case "UPDATE": case "REPLICATION": { - return new SolrCoreHandlerMetric(dropwizardMetric, coreName, metricName); + return new SolrCoreHandlerMetric(dropwizardMetric, coreName, metricName, cloudMode); } case "TLOG": { - return new SolrCoreTlogMetric(dropwizardMetric, coreName, metricName); + return new SolrCoreTlogMetric(dropwizardMetric, coreName, metricName, cloudMode); } case "CACHE": { - return new SolrCoreCacheMetric(dropwizardMetric, coreName, metricName); + return new SolrCoreCacheMetric(dropwizardMetric, coreName, metricName, cloudMode); } case "SEARCHER":{ - return new SolrCoreSearcherMetric(dropwizardMetric, coreName, metricName); + return new SolrCoreSearcherMetric(dropwizardMetric, coreName, metricName, cloudMode); } case "HIGHLIGHTER": { - return new SolrCoreHighlighterMetric(dropwizardMetric, coreName, metricName); + return new SolrCoreHighlighterMetric(dropwizardMetric, coreName, metricName, cloudMode); } case "INDEX": { - return new SolrCoreIndexMetric(dropwizardMetric, coreName, metricName); + return new SolrCoreIndexMetric(dropwizardMetric, coreName, metricName, cloudMode); } case "CORE": default: { - return new SolrCoreNoOpMetric(dropwizardMetric, coreName, metricName); + return new SolrCoreNoOpMetric(dropwizardMetric, coreName, metricName, cloudMode); } } } 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.java index 472fc356792..3501510c1d2 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 @@ -180,14 +180,16 @@ public static void toPrometheusRegistry( List parsedRegistry = new ArrayList<>( Arrays.asList(rawParsedRegistry)); String coreName; + boolean cloudMode = false; if (parsedRegistry.size() == 3) { coreName = parsedRegistry.get(2); } else if (parsedRegistry.size() == 5) { coreName = parsedRegistry.stream().skip(1).collect(Collectors.joining("_")); + cloudMode = true; } else { coreName = registryName; } - SolrPrometheusCoreRegistry solrPrometheusCoreMetrics = new SolrPrometheusCoreRegistry(new PrometheusRegistry(), coreName); + SolrPrometheusCoreRegistry solrPrometheusCoreMetrics = new SolrPrometheusCoreRegistry(new PrometheusRegistry(), coreName, cloudMode); Map> categories = new HashMap<>(); toMaps( From 7d11332d95bdd625231ef243d1c477793ef90eb9 Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Mon, 15 Apr 2024 16:15:38 -0400 Subject: [PATCH 17/25] gradlew tidy --- .../java/org/apache/solr/core/SolrCore.java | 18 +- .../solr/handler/admin/MetricsHandler.java | 60 +++---- .../prometheus/SolrCoreCacheMetric.java | 43 +++-- .../prometheus/SolrCoreHandlerMetric.java | 84 ++++----- .../prometheus/SolrCoreHighlighterMetric.java | 41 +++-- .../prometheus/SolrCoreIndexMetric.java | 39 ++-- .../metrics/prometheus/SolrCoreMetric.java | 38 ++-- .../prometheus/SolrCoreNoOpMetric.java | 25 ++- .../prometheus/SolrCoreSearcherMetric.java | 56 +++--- .../prometheus/SolrCoreTlogMetric.java | 46 +++-- .../SolrPrometheusCoreRegistry.java | 102 +++++------ .../prometheus/SolrPrometheusRegistry.java | 167 ++++++++++-------- .../response/PrometheusResponseWriter.java | 59 +++---- .../apache/solr/util/stats/MetricUtils.java | 107 +++++------ 14 files changed, 451 insertions(+), 434 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java index 3179461e02f..598b41de020 100644 --- a/solr/core/src/java/org/apache/solr/core/SolrCore.java +++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java @@ -123,7 +123,23 @@ import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.request.SolrRequestHandler; import org.apache.solr.request.SolrRequestInfo; -import org.apache.solr.response.*; +import org.apache.solr.response.BinaryResponseWriter; +import org.apache.solr.response.CSVResponseWriter; +import org.apache.solr.response.CborResponseWriter; +import org.apache.solr.response.GeoJSONResponseWriter; +import org.apache.solr.response.GraphMLResponseWriter; +import org.apache.solr.response.JacksonJsonWriter; +import org.apache.solr.response.PHPResponseWriter; +import org.apache.solr.response.PHPSerializedResponseWriter; +import org.apache.solr.response.PrometheusResponseWriter; +import org.apache.solr.response.PythonResponseWriter; +import org.apache.solr.response.QueryResponseWriter; +import org.apache.solr.response.RawResponseWriter; +import org.apache.solr.response.RubyResponseWriter; +import org.apache.solr.response.SchemaXmlResponseWriter; +import org.apache.solr.response.SmileResponseWriter; +import org.apache.solr.response.SolrQueryResponse; +import org.apache.solr.response.XMLResponseWriter; import org.apache.solr.response.transform.TransformerFactory; import org.apache.solr.rest.ManagedResourceStorage; import org.apache.solr.rest.ManagedResourceStorage.StorageIO; 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.java index ba716926fbe..466752e0a0a 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 @@ -38,10 +38,6 @@ import java.util.function.Predicate; import java.util.regex.Pattern; import java.util.stream.Collectors; - -import io.prometheus.metrics.core.metrics.Summary; -import io.prometheus.metrics.model.registry.PrometheusRegistry; -import io.prometheus.metrics.model.snapshots.Unit; import org.apache.solr.common.MapWriter; import org.apache.solr.common.SolrException; import org.apache.solr.common.params.CommonParams; @@ -123,7 +119,7 @@ public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throw } private void handleRequest(SolrParams params, BiConsumer consumer) - throws Exception { + throws Exception { NamedList response; if (!enabled) { @@ -152,16 +148,16 @@ private void handleRequest(SolrParams params, BiConsumer consume response = handleDropwizardRegistry(params, requestedRegistries); consumer.accept("metrics", response); - } - private NamedList handleDropwizardRegistry(SolrParams params, Set requestedRegistries) { + private NamedList handleDropwizardRegistry( + SolrParams params, Set requestedRegistries) { boolean compact = params.getBool(COMPACT_PARAM, true); MetricFilter mustMatchFilter = parseMustMatchFilter(params); Predicate propertyFilter = parsePropertyFilter(params); List metricTypes = parseMetricTypes(params); List metricFilters = - metricTypes.stream().map(MetricType::asMetricFilter).collect(Collectors.toList()); + metricTypes.stream().map(MetricType::asMetricFilter).collect(Collectors.toList()); metricTypes.stream().map(MetricType::asMetricFilter).collect(Collectors.toList()); NamedList response = new SimpleOrderedMap<>(); @@ -170,15 +166,15 @@ private NamedList handleDropwizardRegistry(SolrParams params, Set result = new SimpleOrderedMap<>(); MetricUtils.toMaps( - registry, - metricFilters, - mustMatchFilter, - propertyFilter, - false, - false, - compact, - false, - (k, v) -> result.add(k, v)); + registry, + metricFilters, + mustMatchFilter, + propertyFilter, + false, + false, + compact, + false, + (k, v) -> result.add(k, v)); if (result.size() > 0) { response.add(registryName, result); } @@ -186,33 +182,33 @@ private NamedList handleDropwizardRegistry(SolrParams params, Set handlePrometheusRegistry(SolrParams params, Set requestedRegistries) { + private NamedList handlePrometheusRegistry( + SolrParams params, Set requestedRegistries) { NamedList response = new SimpleOrderedMap<>(); boolean compact = params.getBool(COMPACT_PARAM, true); MetricFilter mustMatchFilter = parseMustMatchFilter(params); Predicate propertyFilter = parsePropertyFilter(params); List metricTypes = parseMetricTypes(params); List metricFilters = - metricTypes.stream().map(MetricType::asMetricFilter).collect(Collectors.toList()); + metricTypes.stream().map(MetricType::asMetricFilter).collect(Collectors.toList()); for (String registryName : requestedRegistries) { MetricRegistry dropWizardRegistry = metricManager.registry(registryName); // Currently only export Solr Core registries - if ( registryName.startsWith("solr.core") ) { + if (registryName.startsWith("solr.core")) { MetricUtils.toPrometheusRegistry( - dropWizardRegistry, - registryName, - metricFilters, - mustMatchFilter, - propertyFilter, - false, - false, - compact, - (registry) -> { - response.add(registryName, registry); - }); + dropWizardRegistry, + registryName, + metricFilters, + mustMatchFilter, + propertyFilter, + false, + false, + compact, + (registry) -> { + response.add(registryName, registry); + }); } - } return response; } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java index 8d8193f45bd..8a2e33b40de 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java @@ -3,32 +3,31 @@ import com.codahale.metrics.Gauge; import com.codahale.metrics.Metric; -import java.util.HashMap; -import java.util.Map; - public class SolrCoreCacheMetric extends SolrCoreMetric { - public static final String CORE_CACHE_SEARCHER_METRICS = "solr_metrics_core_cache_gauge"; + public static final String CORE_CACHE_SEARCHER_METRICS = "solr_metrics_core_cache_gauge"; - public SolrCoreCacheMetric(Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { - super(dropwizardMetric, coreName, metricName, cloudMode); - } + public SolrCoreCacheMetric( + Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { + super(dropwizardMetric, coreName, metricName, cloudMode); + } - @Override - public SolrCoreMetric parseLabels() { - String[] parsedMetric = metricName.split("\\."); - if (dropwizardMetric instanceof Gauge) { - String cacheType = parsedMetric[2]; - labels.put("cacheType", cacheType); - } - return this; + @Override + public SolrCoreMetric parseLabels() { + String[] parsedMetric = metricName.split("\\."); + if (dropwizardMetric instanceof Gauge) { + String cacheType = parsedMetric[2]; + labels.put("cacheType", cacheType); } + return this; + } - @Override - void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { - if (dropwizardMetric instanceof Gauge) { - solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_CACHE_SEARCHER_METRICS, labels); - } else { - System.out.println("This Metric does not exist"); - } + @Override + void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + if (dropwizardMetric instanceof Gauge) { + solrPrometheusCoreRegistry.exportGauge( + (Gauge) dropwizardMetric, CORE_CACHE_SEARCHER_METRICS, labels); + } else { + System.out.println("This Metric does not exist"); } + } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java index 19ada8b738a..2f8b93cc4dd 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java @@ -5,49 +5,51 @@ import com.codahale.metrics.Meter; import com.codahale.metrics.Metric; -import java.util.HashMap; -import java.util.Map; - public class SolrCoreHandlerMetric extends SolrCoreMetric { - public static final String CORE_REQUESTS_TOTAL = "solr_metrics_core_requests_total"; - public static final String CORE_REQUESTS_TOTAL_TIME = "solr_metrics_core_requests_total_time"; - public static final String CORE_HANDLER_HANDLER_START = "solr_metrics_core_handler_start"; - public static final String CORE_UPDATE_HANDLER = "solr_metrics_core_update_handler_metrics"; - public SolrCoreHandlerMetric(Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { - super(dropwizardMetric, coreName, metricName, cloudMode); - } + public static final String CORE_REQUESTS_TOTAL = "solr_metrics_core_requests_total"; + public static final String CORE_REQUESTS_TOTAL_TIME = "solr_metrics_core_requests_total_time"; + public static final String CORE_HANDLER_HANDLER_START = "solr_metrics_core_handler_start"; + public static final String CORE_UPDATE_HANDLER = "solr_metrics_core_update_handler_metrics"; - @Override - public SolrCoreMetric parseLabels() { - String[] parsedMetric = metricName.split("\\."); - String category = parsedMetric[0]; - String handler = parsedMetric[1]; - String type = parsedMetric[2]; - labels.put("category", category); - labels.put("handler", handler); - labels.put("type", type); - return this; - } + public SolrCoreHandlerMetric( + Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { + super(dropwizardMetric, coreName, metricName, cloudMode); + } - @Override - public void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { - if (dropwizardMetric instanceof Meter) { - solrPrometheusCoreRegistry.exportMeter((Meter) dropwizardMetric, CORE_REQUESTS_TOTAL, labels); - } else if (dropwizardMetric instanceof Counter) { - if (metricName.endsWith("requests")) { - solrPrometheusCoreRegistry.exportCounter((Counter) dropwizardMetric, CORE_REQUESTS_TOTAL, labels); - } else if (metricName.endsWith("totalTime")) { - solrPrometheusCoreRegistry.exportCounter((Counter) dropwizardMetric, CORE_REQUESTS_TOTAL_TIME, labels); - } - } else if (dropwizardMetric instanceof Gauge) { - if (metricName.endsWith("handlerStart")) { - solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_HANDLER_HANDLER_START, labels); - } else { - solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_UPDATE_HANDLER, labels); - } - } else { - System.out.println("This Metric does not exist"); - } - } + @Override + public SolrCoreMetric parseLabels() { + String[] parsedMetric = metricName.split("\\."); + String category = parsedMetric[0]; + String handler = parsedMetric[1]; + String type = parsedMetric[2]; + labels.put("category", category); + labels.put("handler", handler); + labels.put("type", type); + return this; + } + @Override + public void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + if (dropwizardMetric instanceof Meter) { + solrPrometheusCoreRegistry.exportMeter((Meter) dropwizardMetric, CORE_REQUESTS_TOTAL, labels); + } else if (dropwizardMetric instanceof Counter) { + if (metricName.endsWith("requests")) { + solrPrometheusCoreRegistry.exportCounter( + (Counter) dropwizardMetric, CORE_REQUESTS_TOTAL, labels); + } else if (metricName.endsWith("totalTime")) { + solrPrometheusCoreRegistry.exportCounter( + (Counter) dropwizardMetric, CORE_REQUESTS_TOTAL_TIME, labels); + } + } else if (dropwizardMetric instanceof Gauge) { + if (metricName.endsWith("handlerStart")) { + solrPrometheusCoreRegistry.exportGauge( + (Gauge) dropwizardMetric, CORE_HANDLER_HANDLER_START, labels); + } else { + solrPrometheusCoreRegistry.exportGauge( + (Gauge) dropwizardMetric, CORE_UPDATE_HANDLER, labels); + } + } else { + System.out.println("This Metric does not exist"); + } + } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java index f18b3c5af42..dc2feb37566 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java @@ -3,30 +3,29 @@ import com.codahale.metrics.Counter; import com.codahale.metrics.Metric; -import java.util.HashMap; -import java.util.Map; - public class SolrCoreHighlighterMetric extends SolrCoreMetric { - public static final String CORE_HIGHLIGHER_METRICS = "solr_metrics_core_highlighter_requests"; + public static final String CORE_HIGHLIGHER_METRICS = "solr_metrics_core_highlighter_requests"; - public SolrCoreHighlighterMetric(Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { - super(dropwizardMetric, coreName, metricName, cloudMode); - } + public SolrCoreHighlighterMetric( + Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { + super(dropwizardMetric, coreName, metricName, cloudMode); + } - @Override - public SolrCoreMetric parseLabels() { - String[] parsedMetric = metricName.split("\\."); - String type = parsedMetric[1]; - String item = parsedMetric[2]; - labels.put("type", type); - labels.put("item", item); - return this; - } + @Override + public SolrCoreMetric parseLabels() { + String[] parsedMetric = metricName.split("\\."); + String type = parsedMetric[1]; + String item = parsedMetric[2]; + labels.put("type", type); + labels.put("item", item); + return this; + } - @Override - void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { - if (dropwizardMetric instanceof Counter) { - solrPrometheusCoreRegistry.exportCounter((Counter) dropwizardMetric, CORE_HIGHLIGHER_METRICS, labels); - } + @Override + void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + if (dropwizardMetric instanceof Counter) { + solrPrometheusCoreRegistry.exportCounter( + (Counter) dropwizardMetric, CORE_HIGHLIGHER_METRICS, labels); } + } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java index 85f25c48c27..bee09ad71c4 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java @@ -3,30 +3,29 @@ import com.codahale.metrics.Gauge; import com.codahale.metrics.Metric; -import java.util.HashMap; -import java.util.Map; - public class SolrCoreIndexMetric extends SolrCoreMetric { - public static final String CORE_INDEX_METRICS = "solr_metrics_index"; + public static final String CORE_INDEX_METRICS = "solr_metrics_index"; - public SolrCoreIndexMetric(Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { - super(dropwizardMetric, coreName, metricName, cloudMode); - } + public SolrCoreIndexMetric( + Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { + super(dropwizardMetric, coreName, metricName, cloudMode); + } - @Override - public SolrCoreMetric parseLabels() { - if (dropwizardMetric instanceof Gauge) { - String[] parsedMetric = metricName.split("\\."); - String type = parsedMetric[1]; - labels.put("type", type); - } - return this; + @Override + public SolrCoreMetric parseLabels() { + if (dropwizardMetric instanceof Gauge) { + String[] parsedMetric = metricName.split("\\."); + String type = parsedMetric[1]; + labels.put("type", type); } + return this; + } - @Override - void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { - if (dropwizardMetric instanceof Gauge) { - solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_INDEX_METRICS, labels); - } + @Override + void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + if (dropwizardMetric instanceof Gauge) { + solrPrometheusCoreRegistry.exportGauge( + (Gauge) dropwizardMetric, CORE_INDEX_METRICS, labels); } + } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java index 3cd34182057..499079eec69 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java @@ -1,28 +1,30 @@ package org.apache.solr.metrics.prometheus; import com.codahale.metrics.Metric; - import java.util.HashMap; import java.util.Map; public abstract class SolrCoreMetric { - public Metric dropwizardMetric; - public String coreName; - public String metricName; - public Map labels = new HashMap<>(); + public Metric dropwizardMetric; + public String coreName; + public String metricName; + public Map labels = new HashMap<>(); - public SolrCoreMetric(Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { - this.dropwizardMetric = dropwizardMetric; - this.coreName = coreName; - 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]); - } + public SolrCoreMetric( + Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { + this.dropwizardMetric = dropwizardMetric; + this.coreName = coreName; + 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]); } - abstract SolrCoreMetric parseLabels(); - abstract void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry); + } + + abstract SolrCoreMetric parseLabels(); + + abstract void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry); } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java index 41d5ed30b16..ed9d6044e8f 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java @@ -2,21 +2,20 @@ import com.codahale.metrics.Metric; -import java.util.Map; - public class SolrCoreNoOpMetric extends SolrCoreMetric { - public SolrCoreNoOpMetric(Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { - super(dropwizardMetric, coreName, metricName, cloudMode); - } + public SolrCoreNoOpMetric( + Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { + super(dropwizardMetric, coreName, metricName, cloudMode); + } - @Override - public SolrCoreMetric parseLabels() { - return this; - } + @Override + public SolrCoreMetric parseLabels() { + return this; + } - @Override - void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { - System.out.println("Cannot export string metrics"); - } + @Override + void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + System.out.println("Cannot export string metrics"); + } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java index a88e964ff5f..be84cf67a8b 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java @@ -1,40 +1,40 @@ package org.apache.solr.metrics.prometheus; +import static org.apache.solr.metrics.prometheus.SolrCoreCacheMetric.CORE_CACHE_SEARCHER_METRICS; + import com.codahale.metrics.Gauge; import com.codahale.metrics.Metric; -import java.util.HashMap; -import java.util.Map; - -import static org.apache.solr.metrics.prometheus.SolrCoreCacheMetric.CORE_CACHE_SEARCHER_METRICS; - public class SolrCoreSearcherMetric extends SolrCoreMetric { - public static final String CORE_SEARCHER_METRICS = "solr_metrics_core_searcher"; + public static final String CORE_SEARCHER_METRICS = "solr_metrics_core_searcher"; - public SolrCoreSearcherMetric(Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { - super(dropwizardMetric, coreName, metricName, cloudMode); - } + public SolrCoreSearcherMetric( + Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { + super(dropwizardMetric, coreName, metricName, cloudMode); + } - @Override - public SolrCoreMetric parseLabels() { - String[] parsedMetric = metricName.split("\\."); - if (dropwizardMetric instanceof Gauge) { - String type = parsedMetric[2]; - labels.put("type", type); - } - return this; + @Override + public SolrCoreMetric parseLabels() { + String[] parsedMetric = metricName.split("\\."); + if (dropwizardMetric instanceof Gauge) { + String type = parsedMetric[2]; + labels.put("type", type); } + return this; + } - @Override - void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { - if (dropwizardMetric instanceof Gauge) { - if (metricName.endsWith("liveDocsCache")) { - solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_CACHE_SEARCHER_METRICS, labels); - } else { - solrPrometheusCoreRegistry.exportGauge((Gauge) dropwizardMetric, CORE_SEARCHER_METRICS, labels); - } - } else { - System.out.println("This metric does not exist"); - } + @Override + void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + if (dropwizardMetric instanceof Gauge) { + if (metricName.endsWith("liveDocsCache")) { + solrPrometheusCoreRegistry.exportGauge( + (Gauge) dropwizardMetric, CORE_CACHE_SEARCHER_METRICS, labels); + } else { + solrPrometheusCoreRegistry.exportGauge( + (Gauge) dropwizardMetric, CORE_SEARCHER_METRICS, labels); + } + } else { + System.out.println("This metric does not exist"); } + } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java index 837c5b9455c..ae4fc205fbb 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java @@ -3,34 +3,32 @@ import com.codahale.metrics.Meter; import com.codahale.metrics.Metric; -import java.util.HashMap; -import java.util.Map; - public class SolrCoreTlogMetric extends SolrCoreMetric { - public static final String CORE_TLOG_METRICS = "solr_metrics_tlog_replicas"; + public static final String CORE_TLOG_METRICS = "solr_metrics_tlog_replicas"; - public SolrCoreTlogMetric(Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { - super(dropwizardMetric, coreName, metricName, cloudMode); - } + public SolrCoreTlogMetric( + Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { + super(dropwizardMetric, coreName, metricName, cloudMode); + } - @Override - public SolrCoreMetric parseLabels() { - String[] parsedMetric = metricName.split("\\."); - if (dropwizardMetric instanceof Meter) { - String item = parsedMetric[1]; - String type = parsedMetric[2]; - labels.put("item", item); - labels.put("type", type); - } - return this; + @Override + public SolrCoreMetric parseLabels() { + String[] parsedMetric = metricName.split("\\."); + if (dropwizardMetric instanceof Meter) { + String item = parsedMetric[1]; + String type = parsedMetric[2]; + labels.put("item", item); + labels.put("type", type); } + return this; + } - @Override - public void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { - if (dropwizardMetric instanceof Meter) { - solrPrometheusCoreRegistry.exportMeter((Meter) dropwizardMetric, CORE_TLOG_METRICS, labels); - } else { - System.out.println("Not possible to migrate string values to prometheus"); - } + @Override + public void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + if (dropwizardMetric instanceof Meter) { + solrPrometheusCoreRegistry.exportMeter((Meter) dropwizardMetric, CORE_TLOG_METRICS, labels); + } else { + System.out.println("Not possible to migrate string values to prometheus"); } + } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java index fa2700915c6..0c4bd25ddbb 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java @@ -1,57 +1,59 @@ package org.apache.solr.metrics.prometheus; -import com.codahale.metrics.*; +import com.codahale.metrics.Metric; import io.prometheus.metrics.model.registry.PrometheusRegistry; -import java.util.HashMap; -import java.util.Map; - public class SolrPrometheusCoreRegistry extends SolrPrometheusRegistry { - public final String coreName; - public final boolean cloudMode; - - - public SolrPrometheusCoreRegistry(PrometheusRegistry prometheusRegistry, String coreName, boolean cloudMode) { - super(prometheusRegistry); - this.coreName = coreName; - this.cloudMode = cloudMode; - - } - - public void exportDropwizardMetric(String metricName, Metric dropwizardMetric) { - SolrCoreMetric solrCoreMetric = categorizeCorePrefix(dropwizardMetric, metricName); - solrCoreMetric.parseLabels().toPrometheus(this); - } - - private SolrCoreMetric categorizeCorePrefix(Metric dropwizardMetric, String metricName) { - String metricCategory = metricName.split("\\.")[0]; - switch (metricCategory) { - case "ADMIN": - case "QUERY": - case "UPDATE": - case "REPLICATION": { - return new SolrCoreHandlerMetric(dropwizardMetric, coreName, metricName, cloudMode); - } - case "TLOG": { - return new SolrCoreTlogMetric(dropwizardMetric, coreName, metricName, cloudMode); - } - case "CACHE": { - return new SolrCoreCacheMetric(dropwizardMetric, coreName, metricName, cloudMode); - } - case "SEARCHER":{ - return new SolrCoreSearcherMetric(dropwizardMetric, coreName, metricName, cloudMode); - } - case "HIGHLIGHTER": { - return new SolrCoreHighlighterMetric(dropwizardMetric, coreName, metricName, cloudMode); - } - case "INDEX": { - return new SolrCoreIndexMetric(dropwizardMetric, coreName, metricName, cloudMode); - } - case "CORE": - default: { - return new SolrCoreNoOpMetric(dropwizardMetric, coreName, metricName, cloudMode); - } + public final String coreName; + public final boolean cloudMode; + + public SolrPrometheusCoreRegistry( + PrometheusRegistry prometheusRegistry, String coreName, boolean cloudMode) { + super(prometheusRegistry); + this.coreName = coreName; + this.cloudMode = cloudMode; + } + + public void exportDropwizardMetric(String metricName, Metric dropwizardMetric) { + SolrCoreMetric solrCoreMetric = categorizeCorePrefix(dropwizardMetric, metricName); + solrCoreMetric.parseLabels().toPrometheus(this); + } + + private SolrCoreMetric categorizeCorePrefix(Metric dropwizardMetric, String metricName) { + String metricCategory = metricName.split("\\.")[0]; + switch (metricCategory) { + case "ADMIN": + case "QUERY": + case "UPDATE": + case "REPLICATION": + { + return new SolrCoreHandlerMetric(dropwizardMetric, coreName, metricName, cloudMode); + } + case "TLOG": + { + return new SolrCoreTlogMetric(dropwizardMetric, coreName, metricName, cloudMode); + } + case "CACHE": + { + return new SolrCoreCacheMetric(dropwizardMetric, coreName, metricName, cloudMode); + } + case "SEARCHER": + { + return new SolrCoreSearcherMetric(dropwizardMetric, coreName, metricName, cloudMode); + } + case "HIGHLIGHTER": + { + return new SolrCoreHighlighterMetric(dropwizardMetric, coreName, metricName, cloudMode); + } + case "INDEX": + { + return new SolrCoreIndexMetric(dropwizardMetric, coreName, metricName, cloudMode); + } + case "CORE": + default: + { + return new SolrCoreNoOpMetric(dropwizardMetric, coreName, metricName, cloudMode); } } - -} \ No newline at end of file + } +} diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java index f45def6d939..6943a1b7ccc 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java @@ -4,99 +4,114 @@ import io.prometheus.metrics.core.metrics.Counter; import io.prometheus.metrics.core.metrics.Gauge; import io.prometheus.metrics.model.registry.PrometheusRegistry; - import java.util.ArrayList; import java.util.HashMap; import java.util.Map; public abstract class SolrPrometheusRegistry { - PrometheusRegistry prometheusRegistry; - String registryName; - private final Map metricCounters; - private final Map metricGauges; + PrometheusRegistry prometheusRegistry; + String registryName; + private final Map metricCounters; + private final Map metricGauges; - public SolrPrometheusRegistry(PrometheusRegistry prometheusRegistry) { - this.prometheusRegistry = prometheusRegistry; - this.metricCounters = new HashMap<>(); - this.metricGauges = new HashMap<>(); - } + public SolrPrometheusRegistry(PrometheusRegistry prometheusRegistry) { + this.prometheusRegistry = prometheusRegistry; + this.metricCounters = new HashMap<>(); + this.metricGauges = new HashMap<>(); + } - public PrometheusRegistry getPrometheusRegistry() { - return prometheusRegistry; - } + public PrometheusRegistry getPrometheusRegistry() { + return prometheusRegistry; + } - public String getRegistryName() { - return registryName; - } + public String getRegistryName() { + return registryName; + } - public Counter getMetricCounter(String metricName) { - return metricCounters.get(metricName); - } + public Counter getMetricCounter(String metricName) { + return metricCounters.get(metricName); + } - public Gauge getMetricGauge(String metricName) { - return metricGauges.get(metricName); - } + public Gauge getMetricGauge(String metricName) { + return metricGauges.get(metricName); + } - protected void registerCounter(String metricName, String ...labelNames) { - Counter counter = io.prometheus.metrics.core.metrics.Counter.builder() - .name(metricName) - .labelNames(labelNames) - .register(prometheusRegistry); - metricCounters.put(metricName, counter); - } + protected void registerCounter(String metricName, String... labelNames) { + Counter counter = + io.prometheus.metrics.core.metrics.Counter.builder() + .name(metricName) + .labelNames(labelNames) + .register(prometheusRegistry); + metricCounters.put(metricName, counter); + } - protected void registerGauge(String metricName, String ...labelNames) { - Gauge gauge = io.prometheus.metrics.core.metrics.Gauge.builder() - .name(metricName) - .labelNames(labelNames) - .register(prometheusRegistry); - metricGauges.put(metricName, gauge); - } + protected void registerGauge(String metricName, String... labelNames) { + Gauge gauge = + io.prometheus.metrics.core.metrics.Gauge.builder() + .name(metricName) + .labelNames(labelNames) + .register(prometheusRegistry); + metricGauges.put(metricName, gauge); + } - protected void exportMeter(Meter dropwizardMetric, String prometheusMetricName, Map labelsMap) { - if (!metricCounters.containsKey(prometheusMetricName)) { - ArrayList labels = new ArrayList<>(labelsMap.keySet()); - registerCounter(prometheusMetricName, labels.toArray(String[]::new)); - } - ArrayList labelValues = new ArrayList<>(labelsMap.values()); - getMetricCounter(prometheusMetricName).labelValues(labelValues.toArray(String[]::new)).inc(dropwizardMetric.getCount()); + protected void exportMeter( + Meter dropwizardMetric, String prometheusMetricName, Map labelsMap) { + if (!metricCounters.containsKey(prometheusMetricName)) { + ArrayList labels = new ArrayList<>(labelsMap.keySet()); + registerCounter(prometheusMetricName, labels.toArray(String[]::new)); } + ArrayList labelValues = new ArrayList<>(labelsMap.values()); + getMetricCounter(prometheusMetricName) + .labelValues(labelValues.toArray(String[]::new)) + .inc(dropwizardMetric.getCount()); + } - protected void exportCounter(com.codahale.metrics.Counter dropwizardMetric, String prometheusMetricName, Map labelsMap) { - if (!metricCounters.containsKey(prometheusMetricName)) { - ArrayList labels = new ArrayList<>(labelsMap.keySet()); - registerCounter(prometheusMetricName, labels.toArray(String[]::new)); - } - ArrayList labelValues = new ArrayList<>(labelsMap.values()); - getMetricCounter(prometheusMetricName).labelValues(labelValues.toArray(String[]::new)).inc(dropwizardMetric.getCount()); + protected void exportCounter( + com.codahale.metrics.Counter dropwizardMetric, + String prometheusMetricName, + Map labelsMap) { + if (!metricCounters.containsKey(prometheusMetricName)) { + ArrayList labels = new ArrayList<>(labelsMap.keySet()); + registerCounter(prometheusMetricName, labels.toArray(String[]::new)); } + ArrayList labelValues = new ArrayList<>(labelsMap.values()); + getMetricCounter(prometheusMetricName) + .labelValues(labelValues.toArray(String[]::new)) + .inc(dropwizardMetric.getCount()); + } - protected void exportGauge(com.codahale.metrics.Gauge dropwizardMetricRaw, String prometheusMetricName, Map labelsMap) { - Object dropwizardMetric = (dropwizardMetricRaw).getValue(); - if (!metricGauges.containsKey(prometheusMetricName)) { - ArrayList labels = new ArrayList<>(labelsMap.keySet()); - if (dropwizardMetric instanceof HashMap) { - labels.add("item"); - } - registerGauge(prometheusMetricName, labels.toArray(String[]::new)); - } - ArrayList labelValues = new ArrayList<>(labelsMap.values()); - String[] labels = labelValues.toArray(String[]::new); - if (dropwizardMetric instanceof Number) { - getMetricGauge(prometheusMetricName).labelValues(labels).set(((Number) dropwizardMetric).doubleValue()); - } else if (dropwizardMetric instanceof HashMap) { - HashMap itemsMap = (HashMap) dropwizardMetric; - for (Object item : itemsMap.keySet()) { - if (itemsMap.get(item) instanceof Number) { - String[] newLabels = new String[labels.length + 1]; - System.arraycopy(labels, 0, newLabels, 0, labels.length); - newLabels[labels.length] = (String) item; - getMetricGauge(prometheusMetricName).labelValues(newLabels).set(((Number) itemsMap.get(item)).doubleValue()); - } else { - System.out.println("This is not an number"); - } - } + protected void exportGauge( + com.codahale.metrics.Gauge dropwizardMetricRaw, + String prometheusMetricName, + Map labelsMap) { + Object dropwizardMetric = (dropwizardMetricRaw).getValue(); + if (!metricGauges.containsKey(prometheusMetricName)) { + ArrayList labels = new ArrayList<>(labelsMap.keySet()); + if (dropwizardMetric instanceof HashMap) { + labels.add("item"); + } + registerGauge(prometheusMetricName, labels.toArray(String[]::new)); + } + ArrayList labelValues = new ArrayList<>(labelsMap.values()); + String[] labels = labelValues.toArray(String[]::new); + if (dropwizardMetric instanceof Number) { + getMetricGauge(prometheusMetricName) + .labelValues(labels) + .set(((Number) dropwizardMetric).doubleValue()); + } else if (dropwizardMetric instanceof HashMap) { + HashMap itemsMap = (HashMap) dropwizardMetric; + for (Object item : itemsMap.keySet()) { + if (itemsMap.get(item) instanceof Number) { + String[] newLabels = new String[labels.length + 1]; + System.arraycopy(labels, 0, newLabels, 0, labels.length); + newLabels[labels.length] = (String) item; + getMetricGauge(prometheusMetricName) + .labelValues(newLabels) + .set(((Number) itemsMap.get(item)).doubleValue()); + } else { + System.out.println("This is not an number"); } + } } - + } } diff --git a/solr/core/src/java/org/apache/solr/response/PrometheusResponseWriter.java b/solr/core/src/java/org/apache/solr/response/PrometheusResponseWriter.java index 033c1fa46dd..4f34e9eb176 100644 --- a/solr/core/src/java/org/apache/solr/response/PrometheusResponseWriter.java +++ b/solr/core/src/java/org/apache/solr/response/PrometheusResponseWriter.java @@ -1,46 +1,31 @@ package org.apache.solr.response; -import io.prometheus.client.CollectorRegistry; - -import io.prometheus.metrics.expositionformats.TextFormatUtil; +import io.prometheus.metrics.expositionformats.PrometheusTextFormatWriter; import io.prometheus.metrics.model.registry.PrometheusRegistry; -import io.prometheus.metrics.model.snapshots.MetricSnapshots; -import org.apache.solr.common.SolrException; -import org.apache.solr.common.params.SolrParams; -import org.apache.solr.common.util.NamedList; -import org.apache.solr.common.util.SimpleOrderedMap; -import org.apache.solr.handler.admin.MetricsHandler; -import org.apache.solr.request.SolrQueryRequest; -import org.w3c.dom.Text; - import java.io.IOException; import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.util.Iterator; import java.util.Map; -import java.util.Set; - -import io.prometheus.metrics.expositionformats.PrometheusTextFormatWriter; +import org.apache.solr.common.util.NamedList; +import org.apache.solr.request.SolrQueryRequest; -@SuppressWarnings (value="unchecked") +@SuppressWarnings(value = "unchecked") public class PrometheusResponseWriter extends RawResponseWriter { - @Override - public void write(OutputStream out, SolrQueryRequest request, SolrQueryResponse response) - throws IOException { - - NamedList prometheusRegistries = (NamedList) response.getValues().get("metrics"); - Map registryMap = prometheusRegistries.asShallowMap(); - PrometheusTextFormatWriter prometheusTextFormatWriter = new PrometheusTextFormatWriter(false); - registryMap.forEach((name, registry) -> { - try { - PrometheusRegistry prometheusRegistry = (PrometheusRegistry) registry; - prometheusTextFormatWriter.write(out, prometheusRegistry.scrape()); - } catch (IOException e) { - throw new RuntimeException(e); - } + @Override + public void write(OutputStream out, SolrQueryRequest request, SolrQueryResponse response) + throws IOException { + + NamedList prometheusRegistries = + (NamedList) response.getValues().get("metrics"); + Map registryMap = prometheusRegistries.asShallowMap(); + PrometheusTextFormatWriter prometheusTextFormatWriter = new PrometheusTextFormatWriter(false); + registryMap.forEach( + (name, registry) -> { + try { + PrometheusRegistry prometheusRegistry = (PrometheusRegistry) registry; + prometheusTextFormatWriter.write(out, prometheusRegistry.scrape()); + } catch (IOException e) { + throw new RuntimeException(e); + } }); - - } - -} \ No newline at end of file + } +} 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.java index 3501510c1d2..0c3830a3f3a 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 @@ -26,6 +26,7 @@ import com.codahale.metrics.MetricRegistry; import com.codahale.metrics.Snapshot; import com.codahale.metrics.Timer; +import io.prometheus.metrics.model.registry.PrometheusRegistry; import java.beans.BeanInfo; import java.beans.IntrospectionException; import java.beans.Introspector; @@ -35,15 +36,19 @@ import java.lang.management.OperatingSystemMXBean; import java.lang.management.PlatformManagedObject; import java.lang.reflect.InvocationTargetException; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.SortedSet; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.stream.Collectors; - -import io.prometheus.metrics.model.registry.PrometheusRegistry; import org.apache.solr.common.ConditionalKeyMapWriter; import org.apache.solr.common.IteratorWriter; import org.apache.solr.common.MapWriter; @@ -165,57 +170,57 @@ public static void toSolrInputDocuments( }); } - public static void toPrometheusRegistry( - MetricRegistry registry, - String registryName, - List shouldMatchFilters, - MetricFilter mustMatchFilter, - Predicate propertyFilter, - boolean skipHistograms, - boolean skipAggregateValues, - boolean compact, - Consumer consumer) { - Map dropwizardMetrics = registry.getMetrics(); - String[]rawParsedRegistry = registryName.split("\\."); - List parsedRegistry = new ArrayList<>( - Arrays.asList(rawParsedRegistry)); - String coreName; - boolean cloudMode = false; - if (parsedRegistry.size() == 3) { - coreName = parsedRegistry.get(2); - } else if (parsedRegistry.size() == 5) { - coreName = parsedRegistry.stream().skip(1).collect(Collectors.joining("_")); - cloudMode = true; - } else { - coreName = registryName; - } - SolrPrometheusCoreRegistry solrPrometheusCoreMetrics = new SolrPrometheusCoreRegistry(new PrometheusRegistry(), coreName, cloudMode); + public static void toPrometheusRegistry( + MetricRegistry registry, + String registryName, + List shouldMatchFilters, + MetricFilter mustMatchFilter, + Predicate propertyFilter, + boolean skipHistograms, + boolean skipAggregateValues, + boolean compact, + Consumer consumer) { + Map dropwizardMetrics = registry.getMetrics(); + String[] rawParsedRegistry = registryName.split("\\."); + List parsedRegistry = new ArrayList<>(Arrays.asList(rawParsedRegistry)); + String coreName; + boolean cloudMode = false; + if (parsedRegistry.size() == 3) { + coreName = parsedRegistry.get(2); + } else if (parsedRegistry.size() == 5) { + coreName = parsedRegistry.stream().skip(1).collect(Collectors.joining("_")); + cloudMode = true; + } else { + coreName = registryName; + } + SolrPrometheusCoreRegistry solrPrometheusCoreMetrics = + new SolrPrometheusCoreRegistry(new PrometheusRegistry(), coreName, cloudMode); - Map> categories = new HashMap<>(); - toMaps( - registry, - shouldMatchFilters, - mustMatchFilter, - propertyFilter, - skipHistograms, - skipAggregateValues, - compact, - false, - (metricName, metric) -> { - Metric dropwizardMetric = dropwizardMetrics.get(metricName); - String[] splitString = metricName.split("\\."); + Map> categories = new HashMap<>(); + toMaps( + registry, + shouldMatchFilters, + mustMatchFilter, + propertyFilter, + skipHistograms, + skipAggregateValues, + compact, + false, + (metricName, metric) -> { + Metric dropwizardMetric = dropwizardMetrics.get(metricName); + String[] splitString = metricName.split("\\."); - if(!categories.containsKey(splitString[0])) { - categories.put(splitString[0], new HashMap<>()); - } - if(!categories.get(splitString[0]).containsKey(metricName)) { - categories.get(splitString[0]).put(metricName, dropwizardMetric); - } + if (!categories.containsKey(splitString[0])) { + categories.put(splitString[0], new HashMap<>()); + } + if (!categories.get(splitString[0]).containsKey(metricName)) { + categories.get(splitString[0]).put(metricName, dropwizardMetric); + } - solrPrometheusCoreMetrics.exportDropwizardMetric(metricName, dropwizardMetric); - }); - consumer.accept(solrPrometheusCoreMetrics.getPrometheusRegistry()); - } + solrPrometheusCoreMetrics.exportDropwizardMetric(metricName, dropwizardMetric); + }); + consumer.accept(solrPrometheusCoreMetrics.getPrometheusRegistry()); + } /** * Fill in a SolrInputDocument with values from a converted metric, recursively. From a3b9d19ef5e8508cf763294733fc022f1a52590c Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Tue, 16 Apr 2024 14:54:02 -0400 Subject: [PATCH 18/25] Introduce timers gauges --- .../prometheus/SolrCoreCacheMetric.java | 5 ++- .../prometheus/SolrCoreHandlerMetric.java | 25 +++++++------- .../prometheus/SolrCoreHighlighterMetric.java | 1 + .../prometheus/SolrCoreIndexMetric.java | 14 ++++---- .../prometheus/SolrCoreNoOpMetric.java | 4 +-- .../prometheus/SolrCoreSearcherMetric.java | 8 +++-- .../prometheus/SolrCoreTlogMetric.java | 6 ++-- .../SolrPrometheusCoreRegistry.java | 34 ++++++++++++------- .../prometheus/SolrPrometheusRegistry.java | 14 ++++++-- .../apache/solr/util/stats/MetricUtils.java | 16 +++------ 10 files changed, 67 insertions(+), 60 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java index 8a2e33b40de..8b21468bf1a 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java @@ -2,9 +2,10 @@ import com.codahale.metrics.Gauge; import com.codahale.metrics.Metric; +import com.codahale.metrics.Timer; public class SolrCoreCacheMetric extends SolrCoreMetric { - public static final String CORE_CACHE_SEARCHER_METRICS = "solr_metrics_core_cache_gauge"; + public static final String CORE_CACHE_SEARCHER_METRICS = "solr_metrics_core_cache"; public SolrCoreCacheMetric( Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { @@ -26,8 +27,6 @@ void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { if (dropwizardMetric instanceof Gauge) { solrPrometheusCoreRegistry.exportGauge( (Gauge) dropwizardMetric, CORE_CACHE_SEARCHER_METRICS, labels); - } else { - System.out.println("This Metric does not exist"); } } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java index 2f8b93cc4dd..9e060a4dcc5 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java @@ -4,12 +4,13 @@ import com.codahale.metrics.Gauge; import com.codahale.metrics.Meter; import com.codahale.metrics.Metric; +import com.codahale.metrics.Timer; public class SolrCoreHandlerMetric extends SolrCoreMetric { - public static final String CORE_REQUESTS_TOTAL = "solr_metrics_core_requests_total"; - public static final String CORE_REQUESTS_TOTAL_TIME = "solr_metrics_core_requests_total_time"; - public static final String CORE_HANDLER_HANDLER_START = "solr_metrics_core_handler_start"; - public static final String CORE_UPDATE_HANDLER = "solr_metrics_core_update_handler_metrics"; + public static final String CORE_REQUESTS_TOTAL = "solr_metrics_core_requests"; + public static final String CORE_REQUESTS_UPDATE_HANDLER = "solr_metrics_core_update_handler"; + public static final String CORE_REQUESTS_TOTAL_TIME = "solr_metrics_core_requests_time"; + public static final String CORE_REQUEST_TIMES = "solr_metrics_core_average_request_time"; public SolrCoreHandlerMetric( Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { @@ -23,8 +24,10 @@ public SolrCoreMetric parseLabels() { String handler = parsedMetric[1]; String type = parsedMetric[2]; labels.put("category", category); - labels.put("handler", handler); labels.put("type", type); + if (!(dropwizardMetric instanceof Gauge)) { + labels.put("handler", handler); + } return this; } @@ -41,15 +44,11 @@ public void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) (Counter) dropwizardMetric, CORE_REQUESTS_TOTAL_TIME, labels); } } else if (dropwizardMetric instanceof Gauge) { - if (metricName.endsWith("handlerStart")) { - solrPrometheusCoreRegistry.exportGauge( - (Gauge) dropwizardMetric, CORE_HANDLER_HANDLER_START, labels); - } else { solrPrometheusCoreRegistry.exportGauge( - (Gauge) dropwizardMetric, CORE_UPDATE_HANDLER, labels); - } - } else { - System.out.println("This Metric does not exist"); + (Gauge) dropwizardMetric, CORE_REQUESTS_UPDATE_HANDLER, labels); + } else if (dropwizardMetric instanceof Timer) { + solrPrometheusCoreRegistry.exportTimer( + (Timer) dropwizardMetric, CORE_REQUEST_TIMES, labels); } } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java index dc2feb37566..da739f18aea 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java @@ -2,6 +2,7 @@ import com.codahale.metrics.Counter; import com.codahale.metrics.Metric; +import com.codahale.metrics.Timer; public class SolrCoreHighlighterMetric extends SolrCoreMetric { public static final String CORE_HIGHLIGHER_METRICS = "solr_metrics_core_highlighter_requests"; diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java index bee09ad71c4..5a013111230 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java @@ -2,9 +2,10 @@ import com.codahale.metrics.Gauge; import com.codahale.metrics.Metric; +import com.codahale.metrics.Timer; public class SolrCoreIndexMetric extends SolrCoreMetric { - public static final String CORE_INDEX_METRICS = "solr_metrics_index"; + public static final String CORE_INDEX_METRICS = "solr_metrics_core_index_size_bytes"; public SolrCoreIndexMetric( Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { @@ -13,19 +14,16 @@ public SolrCoreIndexMetric( @Override public SolrCoreMetric parseLabels() { - if (dropwizardMetric instanceof Gauge) { - String[] parsedMetric = metricName.split("\\."); - String type = parsedMetric[1]; - labels.put("type", type); - } return this; } @Override void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { if (dropwizardMetric instanceof Gauge) { - solrPrometheusCoreRegistry.exportGauge( - (Gauge) dropwizardMetric, CORE_INDEX_METRICS, labels); + if (metricName.endsWith("sizeInBytes")) { + solrPrometheusCoreRegistry.exportGauge( + (Gauge) dropwizardMetric, CORE_INDEX_METRICS, labels); + } } } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java index ed9d6044e8f..2cba2760650 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java @@ -15,7 +15,5 @@ public SolrCoreMetric parseLabels() { } @Override - void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { - System.out.println("Cannot export string metrics"); - } + void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) {} } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java index be84cf67a8b..2c0e2d42006 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java @@ -4,9 +4,11 @@ import com.codahale.metrics.Gauge; import com.codahale.metrics.Metric; +import com.codahale.metrics.Timer; public class SolrCoreSearcherMetric extends SolrCoreMetric { - public static final String CORE_SEARCHER_METRICS = "solr_metrics_core_searcher"; + public static final String CORE_SEARCHER_METRICS = "solr_metrics_core_searcher_documents"; + public static final String CORE_SEARCHER_TIMES = "solr_metrics_core_average_searcher_warmup_time"; public SolrCoreSearcherMetric( Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { @@ -33,8 +35,8 @@ void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { solrPrometheusCoreRegistry.exportGauge( (Gauge) dropwizardMetric, CORE_SEARCHER_METRICS, labels); } - } else { - System.out.println("This metric does not exist"); + } else if (dropwizardMetric instanceof Timer) { + solrPrometheusCoreRegistry.exportTimer((Timer) dropwizardMetric, CORE_SEARCHER_TIMES, labels); } } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java index ae4fc205fbb..05c181ccf96 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java @@ -2,9 +2,10 @@ import com.codahale.metrics.Meter; import com.codahale.metrics.Metric; +import com.codahale.metrics.Timer; public class SolrCoreTlogMetric extends SolrCoreMetric { - public static final String CORE_TLOG_METRICS = "solr_metrics_tlog_replicas"; + public static final String CORE_TLOG_METRICS = "solr_metrics_core_tlog"; public SolrCoreTlogMetric( Metric dropwizardMetric, String coreName, String metricName, boolean cloudMode) { @@ -18,7 +19,6 @@ public SolrCoreMetric parseLabels() { String item = parsedMetric[1]; String type = parsedMetric[2]; labels.put("item", item); - labels.put("type", type); } return this; } @@ -27,8 +27,6 @@ public SolrCoreMetric parseLabels() { public void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { if (dropwizardMetric instanceof Meter) { solrPrometheusCoreRegistry.exportMeter((Meter) dropwizardMetric, CORE_TLOG_METRICS, labels); - } else { - System.out.println("Not possible to migrate string values to prometheus"); } } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java index 0c4bd25ddbb..e4df8404a94 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java @@ -6,6 +6,16 @@ public class SolrPrometheusCoreRegistry extends SolrPrometheusRegistry { public final String coreName; public final boolean cloudMode; + public final static String ADMIN = "ADMIN"; + public final static String QUERY = "QUERY"; + public final static String UPDATE = "UPDATE"; + public final static String REPLICATION = "REPLICATION"; + public final static String TLOG = "TLOG"; + public final static String CACHE = "CACHE"; + public final static String SEARCHER = "SEARCHER"; + public final static String HIGHLIGHTER = "HIGHLIGHTER"; + public final static String INDEX = "INDEX"; + public final static String CORE = "CORE"; public SolrPrometheusCoreRegistry( PrometheusRegistry prometheusRegistry, String coreName, boolean cloudMode) { @@ -15,41 +25,41 @@ public SolrPrometheusCoreRegistry( } public void exportDropwizardMetric(String metricName, Metric dropwizardMetric) { - SolrCoreMetric solrCoreMetric = categorizeCorePrefix(dropwizardMetric, metricName); + SolrCoreMetric solrCoreMetric = categorizeCoreMetric(dropwizardMetric, metricName); solrCoreMetric.parseLabels().toPrometheus(this); } - private SolrCoreMetric categorizeCorePrefix(Metric dropwizardMetric, String metricName) { + private SolrCoreMetric categorizeCoreMetric(Metric dropwizardMetric, String metricName) { String metricCategory = metricName.split("\\.")[0]; switch (metricCategory) { - case "ADMIN": - case "QUERY": - case "UPDATE": - case "REPLICATION": + case ADMIN: + case QUERY: + case UPDATE: + case REPLICATION: { return new SolrCoreHandlerMetric(dropwizardMetric, coreName, metricName, cloudMode); } - case "TLOG": + case TLOG: { return new SolrCoreTlogMetric(dropwizardMetric, coreName, metricName, cloudMode); } - case "CACHE": + case CACHE: { return new SolrCoreCacheMetric(dropwizardMetric, coreName, metricName, cloudMode); } - case "SEARCHER": + case SEARCHER: { return new SolrCoreSearcherMetric(dropwizardMetric, coreName, metricName, cloudMode); } - case "HIGHLIGHTER": + case HIGHLIGHTER: { return new SolrCoreHighlighterMetric(dropwizardMetric, coreName, metricName, cloudMode); } - case "INDEX": + case INDEX: { return new SolrCoreIndexMetric(dropwizardMetric, coreName, metricName, cloudMode); } - case "CORE": + case CORE: default: { return new SolrCoreNoOpMetric(dropwizardMetric, coreName, metricName, cloudMode); diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java index 6943a1b7ccc..ce74d426139 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java @@ -1,6 +1,7 @@ package org.apache.solr.metrics.prometheus; import com.codahale.metrics.Meter; +import com.codahale.metrics.Timer; import io.prometheus.metrics.core.metrics.Counter; import io.prometheus.metrics.core.metrics.Gauge; import io.prometheus.metrics.model.registry.PrometheusRegistry; @@ -80,6 +81,17 @@ protected void exportCounter( .inc(dropwizardMetric.getCount()); } + protected void exportTimer(Timer dropwizardMetric, String prometheusMetricName, Map labelsMap) { + if (!metricGauges.containsKey(prometheusMetricName)) { + ArrayList labels = new ArrayList<>(labelsMap.keySet()); + registerGauge(prometheusMetricName, labels.toArray(String[]::new)); + } + ArrayList labelValues = new ArrayList<>(labelsMap.values()); + getMetricGauge(prometheusMetricName) + .labelValues(labelValues.toArray(String[]::new)) + .set(dropwizardMetric.getMeanRate()); + } + protected void exportGauge( com.codahale.metrics.Gauge dropwizardMetricRaw, String prometheusMetricName, @@ -108,8 +120,6 @@ protected void exportGauge( getMetricGauge(prometheusMetricName) .labelValues(newLabels) .set(((Number) itemsMap.get(item)).doubleValue()); - } else { - System.out.println("This is not an number"); } } } 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.java index 0c3830a3f3a..9295a6edda0 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 @@ -180,11 +180,12 @@ public static void toPrometheusRegistry( boolean skipAggregateValues, boolean compact, Consumer consumer) { + String coreName; + boolean cloudMode = false; Map dropwizardMetrics = registry.getMetrics(); String[] rawParsedRegistry = registryName.split("\\."); List parsedRegistry = new ArrayList<>(Arrays.asList(rawParsedRegistry)); - String coreName; - boolean cloudMode = false; + if (parsedRegistry.size() == 3) { coreName = parsedRegistry.get(2); } else if (parsedRegistry.size() == 5) { @@ -193,10 +194,10 @@ public static void toPrometheusRegistry( } else { coreName = registryName; } + SolrPrometheusCoreRegistry solrPrometheusCoreMetrics = new SolrPrometheusCoreRegistry(new PrometheusRegistry(), coreName, cloudMode); - Map> categories = new HashMap<>(); toMaps( registry, shouldMatchFilters, @@ -208,15 +209,6 @@ public static void toPrometheusRegistry( false, (metricName, metric) -> { Metric dropwizardMetric = dropwizardMetrics.get(metricName); - String[] splitString = metricName.split("\\."); - - if (!categories.containsKey(splitString[0])) { - categories.put(splitString[0], new HashMap<>()); - } - if (!categories.get(splitString[0]).containsKey(metricName)) { - categories.get(splitString[0]).put(metricName, dropwizardMetric); - } - solrPrometheusCoreMetrics.exportDropwizardMetric(metricName, dropwizardMetric); }); consumer.accept(solrPrometheusCoreMetrics.getPrometheusRegistry()); From b04bd1416c7c6255fc01032ff7589d94a86ad010 Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Tue, 16 Apr 2024 15:10:18 -0400 Subject: [PATCH 19/25] Don't fail on entirely exporting a broken metric --- .../prometheus/SolrCoreCacheMetric.java | 1 - .../prometheus/SolrCoreHandlerMetric.java | 7 ++-- .../prometheus/SolrCoreHighlighterMetric.java | 1 - .../prometheus/SolrCoreIndexMetric.java | 3 +- .../prometheus/SolrCoreTlogMetric.java | 1 - .../SolrPrometheusCoreRegistry.java | 20 +++++------ .../prometheus/SolrPrometheusRegistry.java | 36 ++++++++++++------- .../apache/solr/util/stats/MetricUtils.java | 13 ++++--- 8 files changed, 46 insertions(+), 36 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java index 8b21468bf1a..bd127900bb6 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java @@ -2,7 +2,6 @@ import com.codahale.metrics.Gauge; import com.codahale.metrics.Metric; -import com.codahale.metrics.Timer; public class SolrCoreCacheMetric extends SolrCoreMetric { public static final String CORE_CACHE_SEARCHER_METRICS = "solr_metrics_core_cache"; diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java index 9e060a4dcc5..0cfd43a64b5 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java @@ -44,11 +44,10 @@ public void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) (Counter) dropwizardMetric, CORE_REQUESTS_TOTAL_TIME, labels); } } else if (dropwizardMetric instanceof Gauge) { - solrPrometheusCoreRegistry.exportGauge( - (Gauge) dropwizardMetric, CORE_REQUESTS_UPDATE_HANDLER, labels); + solrPrometheusCoreRegistry.exportGauge( + (Gauge) dropwizardMetric, CORE_REQUESTS_UPDATE_HANDLER, labels); } else if (dropwizardMetric instanceof Timer) { - solrPrometheusCoreRegistry.exportTimer( - (Timer) dropwizardMetric, CORE_REQUEST_TIMES, labels); + solrPrometheusCoreRegistry.exportTimer((Timer) dropwizardMetric, CORE_REQUEST_TIMES, labels); } } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java index da739f18aea..dc2feb37566 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java @@ -2,7 +2,6 @@ import com.codahale.metrics.Counter; import com.codahale.metrics.Metric; -import com.codahale.metrics.Timer; public class SolrCoreHighlighterMetric extends SolrCoreMetric { public static final String CORE_HIGHLIGHER_METRICS = "solr_metrics_core_highlighter_requests"; diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java index 5a013111230..ee1b6ad442b 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java @@ -2,7 +2,6 @@ import com.codahale.metrics.Gauge; import com.codahale.metrics.Metric; -import com.codahale.metrics.Timer; public class SolrCoreIndexMetric extends SolrCoreMetric { public static final String CORE_INDEX_METRICS = "solr_metrics_core_index_size_bytes"; @@ -22,7 +21,7 @@ void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { if (dropwizardMetric instanceof Gauge) { if (metricName.endsWith("sizeInBytes")) { solrPrometheusCoreRegistry.exportGauge( - (Gauge) dropwizardMetric, CORE_INDEX_METRICS, labels); + (Gauge) dropwizardMetric, CORE_INDEX_METRICS, labels); } } } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java index 05c181ccf96..b52ec8604c7 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java @@ -2,7 +2,6 @@ import com.codahale.metrics.Meter; import com.codahale.metrics.Metric; -import com.codahale.metrics.Timer; public class SolrCoreTlogMetric extends SolrCoreMetric { public static final String CORE_TLOG_METRICS = "solr_metrics_core_tlog"; diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java index e4df8404a94..196d200e229 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java @@ -6,16 +6,16 @@ public class SolrPrometheusCoreRegistry extends SolrPrometheusRegistry { public final String coreName; public final boolean cloudMode; - public final static String ADMIN = "ADMIN"; - public final static String QUERY = "QUERY"; - public final static String UPDATE = "UPDATE"; - public final static String REPLICATION = "REPLICATION"; - public final static String TLOG = "TLOG"; - public final static String CACHE = "CACHE"; - public final static String SEARCHER = "SEARCHER"; - public final static String HIGHLIGHTER = "HIGHLIGHTER"; - public final static String INDEX = "INDEX"; - public final static String CORE = "CORE"; + public static final String ADMIN = "ADMIN"; + public static final String QUERY = "QUERY"; + public static final String UPDATE = "UPDATE"; + public static final String REPLICATION = "REPLICATION"; + public static final String TLOG = "TLOG"; + public static final String CACHE = "CACHE"; + public static final String SEARCHER = "SEARCHER"; + public static final String HIGHLIGHTER = "HIGHLIGHTER"; + public static final String INDEX = "INDEX"; + public static final String CORE = "CORE"; public SolrPrometheusCoreRegistry( PrometheusRegistry prometheusRegistry, String coreName, boolean cloudMode) { diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java index ce74d426139..fda69a25c3b 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java @@ -2,6 +2,7 @@ import com.codahale.metrics.Meter; import com.codahale.metrics.Timer; +import com.google.common.collect.ImmutableMap; import io.prometheus.metrics.core.metrics.Counter; import io.prometheus.metrics.core.metrics.Gauge; import io.prometheus.metrics.model.registry.PrometheusRegistry; @@ -29,15 +30,23 @@ public String getRegistryName() { return registryName; } - public Counter getMetricCounter(String metricName) { + public Map copyOfCounters() { + return ImmutableMap.copyOf(metricCounters); + } + + public Map copyOfGauges() { + return ImmutableMap.copyOf(metricGauges); + } + + private Counter getMetricCounter(String metricName) { return metricCounters.get(metricName); } - public Gauge getMetricGauge(String metricName) { + private Gauge getMetricGauge(String metricName) { return metricGauges.get(metricName); } - protected void registerCounter(String metricName, String... labelNames) { + private void registerCounter(String metricName, String... labelNames) { Counter counter = io.prometheus.metrics.core.metrics.Counter.builder() .name(metricName) @@ -46,7 +55,7 @@ protected void registerCounter(String metricName, String... labelNames) { metricCounters.put(metricName, counter); } - protected void registerGauge(String metricName, String... labelNames) { + private void registerGauge(String metricName, String... labelNames) { Gauge gauge = io.prometheus.metrics.core.metrics.Gauge.builder() .name(metricName) @@ -55,9 +64,9 @@ protected void registerGauge(String metricName, String... labelNames) { metricGauges.put(metricName, gauge); } - protected void exportMeter( + public void exportMeter( Meter dropwizardMetric, String prometheusMetricName, Map labelsMap) { - if (!metricCounters.containsKey(prometheusMetricName)) { + if (!copyOfCounters().containsKey(prometheusMetricName)) { ArrayList labels = new ArrayList<>(labelsMap.keySet()); registerCounter(prometheusMetricName, labels.toArray(String[]::new)); } @@ -71,7 +80,7 @@ protected void exportCounter( com.codahale.metrics.Counter dropwizardMetric, String prometheusMetricName, Map labelsMap) { - if (!metricCounters.containsKey(prometheusMetricName)) { + if (!copyOfCounters().containsKey(prometheusMetricName)) { ArrayList labels = new ArrayList<>(labelsMap.keySet()); registerCounter(prometheusMetricName, labels.toArray(String[]::new)); } @@ -81,23 +90,24 @@ protected void exportCounter( .inc(dropwizardMetric.getCount()); } - protected void exportTimer(Timer dropwizardMetric, String prometheusMetricName, Map labelsMap) { - if (!metricGauges.containsKey(prometheusMetricName)) { + public void exportTimer( + Timer dropwizardMetric, String prometheusMetricName, Map labelsMap) { + if (!copyOfGauges().containsKey(prometheusMetricName)) { ArrayList labels = new ArrayList<>(labelsMap.keySet()); registerGauge(prometheusMetricName, labels.toArray(String[]::new)); } ArrayList labelValues = new ArrayList<>(labelsMap.values()); getMetricGauge(prometheusMetricName) - .labelValues(labelValues.toArray(String[]::new)) - .set(dropwizardMetric.getMeanRate()); + .labelValues(labelValues.toArray(String[]::new)) + .set(dropwizardMetric.getMeanRate()); } - protected void exportGauge( + public void exportGauge( com.codahale.metrics.Gauge dropwizardMetricRaw, String prometheusMetricName, Map labelsMap) { Object dropwizardMetric = (dropwizardMetricRaw).getValue(); - if (!metricGauges.containsKey(prometheusMetricName)) { + if (!copyOfGauges().containsKey(prometheusMetricName)) { ArrayList labels = new ArrayList<>(labelsMap.keySet()); if (dropwizardMetric instanceof HashMap) { labels.add("item"); 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.java index 9295a6edda0..2e0bdfc51ad 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 @@ -180,8 +180,8 @@ public static void toPrometheusRegistry( boolean skipAggregateValues, boolean compact, Consumer consumer) { - String coreName; - boolean cloudMode = false; + String coreName; + boolean cloudMode = false; Map dropwizardMetrics = registry.getMetrics(); String[] rawParsedRegistry = registryName.split("\\."); List parsedRegistry = new ArrayList<>(Arrays.asList(rawParsedRegistry)); @@ -208,8 +208,13 @@ public static void toPrometheusRegistry( compact, false, (metricName, metric) -> { - Metric dropwizardMetric = dropwizardMetrics.get(metricName); - solrPrometheusCoreMetrics.exportDropwizardMetric(metricName, dropwizardMetric); + try { + Metric dropwizardMetric = dropwizardMetrics.get(metricName); + solrPrometheusCoreMetrics.exportDropwizardMetric(metricName, dropwizardMetric); + } catch (Exception e) { + // Do not fail entirely for metrics exporting. Log and try to export next metric + log.warn("Error occurred exporting Dropwizard Metric to Prometheus", e); + } }); consumer.accept(solrPrometheusCoreMetrics.getPrometheusRegistry()); } From 771d82345474d73c0f56c7ea81ed1c85d6ff1fac Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Tue, 16 Apr 2024 15:17:22 -0400 Subject: [PATCH 20/25] Refactor function placements --- .../solr/handler/admin/MetricsHandler.java | 17 +++--- .../prometheus/SolrPrometheusRegistry.java | 54 +++++++++---------- 2 files changed, 34 insertions(+), 37 deletions(-) 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.java index 466752e0a0a..83e60ef0eb8 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 @@ -126,11 +126,9 @@ private void handleRequest(SolrParams params, BiConsumer consume consumer.accept("error", "metrics collection is disabled"); return; } - boolean compact = params.getBool(COMPACT_PARAM, true); - Set requestedRegistries = parseRegistries(params); if (PROMETHEUS_METRICS_WT.equals(params.get(CommonParams.WT))) { - response = handlePrometheusRegistry(params, requestedRegistries); + response = handlePrometheusRegistry(params); consumer.accept("metrics", response); return; } @@ -145,20 +143,19 @@ private void handleRequest(SolrParams params, BiConsumer consume return; } - response = handleDropwizardRegistry(params, requestedRegistries); + response = handleDropwizardRegistry(params); consumer.accept("metrics", response); } - private NamedList handleDropwizardRegistry( - SolrParams params, Set requestedRegistries) { + private NamedList handleDropwizardRegistry(SolrParams params) { boolean compact = params.getBool(COMPACT_PARAM, true); MetricFilter mustMatchFilter = parseMustMatchFilter(params); Predicate propertyFilter = parsePropertyFilter(params); List metricTypes = parseMetricTypes(params); List metricFilters = metricTypes.stream().map(MetricType::asMetricFilter).collect(Collectors.toList()); - metricTypes.stream().map(MetricType::asMetricFilter).collect(Collectors.toList()); + Set requestedRegistries = parseRegistries(params); NamedList response = new SimpleOrderedMap<>(); for (String registryName : requestedRegistries) { @@ -182,8 +179,7 @@ private NamedList handleDropwizardRegistry( return response; } - private NamedList handlePrometheusRegistry( - SolrParams params, Set requestedRegistries) { + private NamedList handlePrometheusRegistry(SolrParams params) { NamedList response = new SimpleOrderedMap<>(); boolean compact = params.getBool(COMPACT_PARAM, true); MetricFilter mustMatchFilter = parseMustMatchFilter(params); @@ -191,9 +187,10 @@ private NamedList handlePrometheusRegistry( List metricTypes = parseMetricTypes(params); List metricFilters = metricTypes.stream().map(MetricType::asMetricFilter).collect(Collectors.toList()); + Set requestedRegistries = parseRegistries(params); + for (String registryName : requestedRegistries) { MetricRegistry dropWizardRegistry = metricManager.registry(registryName); - // Currently only export Solr Core registries if (registryName.startsWith("solr.core")) { MetricUtils.toPrometheusRegistry( diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java index fda69a25c3b..e7d5cacb7ad 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java @@ -38,32 +38,6 @@ public Map copyOfGauges() { return ImmutableMap.copyOf(metricGauges); } - private Counter getMetricCounter(String metricName) { - return metricCounters.get(metricName); - } - - private Gauge getMetricGauge(String metricName) { - return metricGauges.get(metricName); - } - - private void registerCounter(String metricName, String... labelNames) { - Counter counter = - io.prometheus.metrics.core.metrics.Counter.builder() - .name(metricName) - .labelNames(labelNames) - .register(prometheusRegistry); - metricCounters.put(metricName, counter); - } - - private void registerGauge(String metricName, String... labelNames) { - Gauge gauge = - io.prometheus.metrics.core.metrics.Gauge.builder() - .name(metricName) - .labelNames(labelNames) - .register(prometheusRegistry); - metricGauges.put(metricName, gauge); - } - public void exportMeter( Meter dropwizardMetric, String prometheusMetricName, Map labelsMap) { if (!copyOfCounters().containsKey(prometheusMetricName)) { @@ -76,7 +50,7 @@ public void exportMeter( .inc(dropwizardMetric.getCount()); } - protected void exportCounter( + public void exportCounter( com.codahale.metrics.Counter dropwizardMetric, String prometheusMetricName, Map labelsMap) { @@ -134,4 +108,30 @@ public void exportGauge( } } } + + private Counter getMetricCounter(String metricName) { + return metricCounters.get(metricName); + } + + private Gauge getMetricGauge(String metricName) { + return metricGauges.get(metricName); + } + + private void registerCounter(String metricName, String... labelNames) { + Counter counter = + io.prometheus.metrics.core.metrics.Counter.builder() + .name(metricName) + .labelNames(labelNames) + .register(prometheusRegistry); + metricCounters.put(metricName, counter); + } + + private void registerGauge(String metricName, String... labelNames) { + Gauge gauge = + io.prometheus.metrics.core.metrics.Gauge.builder() + .name(metricName) + .labelNames(labelNames) + .register(prometheusRegistry); + metricGauges.put(metricName, gauge); + } } From fecd76d91882f78e38b9a970870570f5d532e901 Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Tue, 16 Apr 2024 15:42:57 -0400 Subject: [PATCH 21/25] Remove unused prometheus dependencies --- solr/core/build.gradle | 5 ----- versions.lock | 9 +++++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/solr/core/build.gradle b/solr/core/build.gradle index 4eac5c2e9a3..5e9d46af985 100644 --- a/solr/core/build.gradle +++ b/solr/core/build.gradle @@ -154,13 +154,8 @@ dependencies { runtimeOnly 'org.apache.logging.log4j:log4j-slf4j2-impl' // Prometheus client - implementation 'io.prometheus:simpleclient' - implementation 'io.prometheus:simpleclient_common' - implementation 'io.prometheus:simpleclient_dropwizard' implementation 'io.prometheus:prometheus-metrics-exposition-formats:1.1.0' - implementation 'io.prometheus:prometheus-metrics-simpleclient-bridge:1.1.0' implementation 'io.prometheus:prometheus-metrics-core:1.1.0' - implementation 'io.prometheus:prometheus-metrics-instrumentation-jvm:1.1.0' // For faster XML processing than the JDK implementation 'org.codehaus.woodstox:stax2-api' diff --git a/versions.lock b/versions.lock index 8ca94aa7689..46b5426ef88 100644 --- a/versions.lock +++ b/versions.lock @@ -145,6 +145,15 @@ io.opentelemetry:opentelemetry-sdk-logs:1.35.0 (3 constraints: eb32b3b2) io.opentelemetry:opentelemetry-sdk-metrics:1.35.0 (3 constraints: eb32b3b2) io.opentelemetry:opentelemetry-sdk-trace:1.35.0 (3 constraints: eb32b3b2) io.perfmark:perfmark-api:0.26.0 (3 constraints: 21212b16) +io.prometheus:prometheus-metrics-config:1.1.0 (2 constraints: a926cf59) +io.prometheus:prometheus-metrics-core:1.1.0 (1 constraints: 0405f335) +io.prometheus:prometheus-metrics-exposition-formats:1.1.0 (1 constraints: 0405f335) +io.prometheus:prometheus-metrics-model:1.1.0 (2 constraints: a926cf59) +io.prometheus:prometheus-metrics-shaded-protobuf:1.1.0 (1 constraints: 3e164ed8) +io.prometheus:prometheus-metrics-tracer-common:1.1.0 (3 constraints: 993ee7d1) +io.prometheus:prometheus-metrics-tracer-initializer:1.1.0 (1 constraints: 6c1022a8) +io.prometheus:prometheus-metrics-tracer-otel:1.1.0 (1 constraints: 1516fed3) +io.prometheus:prometheus-metrics-tracer-otel-agent:1.1.0 (1 constraints: 1516fed3) io.prometheus:simpleclient:0.16.0 (3 constraints: 9d257513) io.prometheus:simpleclient_common:0.16.0 (1 constraints: 1a1139c0) io.prometheus:simpleclient_httpserver:0.16.0 (1 constraints: 3905353b) From f9b6d2815bc5a636de1bfc4cda7a9c43ca818d4f Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Tue, 16 Apr 2024 15:50:31 -0400 Subject: [PATCH 22/25] Move core metrics classes to core package --- .../metrics/prometheus/SolrPrometheusCoreRegistry.java | 8 ++++++++ .../prometheus/{ => core}/SolrCoreCacheMetric.java | 5 +++-- .../prometheus/{ => core}/SolrCoreHandlerMetric.java | 3 ++- .../prometheus/{ => core}/SolrCoreHighlighterMetric.java | 5 +++-- .../prometheus/{ => core}/SolrCoreIndexMetric.java | 5 +++-- .../metrics/prometheus/{ => core}/SolrCoreMetric.java | 8 +++++--- .../metrics/prometheus/{ => core}/SolrCoreNoOpMetric.java | 5 +++-- .../prometheus/{ => core}/SolrCoreSearcherMetric.java | 7 ++++--- .../metrics/prometheus/{ => core}/SolrCoreTlogMetric.java | 3 ++- 9 files changed, 33 insertions(+), 16 deletions(-) rename solr/core/src/java/org/apache/solr/metrics/prometheus/{ => core}/SolrCoreCacheMetric.java (80%) rename solr/core/src/java/org/apache/solr/metrics/prometheus/{ => core}/SolrCoreHandlerMetric.java (94%) rename solr/core/src/java/org/apache/solr/metrics/prometheus/{ => core}/SolrCoreHighlighterMetric.java (81%) rename solr/core/src/java/org/apache/solr/metrics/prometheus/{ => core}/SolrCoreIndexMetric.java (78%) rename solr/core/src/java/org/apache/solr/metrics/prometheus/{ => core}/SolrCoreMetric.java (75%) rename solr/core/src/java/org/apache/solr/metrics/prometheus/{ => core}/SolrCoreNoOpMetric.java (64%) rename solr/core/src/java/org/apache/solr/metrics/prometheus/{ => core}/SolrCoreSearcherMetric.java (81%) rename solr/core/src/java/org/apache/solr/metrics/prometheus/{ => core}/SolrCoreTlogMetric.java (88%) diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java index 196d200e229..00a097c8c1d 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java @@ -2,6 +2,14 @@ import com.codahale.metrics.Metric; import io.prometheus.metrics.model.registry.PrometheusRegistry; +import org.apache.solr.metrics.prometheus.core.SolrCoreCacheMetric; +import org.apache.solr.metrics.prometheus.core.SolrCoreHandlerMetric; +import org.apache.solr.metrics.prometheus.core.SolrCoreHighlighterMetric; +import org.apache.solr.metrics.prometheus.core.SolrCoreIndexMetric; +import org.apache.solr.metrics.prometheus.core.SolrCoreMetric; +import org.apache.solr.metrics.prometheus.core.SolrCoreNoOpMetric; +import org.apache.solr.metrics.prometheus.core.SolrCoreSearcherMetric; +import org.apache.solr.metrics.prometheus.core.SolrCoreTlogMetric; public class SolrPrometheusCoreRegistry extends SolrPrometheusRegistry { public final String coreName; diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreCacheMetric.java similarity index 80% rename from solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java rename to solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreCacheMetric.java index bd127900bb6..33ded7b37c7 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreCacheMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreCacheMetric.java @@ -1,7 +1,8 @@ -package org.apache.solr.metrics.prometheus; +package org.apache.solr.metrics.prometheus.core; import com.codahale.metrics.Gauge; import com.codahale.metrics.Metric; +import org.apache.solr.metrics.prometheus.SolrPrometheusCoreRegistry; public class SolrCoreCacheMetric extends SolrCoreMetric { public static final String CORE_CACHE_SEARCHER_METRICS = "solr_metrics_core_cache"; @@ -22,7 +23,7 @@ public SolrCoreMetric parseLabels() { } @Override - void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + public void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { if (dropwizardMetric instanceof Gauge) { solrPrometheusCoreRegistry.exportGauge( (Gauge) dropwizardMetric, CORE_CACHE_SEARCHER_METRICS, labels); diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreHandlerMetric.java similarity index 94% rename from solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java rename to solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreHandlerMetric.java index 0cfd43a64b5..25926c78d2a 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHandlerMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreHandlerMetric.java @@ -1,10 +1,11 @@ -package org.apache.solr.metrics.prometheus; +package org.apache.solr.metrics.prometheus.core; import com.codahale.metrics.Counter; import com.codahale.metrics.Gauge; import com.codahale.metrics.Meter; import com.codahale.metrics.Metric; import com.codahale.metrics.Timer; +import org.apache.solr.metrics.prometheus.SolrPrometheusCoreRegistry; public class SolrCoreHandlerMetric extends SolrCoreMetric { public static final String CORE_REQUESTS_TOTAL = "solr_metrics_core_requests"; diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreHighlighterMetric.java similarity index 81% rename from solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java rename to solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreHighlighterMetric.java index dc2feb37566..77a75de840c 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreHighlighterMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreHighlighterMetric.java @@ -1,7 +1,8 @@ -package org.apache.solr.metrics.prometheus; +package org.apache.solr.metrics.prometheus.core; import com.codahale.metrics.Counter; import com.codahale.metrics.Metric; +import org.apache.solr.metrics.prometheus.SolrPrometheusCoreRegistry; public class SolrCoreHighlighterMetric extends SolrCoreMetric { public static final String CORE_HIGHLIGHER_METRICS = "solr_metrics_core_highlighter_requests"; @@ -22,7 +23,7 @@ public SolrCoreMetric parseLabels() { } @Override - void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + public void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { if (dropwizardMetric instanceof Counter) { solrPrometheusCoreRegistry.exportCounter( (Counter) dropwizardMetric, CORE_HIGHLIGHER_METRICS, labels); diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreIndexMetric.java similarity index 78% rename from solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java rename to solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreIndexMetric.java index ee1b6ad442b..ddda550d950 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreIndexMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreIndexMetric.java @@ -1,7 +1,8 @@ -package org.apache.solr.metrics.prometheus; +package org.apache.solr.metrics.prometheus.core; import com.codahale.metrics.Gauge; import com.codahale.metrics.Metric; +import org.apache.solr.metrics.prometheus.SolrPrometheusCoreRegistry; public class SolrCoreIndexMetric extends SolrCoreMetric { public static final String CORE_INDEX_METRICS = "solr_metrics_core_index_size_bytes"; @@ -17,7 +18,7 @@ public SolrCoreMetric parseLabels() { } @Override - void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + public void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { if (dropwizardMetric instanceof Gauge) { if (metricName.endsWith("sizeInBytes")) { solrPrometheusCoreRegistry.exportGauge( diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreMetric.java similarity index 75% rename from solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java rename to solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreMetric.java index 499079eec69..02ab42ae683 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreMetric.java @@ -1,6 +1,8 @@ -package org.apache.solr.metrics.prometheus; +package org.apache.solr.metrics.prometheus.core; import com.codahale.metrics.Metric; +import org.apache.solr.metrics.prometheus.SolrPrometheusCoreRegistry; + import java.util.HashMap; import java.util.Map; @@ -24,7 +26,7 @@ public SolrCoreMetric( } } - abstract SolrCoreMetric parseLabels(); + public abstract SolrCoreMetric parseLabels(); - abstract void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry); + public abstract void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry); } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreNoOpMetric.java similarity index 64% rename from solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java rename to solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreNoOpMetric.java index 2cba2760650..854ba121c9a 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreNoOpMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreNoOpMetric.java @@ -1,6 +1,7 @@ -package org.apache.solr.metrics.prometheus; +package org.apache.solr.metrics.prometheus.core; import com.codahale.metrics.Metric; +import org.apache.solr.metrics.prometheus.SolrPrometheusCoreRegistry; public class SolrCoreNoOpMetric extends SolrCoreMetric { @@ -15,5 +16,5 @@ public SolrCoreMetric parseLabels() { } @Override - void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) {} + public void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) {} } diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreSearcherMetric.java similarity index 81% rename from solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java rename to solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreSearcherMetric.java index 2c0e2d42006..00692f7e629 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreSearcherMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreSearcherMetric.java @@ -1,10 +1,11 @@ -package org.apache.solr.metrics.prometheus; +package org.apache.solr.metrics.prometheus.core; -import static org.apache.solr.metrics.prometheus.SolrCoreCacheMetric.CORE_CACHE_SEARCHER_METRICS; +import static org.apache.solr.metrics.prometheus.core.SolrCoreCacheMetric.CORE_CACHE_SEARCHER_METRICS; import com.codahale.metrics.Gauge; import com.codahale.metrics.Metric; import com.codahale.metrics.Timer; +import org.apache.solr.metrics.prometheus.SolrPrometheusCoreRegistry; public class SolrCoreSearcherMetric extends SolrCoreMetric { public static final String CORE_SEARCHER_METRICS = "solr_metrics_core_searcher_documents"; @@ -26,7 +27,7 @@ public SolrCoreMetric parseLabels() { } @Override - void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { + public void toPrometheus(SolrPrometheusCoreRegistry solrPrometheusCoreRegistry) { if (dropwizardMetric instanceof Gauge) { if (metricName.endsWith("liveDocsCache")) { solrPrometheusCoreRegistry.exportGauge( diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreTlogMetric.java similarity index 88% rename from solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java rename to solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreTlogMetric.java index b52ec8604c7..8ae8f45de17 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrCoreTlogMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreTlogMetric.java @@ -1,7 +1,8 @@ -package org.apache.solr.metrics.prometheus; +package org.apache.solr.metrics.prometheus.core; import com.codahale.metrics.Meter; import com.codahale.metrics.Metric; +import org.apache.solr.metrics.prometheus.SolrPrometheusCoreRegistry; public class SolrCoreTlogMetric extends SolrCoreMetric { public static final String CORE_TLOG_METRICS = "solr_metrics_core_tlog"; From c6101f4fd149d286224da4996f6560b056f4f458 Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Tue, 16 Apr 2024 16:37:10 -0400 Subject: [PATCH 23/25] Add license agreement at top of new files --- .../prometheus/SolrPrometheusCoreRegistry.java | 16 ++++++++++++++++ .../prometheus/SolrPrometheusRegistry.java | 16 ++++++++++++++++ .../prometheus/core/SolrCoreCacheMetric.java | 16 ++++++++++++++++ .../prometheus/core/SolrCoreHandlerMetric.java | 16 ++++++++++++++++ .../core/SolrCoreHighlighterMetric.java | 16 ++++++++++++++++ .../prometheus/core/SolrCoreIndexMetric.java | 16 ++++++++++++++++ .../metrics/prometheus/core/SolrCoreMetric.java | 16 ++++++++++++++++ .../prometheus/core/SolrCoreNoOpMetric.java | 16 ++++++++++++++++ .../prometheus/core/SolrCoreSearcherMetric.java | 16 ++++++++++++++++ .../prometheus/core/SolrCoreTlogMetric.java | 16 ++++++++++++++++ .../solr/response/PrometheusResponseWriter.java | 16 ++++++++++++++++ 11 files changed, 176 insertions(+) diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java index 00a097c8c1d..0ae8dced071 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusCoreRegistry.java @@ -1,3 +1,19 @@ +/* + * 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. + */ package org.apache.solr.metrics.prometheus; import com.codahale.metrics.Metric; diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java index e7d5cacb7ad..912dffb146e 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java @@ -1,3 +1,19 @@ +/* + * 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. + */ package org.apache.solr.metrics.prometheus; import com.codahale.metrics.Meter; diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreCacheMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreCacheMetric.java index 33ded7b37c7..46064bf366b 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreCacheMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreCacheMetric.java @@ -1,3 +1,19 @@ +/* + * 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. + */ package org.apache.solr.metrics.prometheus.core; import com.codahale.metrics.Gauge; diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreHandlerMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreHandlerMetric.java index 25926c78d2a..f9247da4d6b 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreHandlerMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreHandlerMetric.java @@ -1,3 +1,19 @@ +/* + * 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. + */ package org.apache.solr.metrics.prometheus.core; import com.codahale.metrics.Counter; diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreHighlighterMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreHighlighterMetric.java index 77a75de840c..742c580d2db 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreHighlighterMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreHighlighterMetric.java @@ -1,3 +1,19 @@ +/* + * 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. + */ package org.apache.solr.metrics.prometheus.core; import com.codahale.metrics.Counter; diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreIndexMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreIndexMetric.java index ddda550d950..54e582152a7 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreIndexMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreIndexMetric.java @@ -1,3 +1,19 @@ +/* + * 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. + */ package org.apache.solr.metrics.prometheus.core; import com.codahale.metrics.Gauge; diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreMetric.java index 02ab42ae683..0ffc2a69c13 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreMetric.java @@ -1,3 +1,19 @@ +/* + * 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. + */ package org.apache.solr.metrics.prometheus.core; import com.codahale.metrics.Metric; diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreNoOpMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreNoOpMetric.java index 854ba121c9a..6d22b6f8255 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreNoOpMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreNoOpMetric.java @@ -1,3 +1,19 @@ +/* + * 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. + */ package org.apache.solr.metrics.prometheus.core; import com.codahale.metrics.Metric; diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreSearcherMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreSearcherMetric.java index 00692f7e629..ec47e93432a 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreSearcherMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreSearcherMetric.java @@ -1,3 +1,19 @@ +/* + * 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. + */ package org.apache.solr.metrics.prometheus.core; import static org.apache.solr.metrics.prometheus.core.SolrCoreCacheMetric.CORE_CACHE_SEARCHER_METRICS; diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreTlogMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreTlogMetric.java index 8ae8f45de17..86eb7b08a8e 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreTlogMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreTlogMetric.java @@ -1,3 +1,19 @@ +/* + * 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. + */ package org.apache.solr.metrics.prometheus.core; import com.codahale.metrics.Meter; diff --git a/solr/core/src/java/org/apache/solr/response/PrometheusResponseWriter.java b/solr/core/src/java/org/apache/solr/response/PrometheusResponseWriter.java index 4f34e9eb176..869e0575630 100644 --- a/solr/core/src/java/org/apache/solr/response/PrometheusResponseWriter.java +++ b/solr/core/src/java/org/apache/solr/response/PrometheusResponseWriter.java @@ -1,3 +1,19 @@ +/* + * 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. + */ package org.apache.solr.response; import io.prometheus.metrics.expositionformats.PrometheusTextFormatWriter; From d3dc5852460270891e8c3c97ecf5ec2ff242165f Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Tue, 16 Apr 2024 17:25:52 -0400 Subject: [PATCH 24/25] Update licenses --- .../prometheus/core/SolrCoreMetric.java | 3 +- .../metrics/prometheus/core/package-info.java | 22 ++ .../solr/metrics/prometheus/package-info.java | 23 ++ .../prometheus-metrics-config-1.1.0.jar.sha1 | 1 + .../prometheus-metrics-config-LICENSE-ASL.txt | 201 ++++++++++++++++++ .../prometheus-metrics-config-NOTICE.txt | 11 + .../prometheus-metrics-core-1.1.0.jar.sha1 | 1 + .../prometheus-metrics-core-LICENSE-ASL.txt | 201 ++++++++++++++++++ .../prometheus-metrics-core-NOTICE.txt | 11 + ...-metrics-exposition-formats-1.1.0.jar.sha1 | 1 + ...metrics-exposition-formats-LICENSE-ASL.txt | 201 ++++++++++++++++++ ...heus-metrics-exposition-formats-NOTICE.txt | 11 + .../prometheus-metrics-model-1.1.0.jar.sha1 | 1 + .../prometheus-metrics-model-LICENSE-ASL.txt | 201 ++++++++++++++++++ .../prometheus-metrics-model-NOTICE.txt | 11 + ...eus-metrics-shaded-protobuf-1.1.0.jar.sha1 | 1 + ...us-metrics-shaded-protobuf-LICENSE-ASL.txt | 201 ++++++++++++++++++ ...metheus-metrics-shaded-protobuf-NOTICE.txt | 11 + ...theus-metrics-tracer-common-1.1.0.jar.sha1 | 1 + ...heus-metrics-tracer-common-LICENSE-ASL.txt | 201 ++++++++++++++++++ ...rometheus-metrics-tracer-common-NOTICE.txt | 11 + ...-metrics-tracer-initializer-1.1.0.jar.sha1 | 1 + ...metrics-tracer-initializer-LICENSE-ASL.txt | 201 ++++++++++++++++++ ...heus-metrics-tracer-initializer-NOTICE.txt | 11 + ...metheus-metrics-tracer-otel-1.1.0.jar.sha1 | 1 + ...etheus-metrics-tracer-otel-LICENSE-ASL.txt | 201 ++++++++++++++++++ .../prometheus-metrics-tracer-otel-NOTICE.txt | 11 + ...s-metrics-tracer-otel-agent-1.1.0.jar.sha1 | 1 + ...-metrics-tracer-otel-agent-LICENSE-ASL.txt | 201 ++++++++++++++++++ ...theus-metrics-tracer-otel-agent-NOTICE.txt | 11 + 30 files changed, 1963 insertions(+), 2 deletions(-) create mode 100644 solr/core/src/java/org/apache/solr/metrics/prometheus/core/package-info.java create mode 100644 solr/core/src/java/org/apache/solr/metrics/prometheus/package-info.java create mode 100644 solr/licenses/prometheus-metrics-config-1.1.0.jar.sha1 create mode 100644 solr/licenses/prometheus-metrics-config-LICENSE-ASL.txt create mode 100644 solr/licenses/prometheus-metrics-config-NOTICE.txt create mode 100644 solr/licenses/prometheus-metrics-core-1.1.0.jar.sha1 create mode 100644 solr/licenses/prometheus-metrics-core-LICENSE-ASL.txt create mode 100644 solr/licenses/prometheus-metrics-core-NOTICE.txt create mode 100644 solr/licenses/prometheus-metrics-exposition-formats-1.1.0.jar.sha1 create mode 100644 solr/licenses/prometheus-metrics-exposition-formats-LICENSE-ASL.txt create mode 100644 solr/licenses/prometheus-metrics-exposition-formats-NOTICE.txt create mode 100644 solr/licenses/prometheus-metrics-model-1.1.0.jar.sha1 create mode 100644 solr/licenses/prometheus-metrics-model-LICENSE-ASL.txt create mode 100644 solr/licenses/prometheus-metrics-model-NOTICE.txt create mode 100644 solr/licenses/prometheus-metrics-shaded-protobuf-1.1.0.jar.sha1 create mode 100644 solr/licenses/prometheus-metrics-shaded-protobuf-LICENSE-ASL.txt create mode 100644 solr/licenses/prometheus-metrics-shaded-protobuf-NOTICE.txt create mode 100644 solr/licenses/prometheus-metrics-tracer-common-1.1.0.jar.sha1 create mode 100644 solr/licenses/prometheus-metrics-tracer-common-LICENSE-ASL.txt create mode 100644 solr/licenses/prometheus-metrics-tracer-common-NOTICE.txt create mode 100644 solr/licenses/prometheus-metrics-tracer-initializer-1.1.0.jar.sha1 create mode 100644 solr/licenses/prometheus-metrics-tracer-initializer-LICENSE-ASL.txt create mode 100644 solr/licenses/prometheus-metrics-tracer-initializer-NOTICE.txt create mode 100644 solr/licenses/prometheus-metrics-tracer-otel-1.1.0.jar.sha1 create mode 100644 solr/licenses/prometheus-metrics-tracer-otel-LICENSE-ASL.txt create mode 100644 solr/licenses/prometheus-metrics-tracer-otel-NOTICE.txt create mode 100644 solr/licenses/prometheus-metrics-tracer-otel-agent-1.1.0.jar.sha1 create mode 100644 solr/licenses/prometheus-metrics-tracer-otel-agent-LICENSE-ASL.txt create mode 100644 solr/licenses/prometheus-metrics-tracer-otel-agent-NOTICE.txt diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreMetric.java index 0ffc2a69c13..08bdd63c4d0 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreMetric.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreMetric.java @@ -17,10 +17,9 @@ package org.apache.solr.metrics.prometheus.core; import com.codahale.metrics.Metric; -import org.apache.solr.metrics.prometheus.SolrPrometheusCoreRegistry; - import java.util.HashMap; import java.util.Map; +import org.apache.solr.metrics.prometheus.SolrPrometheusCoreRegistry; public abstract class SolrCoreMetric { public Metric dropwizardMetric; diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/core/package-info.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/package-info.java new file mode 100644 index 00000000000..8d0cb5a569f --- /dev/null +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/core/package-info.java @@ -0,0 +1,22 @@ +/* + * 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. + */ + +/** + * The {@link org.apache.solr.metrics.prometheus.core.SolrCoreMetric} is a wrapper to export {@link + * com.codahale.metrics.Metric} to {@link io.prometheus.metrics.core.metrics.Metric} + */ +package org.apache.solr.metrics.prometheus.core; diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/package-info.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/package-info.java new file mode 100644 index 00000000000..384d0c42bc4 --- /dev/null +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/package-info.java @@ -0,0 +1,23 @@ +/* + * 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. + */ + +/** + * The {@link org.apache.solr.metrics.prometheus.SolrPrometheusRegistry} is responsible for + * collecting Prometheus metrics from exporting {@link com.codahale.metrics.Metric}'s from {@link + * com.codahale.metrics.MetricRegistry} + */ +package org.apache.solr.metrics.prometheus; diff --git a/solr/licenses/prometheus-metrics-config-1.1.0.jar.sha1 b/solr/licenses/prometheus-metrics-config-1.1.0.jar.sha1 new file mode 100644 index 00000000000..954a48dcf64 --- /dev/null +++ b/solr/licenses/prometheus-metrics-config-1.1.0.jar.sha1 @@ -0,0 +1 @@ +4588ed1d1bbdcebb2663ccef1162f4cc4c5eb9fb diff --git a/solr/licenses/prometheus-metrics-config-LICENSE-ASL.txt b/solr/licenses/prometheus-metrics-config-LICENSE-ASL.txt new file mode 100644 index 00000000000..f49a4e16e68 --- /dev/null +++ b/solr/licenses/prometheus-metrics-config-LICENSE-ASL.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/solr/licenses/prometheus-metrics-config-NOTICE.txt b/solr/licenses/prometheus-metrics-config-NOTICE.txt new file mode 100644 index 00000000000..cbd3cd95bef --- /dev/null +++ b/solr/licenses/prometheus-metrics-config-NOTICE.txt @@ -0,0 +1,11 @@ +Prometheus instrumentation library for JVM applications +Copyright 2012-2015 The Prometheus Authors + +This product includes software developed at +Boxever Ltd. (http://www.boxever.com/). + +This product includes software developed at +SoundCloud Ltd. (http://soundcloud.com/). + +This product includes software developed as part of the +Ocelli project by Netflix Inc. (https://github.com/Netflix/ocelli/). \ No newline at end of file diff --git a/solr/licenses/prometheus-metrics-core-1.1.0.jar.sha1 b/solr/licenses/prometheus-metrics-core-1.1.0.jar.sha1 new file mode 100644 index 00000000000..aefaedc39a6 --- /dev/null +++ b/solr/licenses/prometheus-metrics-core-1.1.0.jar.sha1 @@ -0,0 +1 @@ +b25424c069a44fce42b55626512718d49c9dcc5d diff --git a/solr/licenses/prometheus-metrics-core-LICENSE-ASL.txt b/solr/licenses/prometheus-metrics-core-LICENSE-ASL.txt new file mode 100644 index 00000000000..f49a4e16e68 --- /dev/null +++ b/solr/licenses/prometheus-metrics-core-LICENSE-ASL.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/solr/licenses/prometheus-metrics-core-NOTICE.txt b/solr/licenses/prometheus-metrics-core-NOTICE.txt new file mode 100644 index 00000000000..cbd3cd95bef --- /dev/null +++ b/solr/licenses/prometheus-metrics-core-NOTICE.txt @@ -0,0 +1,11 @@ +Prometheus instrumentation library for JVM applications +Copyright 2012-2015 The Prometheus Authors + +This product includes software developed at +Boxever Ltd. (http://www.boxever.com/). + +This product includes software developed at +SoundCloud Ltd. (http://soundcloud.com/). + +This product includes software developed as part of the +Ocelli project by Netflix Inc. (https://github.com/Netflix/ocelli/). \ No newline at end of file diff --git a/solr/licenses/prometheus-metrics-exposition-formats-1.1.0.jar.sha1 b/solr/licenses/prometheus-metrics-exposition-formats-1.1.0.jar.sha1 new file mode 100644 index 00000000000..60b2586d867 --- /dev/null +++ b/solr/licenses/prometheus-metrics-exposition-formats-1.1.0.jar.sha1 @@ -0,0 +1 @@ +466f12bdde0dcb5b5469d1bd01370db7b62bead3 diff --git a/solr/licenses/prometheus-metrics-exposition-formats-LICENSE-ASL.txt b/solr/licenses/prometheus-metrics-exposition-formats-LICENSE-ASL.txt new file mode 100644 index 00000000000..f49a4e16e68 --- /dev/null +++ b/solr/licenses/prometheus-metrics-exposition-formats-LICENSE-ASL.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/solr/licenses/prometheus-metrics-exposition-formats-NOTICE.txt b/solr/licenses/prometheus-metrics-exposition-formats-NOTICE.txt new file mode 100644 index 00000000000..cbd3cd95bef --- /dev/null +++ b/solr/licenses/prometheus-metrics-exposition-formats-NOTICE.txt @@ -0,0 +1,11 @@ +Prometheus instrumentation library for JVM applications +Copyright 2012-2015 The Prometheus Authors + +This product includes software developed at +Boxever Ltd. (http://www.boxever.com/). + +This product includes software developed at +SoundCloud Ltd. (http://soundcloud.com/). + +This product includes software developed as part of the +Ocelli project by Netflix Inc. (https://github.com/Netflix/ocelli/). \ No newline at end of file diff --git a/solr/licenses/prometheus-metrics-model-1.1.0.jar.sha1 b/solr/licenses/prometheus-metrics-model-1.1.0.jar.sha1 new file mode 100644 index 00000000000..6cac482dd0c --- /dev/null +++ b/solr/licenses/prometheus-metrics-model-1.1.0.jar.sha1 @@ -0,0 +1 @@ +4a6093076e5b526aff26611e6c4f0eb4518211b3 diff --git a/solr/licenses/prometheus-metrics-model-LICENSE-ASL.txt b/solr/licenses/prometheus-metrics-model-LICENSE-ASL.txt new file mode 100644 index 00000000000..f49a4e16e68 --- /dev/null +++ b/solr/licenses/prometheus-metrics-model-LICENSE-ASL.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/solr/licenses/prometheus-metrics-model-NOTICE.txt b/solr/licenses/prometheus-metrics-model-NOTICE.txt new file mode 100644 index 00000000000..cbd3cd95bef --- /dev/null +++ b/solr/licenses/prometheus-metrics-model-NOTICE.txt @@ -0,0 +1,11 @@ +Prometheus instrumentation library for JVM applications +Copyright 2012-2015 The Prometheus Authors + +This product includes software developed at +Boxever Ltd. (http://www.boxever.com/). + +This product includes software developed at +SoundCloud Ltd. (http://soundcloud.com/). + +This product includes software developed as part of the +Ocelli project by Netflix Inc. (https://github.com/Netflix/ocelli/). \ No newline at end of file diff --git a/solr/licenses/prometheus-metrics-shaded-protobuf-1.1.0.jar.sha1 b/solr/licenses/prometheus-metrics-shaded-protobuf-1.1.0.jar.sha1 new file mode 100644 index 00000000000..c593438438d --- /dev/null +++ b/solr/licenses/prometheus-metrics-shaded-protobuf-1.1.0.jar.sha1 @@ -0,0 +1 @@ +5a18603c6281609b0e9e1e7f21d647c6ce994adb diff --git a/solr/licenses/prometheus-metrics-shaded-protobuf-LICENSE-ASL.txt b/solr/licenses/prometheus-metrics-shaded-protobuf-LICENSE-ASL.txt new file mode 100644 index 00000000000..f49a4e16e68 --- /dev/null +++ b/solr/licenses/prometheus-metrics-shaded-protobuf-LICENSE-ASL.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/solr/licenses/prometheus-metrics-shaded-protobuf-NOTICE.txt b/solr/licenses/prometheus-metrics-shaded-protobuf-NOTICE.txt new file mode 100644 index 00000000000..cbd3cd95bef --- /dev/null +++ b/solr/licenses/prometheus-metrics-shaded-protobuf-NOTICE.txt @@ -0,0 +1,11 @@ +Prometheus instrumentation library for JVM applications +Copyright 2012-2015 The Prometheus Authors + +This product includes software developed at +Boxever Ltd. (http://www.boxever.com/). + +This product includes software developed at +SoundCloud Ltd. (http://soundcloud.com/). + +This product includes software developed as part of the +Ocelli project by Netflix Inc. (https://github.com/Netflix/ocelli/). \ No newline at end of file diff --git a/solr/licenses/prometheus-metrics-tracer-common-1.1.0.jar.sha1 b/solr/licenses/prometheus-metrics-tracer-common-1.1.0.jar.sha1 new file mode 100644 index 00000000000..942ecf85c06 --- /dev/null +++ b/solr/licenses/prometheus-metrics-tracer-common-1.1.0.jar.sha1 @@ -0,0 +1 @@ +daf7dbdb867221e418be0771663eae50a9199228 diff --git a/solr/licenses/prometheus-metrics-tracer-common-LICENSE-ASL.txt b/solr/licenses/prometheus-metrics-tracer-common-LICENSE-ASL.txt new file mode 100644 index 00000000000..f49a4e16e68 --- /dev/null +++ b/solr/licenses/prometheus-metrics-tracer-common-LICENSE-ASL.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/solr/licenses/prometheus-metrics-tracer-common-NOTICE.txt b/solr/licenses/prometheus-metrics-tracer-common-NOTICE.txt new file mode 100644 index 00000000000..cbd3cd95bef --- /dev/null +++ b/solr/licenses/prometheus-metrics-tracer-common-NOTICE.txt @@ -0,0 +1,11 @@ +Prometheus instrumentation library for JVM applications +Copyright 2012-2015 The Prometheus Authors + +This product includes software developed at +Boxever Ltd. (http://www.boxever.com/). + +This product includes software developed at +SoundCloud Ltd. (http://soundcloud.com/). + +This product includes software developed as part of the +Ocelli project by Netflix Inc. (https://github.com/Netflix/ocelli/). \ No newline at end of file diff --git a/solr/licenses/prometheus-metrics-tracer-initializer-1.1.0.jar.sha1 b/solr/licenses/prometheus-metrics-tracer-initializer-1.1.0.jar.sha1 new file mode 100644 index 00000000000..f308f25736c --- /dev/null +++ b/solr/licenses/prometheus-metrics-tracer-initializer-1.1.0.jar.sha1 @@ -0,0 +1 @@ +169f3dae0c95b4154696407de0e1213373f074e1 diff --git a/solr/licenses/prometheus-metrics-tracer-initializer-LICENSE-ASL.txt b/solr/licenses/prometheus-metrics-tracer-initializer-LICENSE-ASL.txt new file mode 100644 index 00000000000..f49a4e16e68 --- /dev/null +++ b/solr/licenses/prometheus-metrics-tracer-initializer-LICENSE-ASL.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/solr/licenses/prometheus-metrics-tracer-initializer-NOTICE.txt b/solr/licenses/prometheus-metrics-tracer-initializer-NOTICE.txt new file mode 100644 index 00000000000..cbd3cd95bef --- /dev/null +++ b/solr/licenses/prometheus-metrics-tracer-initializer-NOTICE.txt @@ -0,0 +1,11 @@ +Prometheus instrumentation library for JVM applications +Copyright 2012-2015 The Prometheus Authors + +This product includes software developed at +Boxever Ltd. (http://www.boxever.com/). + +This product includes software developed at +SoundCloud Ltd. (http://soundcloud.com/). + +This product includes software developed as part of the +Ocelli project by Netflix Inc. (https://github.com/Netflix/ocelli/). \ No newline at end of file diff --git a/solr/licenses/prometheus-metrics-tracer-otel-1.1.0.jar.sha1 b/solr/licenses/prometheus-metrics-tracer-otel-1.1.0.jar.sha1 new file mode 100644 index 00000000000..c28f7197ac4 --- /dev/null +++ b/solr/licenses/prometheus-metrics-tracer-otel-1.1.0.jar.sha1 @@ -0,0 +1 @@ +25c2d488b084a9757a7b5e23cbce8dc812147e54 diff --git a/solr/licenses/prometheus-metrics-tracer-otel-LICENSE-ASL.txt b/solr/licenses/prometheus-metrics-tracer-otel-LICENSE-ASL.txt new file mode 100644 index 00000000000..f49a4e16e68 --- /dev/null +++ b/solr/licenses/prometheus-metrics-tracer-otel-LICENSE-ASL.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/solr/licenses/prometheus-metrics-tracer-otel-NOTICE.txt b/solr/licenses/prometheus-metrics-tracer-otel-NOTICE.txt new file mode 100644 index 00000000000..cbd3cd95bef --- /dev/null +++ b/solr/licenses/prometheus-metrics-tracer-otel-NOTICE.txt @@ -0,0 +1,11 @@ +Prometheus instrumentation library for JVM applications +Copyright 2012-2015 The Prometheus Authors + +This product includes software developed at +Boxever Ltd. (http://www.boxever.com/). + +This product includes software developed at +SoundCloud Ltd. (http://soundcloud.com/). + +This product includes software developed as part of the +Ocelli project by Netflix Inc. (https://github.com/Netflix/ocelli/). \ No newline at end of file diff --git a/solr/licenses/prometheus-metrics-tracer-otel-agent-1.1.0.jar.sha1 b/solr/licenses/prometheus-metrics-tracer-otel-agent-1.1.0.jar.sha1 new file mode 100644 index 00000000000..45a83f1dda1 --- /dev/null +++ b/solr/licenses/prometheus-metrics-tracer-otel-agent-1.1.0.jar.sha1 @@ -0,0 +1 @@ +393255f85063e08684131ac75af5e65aef070a60 diff --git a/solr/licenses/prometheus-metrics-tracer-otel-agent-LICENSE-ASL.txt b/solr/licenses/prometheus-metrics-tracer-otel-agent-LICENSE-ASL.txt new file mode 100644 index 00000000000..f49a4e16e68 --- /dev/null +++ b/solr/licenses/prometheus-metrics-tracer-otel-agent-LICENSE-ASL.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. \ No newline at end of file diff --git a/solr/licenses/prometheus-metrics-tracer-otel-agent-NOTICE.txt b/solr/licenses/prometheus-metrics-tracer-otel-agent-NOTICE.txt new file mode 100644 index 00000000000..cbd3cd95bef --- /dev/null +++ b/solr/licenses/prometheus-metrics-tracer-otel-agent-NOTICE.txt @@ -0,0 +1,11 @@ +Prometheus instrumentation library for JVM applications +Copyright 2012-2015 The Prometheus Authors + +This product includes software developed at +Boxever Ltd. (http://www.boxever.com/). + +This product includes software developed at +SoundCloud Ltd. (http://soundcloud.com/). + +This product includes software developed as part of the +Ocelli project by Netflix Inc. (https://github.com/Netflix/ocelli/). \ No newline at end of file From d00b2492dcce72b346436b26909bd070b77d2b40 Mon Sep 17 00:00:00 2001 From: mbiscocho Date: Wed, 17 Apr 2024 10:51:03 -0400 Subject: [PATCH 25/25] Remove functions that break tests --- solr/core/build.gradle | 3 ++- .../prometheus/SolrPrometheusRegistry.java | 17 ++++------------- versions.lock | 2 +- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/solr/core/build.gradle b/solr/core/build.gradle index 5e9d46af985..a7d0df10b64 100644 --- a/solr/core/build.gradle +++ b/solr/core/build.gradle @@ -154,8 +154,9 @@ dependencies { runtimeOnly 'org.apache.logging.log4j:log4j-slf4j2-impl' // Prometheus client - implementation 'io.prometheus:prometheus-metrics-exposition-formats:1.1.0' implementation 'io.prometheus:prometheus-metrics-core:1.1.0' + implementation 'io.prometheus:prometheus-metrics-model:1.1.0' + implementation 'io.prometheus:prometheus-metrics-exposition-formats:1.1.0' // For faster XML processing than the JDK implementation 'org.codehaus.woodstox:stax2-api' diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java index 912dffb146e..e50da37298d 100644 --- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java +++ b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusRegistry.java @@ -18,7 +18,6 @@ import com.codahale.metrics.Meter; import com.codahale.metrics.Timer; -import com.google.common.collect.ImmutableMap; import io.prometheus.metrics.core.metrics.Counter; import io.prometheus.metrics.core.metrics.Gauge; import io.prometheus.metrics.model.registry.PrometheusRegistry; @@ -46,17 +45,9 @@ public String getRegistryName() { return registryName; } - public Map copyOfCounters() { - return ImmutableMap.copyOf(metricCounters); - } - - public Map copyOfGauges() { - return ImmutableMap.copyOf(metricGauges); - } - public void exportMeter( Meter dropwizardMetric, String prometheusMetricName, Map labelsMap) { - if (!copyOfCounters().containsKey(prometheusMetricName)) { + if (!metricCounters.containsKey(prometheusMetricName)) { ArrayList labels = new ArrayList<>(labelsMap.keySet()); registerCounter(prometheusMetricName, labels.toArray(String[]::new)); } @@ -70,7 +61,7 @@ public void exportCounter( com.codahale.metrics.Counter dropwizardMetric, String prometheusMetricName, Map labelsMap) { - if (!copyOfCounters().containsKey(prometheusMetricName)) { + if (!metricCounters.containsKey(prometheusMetricName)) { ArrayList labels = new ArrayList<>(labelsMap.keySet()); registerCounter(prometheusMetricName, labels.toArray(String[]::new)); } @@ -82,7 +73,7 @@ public void exportCounter( public void exportTimer( Timer dropwizardMetric, String prometheusMetricName, Map labelsMap) { - if (!copyOfGauges().containsKey(prometheusMetricName)) { + if (!metricCounters.containsKey(prometheusMetricName)) { ArrayList labels = new ArrayList<>(labelsMap.keySet()); registerGauge(prometheusMetricName, labels.toArray(String[]::new)); } @@ -97,7 +88,7 @@ public void exportGauge( String prometheusMetricName, Map labelsMap) { Object dropwizardMetric = (dropwizardMetricRaw).getValue(); - if (!copyOfGauges().containsKey(prometheusMetricName)) { + if (!metricGauges.containsKey(prometheusMetricName)) { ArrayList labels = new ArrayList<>(labelsMap.keySet()); if (dropwizardMetric instanceof HashMap) { labels.add("item"); diff --git a/versions.lock b/versions.lock index 46b5426ef88..2d11a7b1716 100644 --- a/versions.lock +++ b/versions.lock @@ -148,7 +148,7 @@ io.perfmark:perfmark-api:0.26.0 (3 constraints: 21212b16) io.prometheus:prometheus-metrics-config:1.1.0 (2 constraints: a926cf59) io.prometheus:prometheus-metrics-core:1.1.0 (1 constraints: 0405f335) io.prometheus:prometheus-metrics-exposition-formats:1.1.0 (1 constraints: 0405f335) -io.prometheus:prometheus-metrics-model:1.1.0 (2 constraints: a926cf59) +io.prometheus:prometheus-metrics-model:1.1.0 (3 constraints: ac2b1ea3) io.prometheus:prometheus-metrics-shaded-protobuf:1.1.0 (1 constraints: 3e164ed8) io.prometheus:prometheus-metrics-tracer-common:1.1.0 (3 constraints: 993ee7d1) io.prometheus:prometheus-metrics-tracer-initializer:1.1.0 (1 constraints: 6c1022a8)