You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ml...@apache.org on 2025/09/26 23:00:40 UTC
(solr) branch feature/SOLR-17458-rebased updated: Test failures and builds from bad rebase
This is an automated email from the ASF dual-hosted git repository.
mlbiscoc pushed a commit to branch feature/SOLR-17458-rebased
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/feature/SOLR-17458-rebased by this push:
new b33762e7129 Test failures and builds from bad rebase
b33762e7129 is described below
commit b33762e7129689bf69d9db210063b79a27613923
Author: Matthew Biscocho <ml...@apache.org>
AuthorDate: Fri Sep 26 19:00:10 2025 -0400
Test failures and builds from bad rebase
---
solr/core/build.gradle | 2 +
solr/core/gradle.lockfile | 3 +-
.../apache/solr/metrics/SolrCoreMetricManager.java | 2 +-
.../prometheus/SolrPrometheusFormatter.java | 276 ---------------------
.../prometheus/core/SolrCoreHandlerMetric.java | 72 ------
.../prometheus/core/SolrCoreSearcherMetric.java | 64 -----
.../prometheus/node/SolrNodeHandlerMetric.java | 59 -----
.../stats/InstrumentedHttpRequestExecutor.java | 161 ------------
...rumentedPoolingHttpClientConnectionManager.java | 78 ------
.../apache/solr/cloud/TestPullReplicaWithAuth.java | 2 +-
.../org/apache/solr/cloud/TestTlogReplica.java | 2 +-
.../impl/PlacementPluginIntegrationTest.java | 4 +-
.../solr/handler/RequestHandlerMetricsTest.java | 2 +-
.../solr/handler/admin/MBeansHandlerTest.java | 2 +-
.../solr/metrics/SolrCoreMetricManagerTest.java | 3 +-
.../solr/metrics/SolrMetricsIntegrationTest.java | 1 +
.../solr/metrics/SolrPrometheusFormatterTest.java | 208 ----------------
.../SolrStandaloneScraperBasicAuthTest.java | 2 +-
.../scraper/SolrStandaloneScraperTest.java | 2 +-
...bstractCollectionsAPIDistributedZkTestBase.java | 2 +-
20 files changed, 16 insertions(+), 931 deletions(-)
diff --git a/solr/core/build.gradle b/solr/core/build.gradle
index 12502f94c16..84db3e87650 100644
--- a/solr/core/build.gradle
+++ b/solr/core/build.gradle
@@ -222,4 +222,6 @@ dependencies {
})
testImplementation libs.apache.httpcomponents.httpclient
testImplementation libs.apache.httpcomponents.httpcore
+
+ testImplementation libs.opentelemetry.sdktesting
}
diff --git a/solr/core/gradle.lockfile b/solr/core/gradle.lockfile
index b82b394cf01..780c9cfbd15 100644
--- a/solr/core/gradle.lockfile
+++ b/solr/core/gradle.lockfile
@@ -71,8 +71,9 @@ io.opentelemetry:opentelemetry-exporter-common:1.50.0=jarValidation,runtimeClass
io.opentelemetry:opentelemetry-exporter-prometheus:1.50.0-alpha=compileClasspath,jarValidation,runtimeClasspath,runtimeLibs,testCompileClasspath,testRuntimeClasspath
io.opentelemetry:opentelemetry-sdk-common:1.53.0=compileClasspath,jarValidation,runtimeClasspath,runtimeLibs,testCompileClasspath,testRuntimeClasspath
io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi:1.50.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
-io.opentelemetry:opentelemetry-sdk-logs:1.53.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
+io.opentelemetry:opentelemetry-sdk-logs:1.53.0=jarValidation,runtimeClasspath,runtimeLibs,testCompileClasspath,testRuntimeClasspath
io.opentelemetry:opentelemetry-sdk-metrics:1.53.0=compileClasspath,jarValidation,runtimeClasspath,runtimeLibs,testCompileClasspath,testRuntimeClasspath
+io.opentelemetry:opentelemetry-sdk-testing:1.53.0=jarValidation,testCompileClasspath,testRuntimeClasspath
io.opentelemetry:opentelemetry-sdk-trace:1.53.0=compileClasspath,jarValidation,runtimeClasspath,runtimeLibs,testCompileClasspath,testRuntimeClasspath
io.opentelemetry:opentelemetry-sdk:1.53.0=compileClasspath,jarValidation,runtimeClasspath,runtimeLibs,testCompileClasspath,testRuntimeClasspath
io.prometheus:prometheus-metrics-config:1.3.6=jarValidation,testRuntimeClasspath
diff --git a/solr/core/src/java/org/apache/solr/metrics/SolrCoreMetricManager.java b/solr/core/src/java/org/apache/solr/metrics/SolrCoreMetricManager.java
index 99dec259ff6..683e71b283e 100644
--- a/solr/core/src/java/org/apache/solr/metrics/SolrCoreMetricManager.java
+++ b/solr/core/src/java/org/apache/solr/metrics/SolrCoreMetricManager.java
@@ -191,7 +191,7 @@ public class SolrCoreMetricManager implements Closeable {
metricManager.unregisterGauges(
solrMetricsContext.getRegistryName(), solrMetricsContext.getTag());
- metricManager.meterProvider(solrMetricsContext.getRegistryName()).close();
+ metricManager.removeRegistry(solrMetricsContext.getRegistryName());
registeredProducers.clear();
}
diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusFormatter.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusFormatter.java
deleted file mode 100644
index 7a036336d8d..00000000000
--- a/solr/core/src/java/org/apache/solr/metrics/prometheus/SolrPrometheusFormatter.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * 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;
-import com.codahale.metrics.Metric;
-import com.codahale.metrics.Snapshot;
-import com.codahale.metrics.Timer;
-import io.prometheus.metrics.model.snapshots.CounterSnapshot;
-import io.prometheus.metrics.model.snapshots.Exemplars;
-import io.prometheus.metrics.model.snapshots.GaugeSnapshot;
-import io.prometheus.metrics.model.snapshots.Labels;
-import io.prometheus.metrics.model.snapshots.MetricMetadata;
-import io.prometheus.metrics.model.snapshots.MetricSnapshot;
-import io.prometheus.metrics.model.snapshots.MetricSnapshots;
-import io.prometheus.metrics.model.snapshots.Quantile;
-import io.prometheus.metrics.model.snapshots.Quantiles;
-import io.prometheus.metrics.model.snapshots.SummarySnapshot;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.solr.util.stats.MetricUtils;
-
-/**
- * Base class for all {@link SolrPrometheusFormatter} holding {@link MetricSnapshot}s. Can export
- * {@link com.codahale.metrics.Metric} to {@link MetricSnapshot} to be outputted for {@link
- * org.apache.solr.response.PrometheusResponseWriter}
- */
-public abstract class SolrPrometheusFormatter {
- protected final Map<String, List<CounterSnapshot.CounterDataPointSnapshot>> metricCounters;
- protected final Map<String, List<GaugeSnapshot.GaugeDataPointSnapshot>> metricGauges;
- protected final Map<String, List<SummarySnapshot.SummaryDataPointSnapshot>> metricSummaries;
-
- public SolrPrometheusFormatter() {
- this.metricCounters = new HashMap<>();
- this.metricGauges = new HashMap<>();
- this.metricSummaries = new HashMap<>();
- }
-
- /**
- * Export {@link Metric} to {@link io.prometheus.metrics.model.snapshots.MetricSnapshot} and
- * register the Snapshot
- *
- * @param dropwizardMetric the {@link Metric} to be exported
- * @param metricName Dropwizard metric name
- */
- public abstract void exportDropwizardMetric(Metric dropwizardMetric, String metricName);
-
- /**
- * Categorize {@link Metric} based on the metric name
- *
- * @param dropwizardMetric the {@link Metric} to be exported
- * @param metricName Dropwizard metric name
- */
- public abstract SolrMetric categorizeMetric(Metric dropwizardMetric, String metricName);
-
- /**
- * Export {@link Meter} to {@link
- * io.prometheus.metrics.model.snapshots.CounterSnapshot.CounterDataPointSnapshot} and collect
- * datapoint
- *
- * @param metricName name of metric after export
- * @param dropwizardMetric the {@link Meter} to be exported
- * @param labels label names and values to record
- */
- public void exportMeter(String metricName, Meter dropwizardMetric, Labels labels) {
- CounterSnapshot.CounterDataPointSnapshot dataPoint =
- createCounterDatapoint((double) dropwizardMetric.getCount(), labels);
- collectCounterDatapoint(metricName, dataPoint);
- }
-
- /**
- * Export {@link com.codahale.metrics.Counter} to {@link
- * io.prometheus.metrics.model.snapshots.CounterSnapshot.CounterDataPointSnapshot} and collect
- * datapoint
- *
- * @param metricName name of prometheus metric
- * @param dropwizardMetric the {@link com.codahale.metrics.Counter} to be exported
- * @param labels label names and values to record
- */
- public void exportCounter(
- String metricName, com.codahale.metrics.Counter dropwizardMetric, Labels labels) {
- CounterSnapshot.CounterDataPointSnapshot dataPoint =
- createCounterDatapoint((double) dropwizardMetric.getCount(), labels);
- collectCounterDatapoint(metricName, dataPoint);
- }
-
- /**
- * Export {@link Timer} ands its quantile data to {@link
- * io.prometheus.metrics.model.snapshots.SummarySnapshot.SummaryDataPointSnapshot} and collect
- * datapoint
- *
- * @param metricName name of prometheus metric
- * @param dropwizardMetric the {@link Timer} to be exported
- * @param labels label names and values to record
- */
- public void exportTimer(String metricName, Timer dropwizardMetric, Labels labels) {
- Snapshot snapshot = dropwizardMetric.getSnapshot();
-
- long count = snapshot.size();
- double sum =
- Arrays.stream(snapshot.getValues())
- .asDoubleStream()
- .map(num -> MetricUtils.nsToMs(num))
- .sum();
-
- Quantiles quantiles =
- Quantiles.of(
- List.of(
- new Quantile(0.50, MetricUtils.nsToMs(snapshot.getMedian())),
- new Quantile(0.75, MetricUtils.nsToMs(snapshot.get75thPercentile())),
- new Quantile(0.99, MetricUtils.nsToMs(snapshot.get99thPercentile())),
- new Quantile(0.999, MetricUtils.nsToMs(snapshot.get999thPercentile()))));
-
- var summary =
- new SummarySnapshot.SummaryDataPointSnapshot(
- count, sum, quantiles, labels, Exemplars.EMPTY, 0L);
- collectSummaryDatapoint(metricName, summary);
- }
-
- /**
- * Export {@link Timer} ands its Count to {@link
- * io.prometheus.metrics.model.snapshots.CounterSnapshot.CounterDataPointSnapshot} and collect
- * datapoint
- *
- * @param metricName name of prometheus metric
- * @param dropwizardMetric the {@link Timer} to be exported
- * @param labels label names and values to record
- */
- public void exportTimerCount(String metricName, Timer dropwizardMetric, Labels labels) {
- CounterSnapshot.CounterDataPointSnapshot dataPoint =
- createCounterDatapoint((double) dropwizardMetric.getCount(), labels);
- collectCounterDatapoint(metricName, dataPoint);
- }
-
- /**
- * Export {@link com.codahale.metrics.Gauge} to {@link
- * io.prometheus.metrics.model.snapshots.GaugeSnapshot.GaugeDataPointSnapshot} and collect to
- * datapoint. Unlike other Dropwizard metric types, Gauges can have more complex types. In the
- * case of a hashmap, collect each as an individual metric and have its key appended as a label to
- * the metric called "item"
- *
- * @param metricName name of prometheus metric
- * @param dropwizardMetricRaw the {@link com.codahale.metrics.Gauge} to be exported
- * @param labels label names and values to record
- */
- public void exportGauge(
- String metricName, com.codahale.metrics.Gauge<?> dropwizardMetricRaw, Labels labels) {
- Object dropwizardMetric = (dropwizardMetricRaw).getValue();
- if (dropwizardMetric instanceof Number) {
- GaugeSnapshot.GaugeDataPointSnapshot dataPoint =
- createGaugeDatapoint(((Number) dropwizardMetric).doubleValue(), labels);
- collectGaugeDatapoint(metricName, dataPoint);
- } else if (dropwizardMetric instanceof HashMap<?, ?> itemsMap) {
- for (Object item : itemsMap.keySet()) {
- if (itemsMap.get(item) instanceof Number) {
- GaugeSnapshot.GaugeDataPointSnapshot dataPoint =
- createGaugeDatapoint(
- ((Number) itemsMap.get(item)).doubleValue(),
- labels.merge(Labels.of("item", (String) item)));
- collectGaugeDatapoint(metricName, dataPoint);
- }
- }
- }
- }
-
- /**
- * Create a {@link io.prometheus.metrics.model.snapshots.CounterSnapshot.CounterDataPointSnapshot}
- * with labels
- *
- * @param value metric value
- * @param labels set of name/values labels
- */
- public CounterSnapshot.CounterDataPointSnapshot createCounterDatapoint(
- double value, Labels labels) {
- return CounterSnapshot.CounterDataPointSnapshot.builder().value(value).labels(labels).build();
- }
-
- /**
- * Create a {@link io.prometheus.metrics.model.snapshots.GaugeSnapshot.GaugeDataPointSnapshot}
- * with labels
- *
- * @param value metric value
- * @param labels set of name/values labels
- */
- public GaugeSnapshot.GaugeDataPointSnapshot createGaugeDatapoint(double value, Labels labels) {
- return GaugeSnapshot.GaugeDataPointSnapshot.builder().value(value).labels(labels).build();
- }
-
- /**
- * Collects {@link io.prometheus.metrics.model.snapshots.CounterSnapshot.CounterDataPointSnapshot}
- * and appends to existing metric or create new metric if name does not exist
- *
- * @param metricName Name of metric
- * @param dataPoint Counter datapoint to be collected
- */
- public void collectCounterDatapoint(
- String metricName, CounterSnapshot.CounterDataPointSnapshot dataPoint) {
- if (!metricCounters.containsKey(metricName)) {
- metricCounters.put(metricName, new ArrayList<>());
- }
- metricCounters.get(metricName).add(dataPoint);
- }
-
- /**
- * Collects {@link io.prometheus.metrics.model.snapshots.GaugeSnapshot.GaugeDataPointSnapshot} and
- * appends to existing metric or create new metric if name does not exist
- *
- * @param metricName Name of metric
- * @param dataPoint Gauge datapoint to be collected
- */
- public void collectGaugeDatapoint(
- String metricName, GaugeSnapshot.GaugeDataPointSnapshot dataPoint) {
- if (!metricGauges.containsKey(metricName)) {
- metricGauges.put(metricName, new ArrayList<>());
- }
- metricGauges.get(metricName).add(dataPoint);
- }
-
- /**
- * Collects {@link io.prometheus.metrics.model.snapshots.SummarySnapshot.SummaryDataPointSnapshot}
- * and appends to existing metric or create new metric if name does not exist
- *
- * @param metricName Name of metric
- * @param dataPoint Gauge datapoint to be collected
- */
- public void collectSummaryDatapoint(
- String metricName, SummarySnapshot.SummaryDataPointSnapshot dataPoint) {
- metricSummaries.computeIfAbsent(metricName, k -> new ArrayList<>()).add(dataPoint);
- }
-
- /**
- * Returns an immutable {@link MetricSnapshots} from the {@link
- * io.prometheus.metrics.model.snapshots.DataPointSnapshot}s collected from the registry
- */
- public MetricSnapshots collect() {
- ArrayList<MetricSnapshot> snapshots = new ArrayList<>();
-
- metricCounters
- .entrySet()
- .forEach(
- entry ->
- snapshots.add(
- new CounterSnapshot(new MetricMetadata(entry.getKey()), entry.getValue())));
- metricGauges
- .entrySet()
- .forEach(
- entry ->
- snapshots.add(
- new GaugeSnapshot(new MetricMetadata(entry.getKey()), entry.getValue())));
- metricSummaries
- .entrySet()
- .forEach(
- entry ->
- snapshots.add(
- new SummarySnapshot(new MetricMetadata(entry.getKey()), entry.getValue())));
-
- return new MetricSnapshots(snapshots);
- }
-}
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
deleted file mode 100644
index ac61d6ef6f7..00000000000
--- a/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreHandlerMetric.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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;
-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.SolrPrometheusFormatter;
-
-/** Dropwizard metrics of name ADMIN/QUERY/UPDATE/REPLICATION.* */
-public class SolrCoreHandlerMetric extends SolrCoreMetric {
- 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_REQUEST_TIMES = "solr_metrics_core_request_time_ms";
-
- public SolrCoreHandlerMetric(Metric dropwizardMetric, String metricName) {
- super(dropwizardMetric, metricName);
- }
-
- /*
- * Metric examples being exported
- *
- * QUERY./select.totalTime
- * UPDATE./update.requests
- * UPDATE./update.totalTime
- */
-
- @Override
- public SolrCoreMetric parseLabels() {
- String[] parsedMetric = metricName.split("\\.");
- labels.put("category", parsedMetric[0]);
- labels.put("handler", parsedMetric[1]);
- labels.put("type", parsedMetric[2]);
- return this;
- }
-
- @Override
- public void toPrometheus(SolrPrometheusFormatter formatter) {
- if (dropwizardMetric instanceof Meter) {
- formatter.exportMeter(CORE_REQUESTS_TOTAL, (Meter) dropwizardMetric, getLabels());
- } else if (dropwizardMetric instanceof Counter) {
- if (metricName.endsWith("requests")) {
- formatter.exportCounter(CORE_REQUESTS_TOTAL, (Counter) dropwizardMetric, getLabels());
- }
- } else if (dropwizardMetric instanceof Gauge) {
- if (!metricName.endsWith("handlerStart")) {
- formatter.exportGauge(
- CORE_REQUESTS_UPDATE_HANDLER, (Gauge<?>) dropwizardMetric, getLabels());
- }
- } else if (dropwizardMetric instanceof Timer) {
- // Do not need type label for request times
- labels.remove("type");
- formatter.exportTimer(CORE_REQUEST_TIMES, (Timer) dropwizardMetric, getLabels());
- }
- }
-}
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
deleted file mode 100644
index 0ab89e325c7..00000000000
--- a/solr/core/src/java/org/apache/solr/metrics/prometheus/core/SolrCoreSearcherMetric.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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;
-
-import com.codahale.metrics.Counter;
-import com.codahale.metrics.Gauge;
-import com.codahale.metrics.Metric;
-import com.codahale.metrics.Timer;
-import org.apache.solr.metrics.prometheus.SolrPrometheusFormatter;
-
-/** Dropwizard metrics of name SEARCHER.* */
-public class SolrCoreSearcherMetric extends SolrCoreMetric {
- public static final String CORE_SEARCHER_METRICS = "solr_metrics_core_searcher_documents";
- public static final String CORE_SEARCHER_TIMES = "solr_metrics_core_searcher_warmup_time_ms";
-
- public SolrCoreSearcherMetric(Metric dropwizardMetric, String metricName) {
- super(dropwizardMetric, metricName);
- }
-
- /*
- * Metric examples being exported
- * SEARCHER.searcher.deletedDocs
- * SEARCHER.new.time
- */
-
- @Override
- public SolrCoreMetric parseLabels() {
- String[] parsedMetric = metricName.split("\\.");
- if (!(dropwizardMetric instanceof Counter)) {
- labels.put("type", parsedMetric[2]);
- }
- return this;
- }
-
- @Override
- public void toPrometheus(SolrPrometheusFormatter formatter) {
- if (dropwizardMetric instanceof Gauge) {
- if (metricName.endsWith("liveDocsCache")) {
- formatter.exportGauge(
- CORE_CACHE_SEARCHER_METRICS, (Gauge<?>) dropwizardMetric, getLabels());
- } else {
- formatter.exportGauge(CORE_SEARCHER_METRICS, (Gauge<?>) dropwizardMetric, getLabels());
- }
- } else if (dropwizardMetric instanceof Timer) {
- formatter.exportTimer(CORE_SEARCHER_TIMES, (Timer) dropwizardMetric, getLabels());
- }
- }
-}
diff --git a/solr/core/src/java/org/apache/solr/metrics/prometheus/node/SolrNodeHandlerMetric.java b/solr/core/src/java/org/apache/solr/metrics/prometheus/node/SolrNodeHandlerMetric.java
deleted file mode 100644
index bb4b84bd52e..00000000000
--- a/solr/core/src/java/org/apache/solr/metrics/prometheus/node/SolrNodeHandlerMetric.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.node;
-
-import com.codahale.metrics.Counter;
-import com.codahale.metrics.Meter;
-import com.codahale.metrics.Metric;
-import org.apache.solr.metrics.prometheus.SolrMetric;
-import org.apache.solr.metrics.prometheus.SolrPrometheusFormatter;
-
-/* Dropwizard metrics of name ADMIN.* and UPDATE.* */
-public class SolrNodeHandlerMetric extends SolrNodeMetric {
- public static final String NODE_REQUESTS = "solr_metrics_node_requests";
- public static final String NODE_SECONDS_TOTAL = "solr_metrics_node_requests_time";
-
- public SolrNodeHandlerMetric(Metric dropwizardMetric, String metricName) {
- super(dropwizardMetric, metricName);
- }
-
- /*
- * Metric examples being exported
- * ADMIN./admin/collections.requests
- */
-
- @Override
- public SolrMetric parseLabels() {
- String[] parsedMetric = metricName.split("\\.");
- labels.put("category", parsedMetric[0]);
- labels.put("handler", parsedMetric[1]);
- labels.put("type", parsedMetric[2]);
- return this;
- }
-
- @Override
- public void toPrometheus(SolrPrometheusFormatter formatter) {
- if (metricName.endsWith(".totalTime")) {
- labels.remove("type");
- formatter.exportCounter(NODE_SECONDS_TOTAL, (Counter) dropwizardMetric, getLabels());
- } else if (dropwizardMetric instanceof Meter) {
- formatter.exportMeter(NODE_REQUESTS, (Meter) dropwizardMetric, getLabels());
- } else if (dropwizardMetric instanceof Counter) {
- formatter.exportCounter(NODE_REQUESTS, (Counter) dropwizardMetric, getLabels());
- }
- }
-}
diff --git a/solr/core/src/java/org/apache/solr/util/stats/InstrumentedHttpRequestExecutor.java b/solr/core/src/java/org/apache/solr/util/stats/InstrumentedHttpRequestExecutor.java
deleted file mode 100644
index 0473d9e0cee..00000000000
--- a/solr/core/src/java/org/apache/solr/util/stats/InstrumentedHttpRequestExecutor.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * 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.util.stats;
-
-import static org.apache.solr.metrics.SolrMetricManager.mkName;
-
-import com.codahale.metrics.Timer;
-import io.opentelemetry.api.common.Attributes;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.util.Locale;
-import java.util.Map;
-import org.apache.http.HttpClientConnection;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.RequestLine;
-import org.apache.http.client.methods.HttpRequestWrapper;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestExecutor;
-import org.apache.solr.common.util.CollectionUtil;
-import org.apache.solr.metrics.SolrMetricProducer;
-import org.apache.solr.metrics.SolrMetricsContext;
-import org.apache.solr.util.tracing.TraceUtils;
-
-/**
- * Sub-class of HttpRequestExecutor which tracks metrics interesting to solr Inspired and partially
- * copied from dropwizard httpclient library
- */
-public class InstrumentedHttpRequestExecutor extends HttpRequestExecutor
- implements SolrMetricProducer {
- public static final HttpClientMetricNameStrategy QUERYLESS_URL_AND_METHOD =
- (scope, request) -> {
- try {
- final RequestLine requestLine = request.getRequestLine();
- String schemeHostPort = null;
- if (request instanceof HttpRequestWrapper wrapper) {
- if (wrapper.getTarget() != null) {
- schemeHostPort =
- wrapper.getTarget().getSchemeName()
- + "://"
- + wrapper.getTarget().getHostName()
- + ":"
- + wrapper.getTarget().getPort();
- }
- }
- final URIBuilder url = new URIBuilder(requestLine.getUri());
- return mkName(
- (schemeHostPort != null ? schemeHostPort : "")
- + url.removeQuery().build().toString()
- + "."
- + methodNameString(request),
- scope);
- } catch (URISyntaxException e) {
- throw new IllegalArgumentException(e);
- }
- };
-
- public static final HttpClientMetricNameStrategy METHOD_ONLY =
- (scope, request) -> mkName(methodNameString(request), scope);
-
- public static final HttpClientMetricNameStrategy HOST_AND_METHOD =
- (scope, request) -> {
- try {
- final RequestLine requestLine = request.getRequestLine();
- String schemeHostPort = null;
- if (request instanceof HttpRequestWrapper wrapper) {
- if (wrapper.getTarget() != null) {
- schemeHostPort =
- wrapper.getTarget().getSchemeName()
- + "://"
- + wrapper.getTarget().getHostName()
- + ":"
- + wrapper.getTarget().getPort();
- }
- }
- final URIBuilder url = new URIBuilder(requestLine.getUri());
- return mkName(
- (schemeHostPort != null ? schemeHostPort : "") + "." + methodNameString(request),
- scope);
- } catch (URISyntaxException e) {
- throw new IllegalArgumentException(e);
- }
- };
-
- public static final Map<String, HttpClientMetricNameStrategy> KNOWN_METRIC_NAME_STRATEGIES =
- CollectionUtil.newHashMap(3);
-
- static {
- KNOWN_METRIC_NAME_STRATEGIES.put("queryLessURLAndMethod", QUERYLESS_URL_AND_METHOD);
- KNOWN_METRIC_NAME_STRATEGIES.put("hostAndMethod", HOST_AND_METHOD);
- KNOWN_METRIC_NAME_STRATEGIES.put("methodOnly", METHOD_ONLY);
- }
-
- protected String scope;
- protected HttpClientMetricNameStrategy nameStrategy;
- protected SolrMetricsContext solrMetricsContext;
-
- public InstrumentedHttpRequestExecutor(
- int waitForContinue, HttpClientMetricNameStrategy nameStrategy) {
- super(waitForContinue);
- this.nameStrategy = nameStrategy;
- }
-
- public InstrumentedHttpRequestExecutor(HttpClientMetricNameStrategy nameStrategy) {
- this.nameStrategy = nameStrategy;
- }
-
- private static String methodNameString(HttpRequest request) {
- return request.getRequestLine().getMethod().toLowerCase(Locale.ROOT) + ".requests";
- }
-
- @Override
- public SolrMetricsContext getSolrMetricsContext() {
- return solrMetricsContext;
- }
-
- @Override
- public HttpResponse execute(HttpRequest request, HttpClientConnection conn, HttpContext context)
- throws IOException, HttpException {
- Timer.Context timerContext = null;
- if (solrMetricsContext != null) {
- timerContext = timer(request).time();
- }
- TraceUtils.injectTraceContext(request);
- try {
- return super.execute(request, conn, context);
- } finally {
- if (timerContext != null) {
- timerContext.stop();
- }
- }
- }
-
- private Timer timer(HttpRequest request) {
- return solrMetricsContext.timer(null, nameStrategy.getNameFor(scope, request));
- }
-
- @Override
- public void initializeMetrics(
- SolrMetricsContext parentContext, Attributes attributes, String scope) {
- this.solrMetricsContext = parentContext.getChildContext(this);
- this.scope = scope;
- }
-}
diff --git a/solr/core/src/java/org/apache/solr/util/stats/InstrumentedPoolingHttpClientConnectionManager.java b/solr/core/src/java/org/apache/solr/util/stats/InstrumentedPoolingHttpClientConnectionManager.java
deleted file mode 100644
index 8174613c72a..00000000000
--- a/solr/core/src/java/org/apache/solr/util/stats/InstrumentedPoolingHttpClientConnectionManager.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.util.stats;
-
-import io.opentelemetry.api.common.Attributes;
-import org.apache.http.config.Registry;
-import org.apache.http.conn.socket.ConnectionSocketFactory;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.apache.solr.metrics.SolrMetricManager;
-import org.apache.solr.metrics.SolrMetricProducer;
-import org.apache.solr.metrics.SolrMetricsContext;
-
-/**
- * Sub-class of PoolingHttpClientConnectionManager which tracks metrics interesting to Solr.
- * Inspired by dropwizard metrics-httpclient library implementation.
- */
-public class InstrumentedPoolingHttpClientConnectionManager
- extends PoolingHttpClientConnectionManager implements SolrMetricProducer {
-
- private SolrMetricsContext solrMetricsContext;
-
- public InstrumentedPoolingHttpClientConnectionManager(
- Registry<ConnectionSocketFactory> socketFactoryRegistry) {
- super(socketFactoryRegistry);
- }
-
- @Override
- public SolrMetricsContext getSolrMetricsContext() {
- return solrMetricsContext;
- }
-
- // TODO SOLR-17458: Migrate to Otel
- @Override
- public void initializeMetrics(
- SolrMetricsContext parentContext, Attributes attributes, String scope) {
- this.solrMetricsContext = parentContext.getChildContext(this);
- solrMetricsContext.gauge(
- () -> getTotalStats().getAvailable(),
- true,
- SolrMetricManager.mkName("availableConnections", scope));
- // this acquires a lock on the connection pool; remove if contention sucks
- solrMetricsContext.gauge(
- () -> getTotalStats().getLeased(),
- true,
- SolrMetricManager.mkName("leasedConnections", scope));
- solrMetricsContext.gauge(
- () -> getTotalStats().getMax(), true, SolrMetricManager.mkName("maxConnections", scope));
- solrMetricsContext.gauge(
- () -> getTotalStats().getPending(),
- true,
- SolrMetricManager.mkName("pendingConnections", scope));
- }
-
- @Override
- public void close() {
- super.close();
- try {
- SolrMetricProducer.super.close();
- } catch (Exception e) {
- throw new RuntimeException("Exception closing.", e);
- }
- }
-}
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestPullReplicaWithAuth.java b/solr/core/src/test/org/apache/solr/cloud/TestPullReplicaWithAuth.java
index 8020f662b0c..5e2b2500382 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestPullReplicaWithAuth.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestPullReplicaWithAuth.java
@@ -70,7 +70,7 @@ public class TestPullReplicaWithAuth extends SolrCloudTestCase {
@Test
// NOCOMMIT: This test is broken from OTEL migration and the /admin/plugins endpoint. Placing
// BadApple test but this must be fixed before this feature gets merged to a release branch
- @BadApple(bugUrl = "https://issues.apache.org/jira/browse/SOLR-17458")
+ @AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-17458")
public void testPKIAuthWorksForPullReplication() throws Exception {
int numPullReplicas = 2;
withBasicAuth(
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java b/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java
index da94bf4cc62..f89aa37f90b 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java
@@ -259,7 +259,7 @@ public class TestTlogReplica extends SolrCloudTestCase {
@SuppressWarnings("unchecked")
// NOCOMMIT: This test is broken from OTEL migration and the /admin/plugins endpoint. Placing
// BadApple test but this must be fixed before this feature gets merged to a release branch
- @BadApple(bugUrl = "https://issues.apache.org/jira/browse/SOLR-17458")
+ @AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-17458")
public void testAddDocs() throws Exception {
int numTlogReplicas = 1 + random().nextInt(3);
DocCollection docCollection = createAndWaitForCollection(1, 0, numTlogReplicas, 0);
diff --git a/solr/core/src/test/org/apache/solr/cluster/placement/impl/PlacementPluginIntegrationTest.java b/solr/core/src/test/org/apache/solr/cluster/placement/impl/PlacementPluginIntegrationTest.java
index d3dc25f2e1e..760efbb83ea 100644
--- a/solr/core/src/test/org/apache/solr/cluster/placement/impl/PlacementPluginIntegrationTest.java
+++ b/solr/core/src/test/org/apache/solr/cluster/placement/impl/PlacementPluginIntegrationTest.java
@@ -388,7 +388,7 @@ public class PlacementPluginIntegrationTest extends SolrCloudTestCase {
// NOCOMMIT: This test fails because of CollectionMetricsBuilder. Need to dive deeper into what
// this is and if we need to shim otel into this metrics map.
@Test
- @BadApple(bugUrl = "https://issues.apache.org/jira/browse/SOLR-17458")
+ @AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-17458")
public void testNodeTypeIntegration() throws Exception {
// this functionality relies on System.getProperty which we cannot set on individual
// nodes in a mini cluster.
@@ -442,7 +442,7 @@ public class PlacementPluginIntegrationTest extends SolrCloudTestCase {
// NOCOMMIT: This test needs to be fixed after migrating the collection metrics builder
@Test
- @BadApple(bugUrl = "https://issues.apache.org/jira/browse/SOLR-17458")
+ @AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-17458")
public void testAttributeFetcherImpl() throws Exception {
CollectionAdminResponse rsp =
CollectionAdminRequest.createCollection(COLLECTION, "conf", 2, 2)
diff --git a/solr/core/src/test/org/apache/solr/handler/RequestHandlerMetricsTest.java b/solr/core/src/test/org/apache/solr/handler/RequestHandlerMetricsTest.java
index 7a23fd88094..467094ccd62 100644
--- a/solr/core/src/test/org/apache/solr/handler/RequestHandlerMetricsTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/RequestHandlerMetricsTest.java
@@ -57,7 +57,7 @@ public class RequestHandlerMetricsTest extends SolrCloudTestCase {
// NOCOMMIT: Need to fix aggregateNodeLevelMetricsEnabled for OTEL. Delegate registries currently
// do not play nice with OTEL instrumentation
@Test
- @BadApple(bugUrl = "https://issues.apache.org/jira/browse/SOLR-17458")
+ @AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-17458")
@SuppressWarnings({"unchecked"})
public void testAggregateNodeLevelMetrics() throws SolrServerException, IOException {
String collection1 = "testRequestHandlerMetrics1";
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/MBeansHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/MBeansHandlerTest.java
index 1dab6cf5d42..be55062f79f 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/MBeansHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/MBeansHandlerTest.java
@@ -41,7 +41,7 @@ import org.slf4j.LoggerFactory;
// NOCOMMIT: Test fails because of the /admin/mbeans endpoint. Need to create a bridge or shim after
// migrating all metrics to support this.
-@LuceneTestCase.BadApple(bugUrl = "https://issues.apache.org/jira/browse/SOLR-17458")
+@LuceneTestCase.AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-17458")
public class MBeansHandlerTest extends SolrTestCaseJ4 {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
diff --git a/solr/core/src/test/org/apache/solr/metrics/SolrCoreMetricManagerTest.java b/solr/core/src/test/org/apache/solr/metrics/SolrCoreMetricManagerTest.java
index ffd72b881e3..b49f2fbe471 100644
--- a/solr/core/src/test/org/apache/solr/metrics/SolrCoreMetricManagerTest.java
+++ b/solr/core/src/test/org/apache/solr/metrics/SolrCoreMetricManagerTest.java
@@ -260,7 +260,6 @@ public class SolrCoreMetricManagerTest extends SolrTestCaseJ4 {
// Make sure the core metric registry does not exist anymore once we fully removed the core
// from the container
- names = metricManager.registryNames();
- assertFalse(names.contains(coreRegistryName));
+ assertFalse(metricManager.getPrometheusMetricReaders().containsKey(coreRegistryName));
}
}
diff --git a/solr/core/src/test/org/apache/solr/metrics/SolrMetricsIntegrationTest.java b/solr/core/src/test/org/apache/solr/metrics/SolrMetricsIntegrationTest.java
index d8edadd7209..7f4a4fd2035 100644
--- a/solr/core/src/test/org/apache/solr/metrics/SolrMetricsIntegrationTest.java
+++ b/solr/core/src/test/org/apache/solr/metrics/SolrMetricsIntegrationTest.java
@@ -105,6 +105,7 @@ public class SolrMetricsIntegrationTest extends SolrTestCaseJ4 {
// NOCOMMIT: Comeback and fix this test after merging the SolrZKClient metrics migration
@Test
+ @AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-17458")
public void testZkMetrics() throws Exception {
System.setProperty("metricsEnabled", "true");
MiniSolrCloudCluster cluster =
diff --git a/solr/core/src/test/org/apache/solr/metrics/SolrPrometheusFormatterTest.java b/solr/core/src/test/org/apache/solr/metrics/SolrPrometheusFormatterTest.java
deleted file mode 100644
index 6a99a790dff..00000000000
--- a/solr/core/src/test/org/apache/solr/metrics/SolrPrometheusFormatterTest.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * 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;
-
-import static org.apache.solr.metrics.prometheus.core.SolrCoreMetric.CLOUD_CORE_PATTERN;
-import static org.apache.solr.metrics.prometheus.core.SolrCoreMetric.STANDALONE_CORE_PATTERN;
-
-import com.codahale.metrics.Counter;
-import com.codahale.metrics.Gauge;
-import com.codahale.metrics.Meter;
-import com.codahale.metrics.Metric;
-import com.codahale.metrics.SettableGauge;
-import com.codahale.metrics.Timer;
-import io.prometheus.metrics.model.snapshots.CounterSnapshot;
-import io.prometheus.metrics.model.snapshots.GaugeSnapshot;
-import io.prometheus.metrics.model.snapshots.Labels;
-import io.prometheus.metrics.model.snapshots.SummarySnapshot;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-import java.util.regex.Matcher;
-import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.metrics.prometheus.SolrMetric;
-import org.apache.solr.metrics.prometheus.SolrPrometheusFormatter;
-import org.junit.Test;
-
-public class SolrPrometheusFormatterTest extends SolrTestCaseJ4 {
- @Test
- public void testExportMeter() {
- TestSolrPrometheusFormatter testFormatter = new TestSolrPrometheusFormatter();
- String expectedMetricName = "test_metric";
- Meter metric = new Meter();
- metric.mark(123);
- Labels expectedLabels = Labels.of("test", "test-value");
-
- testFormatter.exportMeter(expectedMetricName, metric, expectedLabels);
- assertTrue(testFormatter.getMetricCounters().containsKey(expectedMetricName));
-
- CounterSnapshot.CounterDataPointSnapshot actual =
- testFormatter.getMetricCounters().get("test_metric").get(0);
- assertEquals(123.0, actual.getValue(), 0);
- assertEquals(expectedLabels, actual.getLabels());
- }
-
- @Test
- public void testExportCounter() {
- TestSolrPrometheusFormatter testFormatter = new TestSolrPrometheusFormatter();
- String expectedMetricName = "test_metric";
- Counter metric = new Counter();
- metric.inc(123);
- Labels expectedLabels = Labels.of("test", "test-value");
-
- testFormatter.exportCounter(expectedMetricName, metric, expectedLabels);
- assertTrue(testFormatter.getMetricCounters().containsKey(expectedMetricName));
-
- CounterSnapshot.CounterDataPointSnapshot actual =
- testFormatter.getMetricCounters().get("test_metric").get(0);
- assertEquals(123.0, actual.getValue(), 0);
- assertEquals(expectedLabels, actual.getLabels());
- }
-
- @Test
- public void testExportTimer() throws InterruptedException {
- TestSolrPrometheusFormatter testFormatter = new TestSolrPrometheusFormatter();
- String expectedMetricName = "test_metric";
- Timer metric = new Timer();
- Timer.Context context = metric.time();
- TimeUnit.SECONDS.sleep(5);
- context.stop();
-
- Labels expectedLabels = Labels.of("test", "test-value");
- testFormatter.exportTimer(expectedMetricName, metric, expectedLabels);
- assertTrue(testFormatter.getMetricSummaries().containsKey(expectedMetricName));
-
- SummarySnapshot.SummaryDataPointSnapshot actual =
- testFormatter.getMetricSummaries().get("test_metric").get(0);
- assertEquals(5000L, actual.getSum(), 500L);
- assertEquals(expectedLabels, actual.getLabels());
- }
-
- @Test
- public void testExportGaugeNumber() throws InterruptedException {
- TestSolrPrometheusFormatter testFormatter = new TestSolrPrometheusFormatter();
- String expectedMetricName = "test_metric";
- Gauge<Number> metric =
- new SettableGauge<>() {
- @Override
- public void setValue(Number value) {}
-
- @Override
- public Number getValue() {
- return 123.0;
- }
- };
-
- Labels expectedLabels = Labels.of("test", "test-value");
- testFormatter.exportGauge(expectedMetricName, metric, expectedLabels);
- assertTrue(testFormatter.getMetricGauges().containsKey(expectedMetricName));
-
- GaugeSnapshot.GaugeDataPointSnapshot actual =
- testFormatter.getMetricGauges().get("test_metric").get(0);
- assertEquals(123.0, actual.getValue(), 0);
- assertEquals(expectedLabels, actual.getLabels());
- }
-
- @Test
- public void testExportGaugeMap() throws InterruptedException {
- TestSolrPrometheusFormatter testFormatter = new TestSolrPrometheusFormatter();
- String expectedMetricName = "test_metric";
- Gauge<Map<String, Number>> metric =
- new SettableGauge<>() {
- @Override
- public void setValue(Map<String, Number> value) {}
-
- @Override
- public Map<String, Number> getValue() {
- final Map<String, Number> expected = new HashMap<>();
- expected.put("test-item", 123.0);
- return expected;
- }
- };
-
- Labels labels = Labels.of("test", "test-value");
- testFormatter.exportGauge(expectedMetricName, metric, labels);
- assertTrue(testFormatter.getMetricGauges().containsKey(expectedMetricName));
-
- GaugeSnapshot.GaugeDataPointSnapshot actual =
- testFormatter.getMetricGauges().get("test_metric").get(0);
- assertEquals(123.0, actual.getValue(), 0);
- Labels expectedLabels = Labels.of("test", "test-value", "item", "test-item");
- assertEquals(expectedLabels, actual.getLabels());
- }
-
- @Test
- public void testCloudCorePattern() {
- String metricName = "core_test-core_shard2_replica_t123.TEST./foobar/endpoint";
- Matcher m = CLOUD_CORE_PATTERN.matcher(metricName);
- assertTrue(m.find());
- assertEquals("core_test-core_shard2_replica_t123", m.group("core"));
- assertEquals("test-core", m.group("collection"));
- assertEquals("shard2", m.group("shard"));
- assertEquals("replica_t123", m.group("replica"));
-
- metricName = "core_foo_bar_shard24_replica_p8.QUERY.random.metric-name";
- m = CLOUD_CORE_PATTERN.matcher(metricName);
- assertTrue(m.matches());
- assertEquals("core_foo_bar_shard24_replica_p8", m.group("core"));
- assertEquals("foo_bar", m.group("collection"));
- assertEquals("shard24", m.group("shard"));
- assertEquals("replica_p8", m.group("replica"));
- }
-
- @Test
- public void testBadCloudCorePattern() {
- String badMetricName = "core_solrtest_shard100_replica_xyz23.TEST./foobar/endpoint";
- Matcher m = CLOUD_CORE_PATTERN.matcher(badMetricName);
- assertFalse(m.matches());
-
- badMetricName = "core_solrtest_shards100_replica_x23.QUERY.random.metric-name";
- m = CLOUD_CORE_PATTERN.matcher(badMetricName);
- assertFalse(m.matches());
- }
-
- @Test
- public void testStandaloneCorePattern() {
- String metricName = "core_test-core.TEST./foobar/endpoint";
- Matcher m = STANDALONE_CORE_PATTERN.matcher(metricName);
- assertTrue(m.find());
- assertEquals("test-core", m.group(1));
- }
-
- static class TestSolrPrometheusFormatter extends SolrPrometheusFormatter {
- @Override
- public void exportDropwizardMetric(Metric dropwizardMetric, String metricName) {}
-
- @Override
- public SolrMetric categorizeMetric(Metric dropwizardMetric, String metricName) {
- return null;
- }
-
- public Map<String, List<CounterSnapshot.CounterDataPointSnapshot>> getMetricCounters() {
- return metricCounters;
- }
-
- public Map<String, List<GaugeSnapshot.GaugeDataPointSnapshot>> getMetricGauges() {
- return metricGauges;
- }
-
- public Map<String, List<SummarySnapshot.SummaryDataPointSnapshot>> getMetricSummaries() {
- return metricSummaries;
- }
- }
-}
diff --git a/solr/prometheus-exporter/src/test/org/apache/solr/prometheus/scraper/SolrStandaloneScraperBasicAuthTest.java b/solr/prometheus-exporter/src/test/org/apache/solr/prometheus/scraper/SolrStandaloneScraperBasicAuthTest.java
index 93aca188fc7..8197bb7d9c7 100644
--- a/solr/prometheus-exporter/src/test/org/apache/solr/prometheus/scraper/SolrStandaloneScraperBasicAuthTest.java
+++ b/solr/prometheus-exporter/src/test/org/apache/solr/prometheus/scraper/SolrStandaloneScraperBasicAuthTest.java
@@ -41,7 +41,7 @@ import org.junit.ClassRule;
import org.junit.Test;
// Prometheus Exporter will be deprecated
-@LuceneTestCase.BadApple(bugUrl = "https://issues.apache.org/jira/browse/SOLR-17458")
+@LuceneTestCase.AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-17458")
public class SolrStandaloneScraperBasicAuthTest extends SolrTestCaseJ4 {
@ClassRule public static final SolrJettyTestRule solrRule = new SolrJettyTestRule();
diff --git a/solr/prometheus-exporter/src/test/org/apache/solr/prometheus/scraper/SolrStandaloneScraperTest.java b/solr/prometheus-exporter/src/test/org/apache/solr/prometheus/scraper/SolrStandaloneScraperTest.java
index e563efa85b9..d7271c5c7c4 100644
--- a/solr/prometheus-exporter/src/test/org/apache/solr/prometheus/scraper/SolrStandaloneScraperTest.java
+++ b/solr/prometheus-exporter/src/test/org/apache/solr/prometheus/scraper/SolrStandaloneScraperTest.java
@@ -45,7 +45,7 @@ import org.junit.Test;
// NOCOMMIT: This test is broken from OTEL migration and the /admin/plugins endpoint. Placing
// BadApple test but this must be fixed before this feature gets merged to a release branch
-@LuceneTestCase.BadApple(bugUrl = "https://issues.apache.org/jira/browse/SOLR-17458")
+@LuceneTestCase.AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-17458")
public class SolrStandaloneScraperTest extends SolrTestCaseJ4 {
@ClassRule public static final SolrJettyTestRule solrRule = new SolrJettyTestRule();
diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCollectionsAPIDistributedZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCollectionsAPIDistributedZkTestBase.java
index 0d17b9b1558..36f3e4317a3 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCollectionsAPIDistributedZkTestBase.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCollectionsAPIDistributedZkTestBase.java
@@ -392,7 +392,7 @@ public abstract class AbstractCollectionsAPIDistributedZkTestBase extends SolrCl
// NOCOMMIT: Failing from JMX reporter
@Test
- @LuceneTestCase.BadApple(bugUrl = "https://issues.apache.org/jira/browse/SOLR-17458")
+ @LuceneTestCase.AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-17458")
public void testCollectionsAPI() throws Exception {
// create new collections rapid fire