You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2022/02/19 17:15:54 UTC
[GitHub] [solr] dsmiley commented on a change in pull request #669: SOLR-16035: Enable spotless for prometheus-exporter
dsmiley commented on a change in pull request #669:
URL: https://github.com/apache/solr/pull/669#discussion_r810514546
##########
File path: solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/SolrClientFactory.java
##########
@@ -57,13 +57,18 @@ public CloudSolrClient createCloudSolrClient(String zookeeperConnectionString) {
ConnectStringParser parser = new ConnectStringParser(zookeeperConnectionString);
- CloudSolrClient.Builder cloudBuilder = new CloudSolrClient.Builder(
- parser.getServerAddresses().stream()
- .map(address -> String.format(Locale.ROOT, "%s:%s", address.getHostString(), address.getPort()))
- .collect(Collectors.toList()),
- Optional.ofNullable(parser.getChrootPath()));
-
- cloudBuilder.withConnectionTimeout(settings.getHttpConnectionTimeout())
+ CloudSolrClient.Builder cloudBuilder =
+ new CloudSolrClient.Builder(
+ parser.getServerAddresses().stream()
+ .map(
+ address ->
+ String.format(
Review comment:
Simple string concatenation with a colon would be simpler and shorter, probably wouldn't wrap
##########
File path: solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/SolrExporter.java
##########
@@ -144,39 +157,68 @@ private SolrScraper createScraper(SolrScrapeConfiguration configuration, Prometh
factory.createStandaloneSolrClient(configuration.getSolrHost().get()), requestExecutor);
case CLOUD:
return new SolrCloudScraper(
- factory.createCloudSolrClient(configuration.getZookeeperConnectionString().get()), requestExecutor, factory);
+ factory.createCloudSolrClient(configuration.getZookeeperConnectionString().get()),
+ requestExecutor,
+ factory);
default:
- throw new RuntimeException(String.format(Locale.ROOT, "Invalid type: %s", configuration.getType()));
+ throw new RuntimeException(
+ String.format(Locale.ROOT, "Invalid type: %s", configuration.getType()));
Review comment:
String concatenation would be shorter; probably wouldn't wrap
##########
File path: solr/prometheus-exporter/src/test/org/apache/solr/prometheus/collector/MetricSamplesTest.java
##########
@@ -25,46 +28,48 @@
import java.util.Locale;
import java.util.Map;
import java.util.stream.Collectors;
-
-import io.prometheus.client.Collector;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-
public class MetricSamplesTest {
private Collector.MetricFamilySamples.Sample sample(String name, Double value) {
- return new Collector.MetricFamilySamples.Sample(name, Collections.emptyList(), Collections.emptyList(), value);
+ return new Collector.MetricFamilySamples.Sample(
+ name, Collections.emptyList(), Collections.emptyList(), value);
}
- private Collector.MetricFamilySamples samples(String metricName, Collector.Type type, Collector.MetricFamilySamples.Sample...samples) {
+ private Collector.MetricFamilySamples samples(
+ String metricName, Collector.Type type, Collector.MetricFamilySamples.Sample... samples) {
return new Collector.MetricFamilySamples(
- metricName,
- type,
- "help",
- new ArrayList<>(Arrays.asList(samples))
- );
+ metricName, type, "help", new ArrayList<>(Arrays.asList(samples)));
}
private void validateMetricSamples(
List<Collector.MetricFamilySamples> allMetrics,
String metricName,
List<Double> expectedValues) {
- Collector.MetricFamilySamples test1 = allMetrics.stream()
- .filter(s -> s.name.equals(metricName))
- .findFirst()
- .orElseThrow(() -> new RuntimeException(String.format(Locale.ROOT, "Unable to find item %s", metricName)));
-
- assertEquals(expectedValues, test1.samples.stream().map(s -> s.value).collect(Collectors.toList()));
+ Collector.MetricFamilySamples test1 =
+ allMetrics.stream()
+ .filter(s -> s.name.equals(metricName))
+ .findFirst()
+ .orElseThrow(
+ () ->
+ new RuntimeException(
+ String.format(Locale.ROOT, "Unable to find item %s", metricName)));
Review comment:
Simple string concatenation probably wouldn't have wrapped
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org