pull/35935/head
Phillip Webb 1 year ago
parent fe927f0e06
commit 854b29b8fb

@ -18,7 +18,6 @@ package org.springframework.boot.actuate.autoconfigure.tracing;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import io.micrometer.tracing.SpanCustomizer; import io.micrometer.tracing.SpanCustomizer;
import io.micrometer.tracing.exporter.SpanExportingPredicate; import io.micrometer.tracing.exporter.SpanExportingPredicate;
@ -128,7 +127,7 @@ public class OpenTelemetryAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
SpanProcessors spanProcessors(ObjectProvider<SpanProcessor> spanProcessors) { SpanProcessors spanProcessors(ObjectProvider<SpanProcessor> spanProcessors) {
return SpanProcessors.of(spanProcessors.orderedStream().collect(Collectors.toList())); return SpanProcessors.of(spanProcessors.orderedStream().toList());
} }
@Bean @Bean
@ -145,7 +144,7 @@ public class OpenTelemetryAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
SpanExporters spanExporters(ObjectProvider<SpanExporter> spanExporters) { SpanExporters spanExporters(ObjectProvider<SpanExporter> spanExporters) {
return SpanExporters.of(spanExporters.orderedStream().collect(Collectors.toList())); return SpanExporters.of(spanExporters.orderedStream().toList());
} }
@Bean @Bean

@ -17,18 +17,22 @@
package org.springframework.boot.actuate.autoconfigure.tracing; package org.springframework.boot.actuate.autoconfigure.tracing;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Spliterator; import java.util.Spliterator;
import io.opentelemetry.sdk.trace.export.SpanExporter; import io.opentelemetry.sdk.trace.export.SpanExporter;
import org.springframework.util.Assert;
/** /**
* A collection of {@link SpanExporter span exporters}. * A collection of {@link SpanExporter span exporters}.
* *
* @author Moritz Halbritter * @author Moritz Halbritter
* @since 3.2.0 * @since 3.2.0
*/ */
@FunctionalInterface
public interface SpanExporters extends Iterable<SpanExporter> { public interface SpanExporters extends Iterable<SpanExporter> {
/** /**
@ -47,16 +51,6 @@ public interface SpanExporters extends Iterable<SpanExporter> {
return list().spliterator(); return list().spliterator();
} }
/**
* Constructs a {@link SpanExporters} instance with the given list of
* {@link SpanExporter span exporters}.
* @param spanExporters the list of span exporters
* @return the constructed {@link SpanExporters} instance
*/
static SpanExporters of(List<SpanExporter> spanExporters) {
return () -> spanExporters;
}
/** /**
* Constructs a {@link SpanExporters} instance with the given {@link SpanExporter span * Constructs a {@link SpanExporters} instance with the given {@link SpanExporter span
* exporters}. * exporters}.
@ -67,4 +61,16 @@ public interface SpanExporters extends Iterable<SpanExporter> {
return of(Arrays.asList(spanExporters)); return of(Arrays.asList(spanExporters));
} }
/**
* Constructs a {@link SpanExporters} instance with the given list of
* {@link SpanExporter span exporters}.
* @param spanExporters the list of span exporters
* @return the constructed {@link SpanExporters} instance
*/
static SpanExporters of(Collection<? extends SpanExporter> spanExporters) {
Assert.notNull(spanExporters, "SpanExporters must not be null");
List<SpanExporter> copy = List.copyOf(spanExporters);
return () -> copy;
}
} }

@ -17,18 +17,22 @@
package org.springframework.boot.actuate.autoconfigure.tracing; package org.springframework.boot.actuate.autoconfigure.tracing;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Spliterator; import java.util.Spliterator;
import io.opentelemetry.sdk.trace.SpanProcessor; import io.opentelemetry.sdk.trace.SpanProcessor;
import org.springframework.util.Assert;
/** /**
* A collection of {@link SpanProcessor span processors}. * A collection of {@link SpanProcessor span processors}.
* *
* @author Moritz Halbritter * @author Moritz Halbritter
* @since 3.2.0 * @since 3.2.0
*/ */
@FunctionalInterface
public interface SpanProcessors extends Iterable<SpanProcessor> { public interface SpanProcessors extends Iterable<SpanProcessor> {
/** /**
@ -47,16 +51,6 @@ public interface SpanProcessors extends Iterable<SpanProcessor> {
return list().spliterator(); return list().spliterator();
} }
/**
* Constructs a {@link SpanProcessors} instance with the given list of
* {@link SpanProcessor span processors}.
* @param spanProcessors the list of span processors
* @return the constructed {@link SpanProcessors} instance
*/
static SpanProcessors of(List<SpanProcessor> spanProcessors) {
return () -> spanProcessors;
}
/** /**
* Constructs a {@link SpanProcessors} instance with the given {@link SpanProcessor * Constructs a {@link SpanProcessors} instance with the given {@link SpanProcessor
* span processors}. * span processors}.
@ -67,4 +61,16 @@ public interface SpanProcessors extends Iterable<SpanProcessor> {
return of(Arrays.asList(spanProcessors)); return of(Arrays.asList(spanProcessors));
} }
/**
* Constructs a {@link SpanProcessors} instance with the given list of
* {@link SpanProcessor span processors}.
* @param spanProcessors the list of span processors
* @return the constructed {@link SpanProcessors} instance
*/
static SpanProcessors of(Collection<? extends SpanProcessor> spanProcessors) {
Assert.notNull(spanProcessors, "SpanProcessors must not be null");
List<SpanProcessor> copy = List.copyOf(spanProcessors);
return () -> copy;
}
} }

@ -26,8 +26,9 @@ import org.eclipse.jetty.util.thread.ThreadPool;
import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.boot.autoconfigure.web.ServerProperties;
/** /**
* Creates a {@link ThreadPool} for Jetty, applying the * Creates a {@link ThreadPool} for Jetty, applying
* {@link ServerProperties.Jetty.Threads} properties. * {@link org.springframework.boot.autoconfigure.web.ServerProperties.Jetty.Threads
* ServerProperties.Jetty.Threads Jetty thread properties}.
* *
* @author Moritz Halbritter * @author Moritz Halbritter
*/ */
@ -52,9 +53,7 @@ final class JettyThreadPool {
if (maxQueueCapacity == 0) { if (maxQueueCapacity == 0) {
return new SynchronousQueue<>(); return new SynchronousQueue<>();
} }
else {
return new BlockingArrayQueue<>(maxQueueCapacity); return new BlockingArrayQueue<>(maxQueueCapacity);
} }
}
} }

Loading…
Cancel
Save