Pares back some deprecation after analyzing each file (#1640)

This puts specific comments in as to why certain files that seem like they
shouldn't be public are. Notably, this includes entrypoint autoconfiguration,
which are sometimes order sensitive. In other cases there are types that were
documented (notably the async package).

This also untangles a few configuration.
This commit is contained in:
Adrian Cole
2020-05-17 08:38:08 +08:00
committed by GitHub
parent c1a83aa5bb
commit e9d12703c1
18 changed files with 75 additions and 99 deletions

View File

@@ -16,7 +16,6 @@
package org.springframework.cloud.sleuth.autoconfig;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -70,14 +69,13 @@ import org.springframework.util.StringUtils;
* @author Marcin Grzejszczak
* @author Tim Ysewyn
* @since 2.0.0
* @deprecated This type should have never been public and will be hidden or removed in
* 3.0
*/
@Deprecated
@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(value = "spring.sleuth.enabled", matchIfMissing = true)
@EnableConfigurationProperties(SleuthProperties.class)
@Import({ SleuthLogAutoConfiguration.class, SamplerAutoConfiguration.class })
// public allows @AutoConfigureAfter(TraceAutoConfiguration)
// for components needing Tracing
public class TraceAutoConfiguration {
/**
@@ -90,42 +88,40 @@ public class TraceAutoConfiguration {
*/
public static final String DEFAULT_SERVICE_NAME = "default";
@Autowired(required = false)
List<SpanAdjuster> spanAdjusters = new ArrayList<>();
@Autowired(required = false)
List<SpanHandler> spanHandlers = new ArrayList<>();
@Autowired(required = false)
ExtraFieldPropagation.FactoryBuilder extraFieldPropagationFactoryBuilder;
@Autowired(required = false)
List<TracingCustomizer> tracingCustomizers = new ArrayList<>();
@Autowired(required = false)
List<ExtraFieldCustomizer> extraFieldCustomizers = new ArrayList<>();
@Bean
@ConditionalOnMissingBean
// NOTE: stable bean name as might be used outside sleuth
Tracing tracing(@LocalServiceName String serviceName, Propagation.Factory factory,
CurrentTraceContext currentTraceContext, Sampler sampler,
ErrorParser errorParser, SleuthProperties sleuthProperties,
@Nullable List<Reporter<zipkin2.Span>> spanReporters) {
@Nullable List<Reporter<zipkin2.Span>> spanReporters,
@Nullable List<SpanAdjuster> spanAdjusters,
@Nullable List<SpanHandler> spanHandlers,
@Nullable List<TracingCustomizer> tracingCustomizers) {
if (spanAdjusters == null) {
spanAdjusters = Collections.emptyList();
}
Tracing.Builder builder = Tracing.newBuilder().sampler(sampler)
.errorParser(errorParser)
.localServiceName(StringUtils.isEmpty(serviceName) ? DEFAULT_SERVICE_NAME
: serviceName)
.propagationFactory(factory).currentTraceContext(currentTraceContext)
.spanReporter(new CompositeReporter(this.spanAdjusters,
.spanReporter(new CompositeReporter(spanAdjusters,
spanReporters != null ? spanReporters : Collections.emptyList()))
.traceId128Bit(sleuthProperties.isTraceId128())
.supportsJoin(sleuthProperties.isSupportsJoin());
for (SpanHandler spanHandlerFactory : this.spanHandlers) {
builder.addSpanHandler(spanHandlerFactory);
if (spanHandlers != null) {
for (SpanHandler spanHandlerFactory : spanHandlers) {
builder.addSpanHandler(spanHandlerFactory);
}
}
for (TracingCustomizer customizer : this.tracingCustomizers) {
customizer.customize(builder);
if (tracingCustomizers != null) {
for (TracingCustomizer customizer : tracingCustomizers) {
customizer.customize(builder);
}
}
return builder.build();
}
@@ -144,7 +140,11 @@ public class TraceAutoConfiguration {
@Bean
@ConditionalOnMissingBean
Propagation.Factory sleuthPropagation(SleuthProperties sleuthProperties) {
Propagation.Factory sleuthPropagation(SleuthProperties sleuthProperties,
List<ExtraFieldCustomizer> extraFieldCustomizers) {
if (extraFieldCustomizers == null) {
extraFieldCustomizers = Collections.emptyList();
}
if (sleuthProperties.getBaggageKeys().isEmpty()
&& sleuthProperties.getPropagationKeys().isEmpty()
&& extraFieldCustomizers.isEmpty()
@@ -177,7 +177,7 @@ public class TraceAutoConfiguration {
factoryBuilder = factoryBuilder.addRedactedField(key);
}
}
for (ExtraFieldCustomizer customizer : this.extraFieldCustomizers) {
for (ExtraFieldCustomizer customizer : extraFieldCustomizers) {
customizer.customize(factoryBuilder);
}
return factoryBuilder.build();

View File

@@ -29,10 +29,8 @@ import org.springframework.scheduling.annotation.AsyncConfigurerSupport;
*
* @author Dave Syer
* @since 1.0.0
* @deprecated This type should have never been public and will be hidden or removed in
* 3.0
*/
@Deprecated
// public as most types in this package were documented for use
public class LazyTraceAsyncCustomizer extends AsyncConfigurerSupport {
private final BeanFactory beanFactory;

View File

@@ -35,10 +35,8 @@ import org.springframework.core.task.AsyncTaskExecutor;
*
* @author Marcin Grzejszczak
* @since 2.1.0
* @deprecated This type should have never been public and will be hidden or removed in
* 3.0
*/
@Deprecated
// public as most types in this package were documented for use
public class LazyTraceAsyncTaskExecutor implements AsyncTaskExecutor {
private static final Log log = LogFactory.getLog(LazyTraceAsyncTaskExecutor.class);

View File

@@ -32,10 +32,8 @@ import org.springframework.cloud.sleuth.SpanNamer;
*
* @author Dave Syer
* @since 1.0.0
* @deprecated This type should have never been public and will be hidden or removed in
* 3.0
*/
@Deprecated
// public as most types in this package were documented for use
public class LazyTraceExecutor implements Executor {
private static final Log log = LogFactory.getLog(LazyTraceExecutor.class);

View File

@@ -39,11 +39,9 @@ import org.springframework.util.concurrent.ListenableFuture;
*
* @author Marcin Grzejszczak
* @since 1.0.10
* @deprecated This type should have never been public and will be hidden or removed in
* 3.0
*/
@Deprecated
@SuppressWarnings("serial")
// public as most types in this package were documented for use
public class LazyTraceThreadPoolTaskExecutor extends ThreadPoolTaskExecutor {
private static final Log log = LogFactory

View File

@@ -33,10 +33,8 @@ import org.springframework.cloud.sleuth.SpanNamer;
* @author Spencer Gibb
* @author Marcin Grzejszczak
* @since 1.0.0
* @deprecated This type should have never been public and will be hidden or removed in
* 3.0
*/
@Deprecated
// public as most types in this package were documented for use
public class TraceCallable<V> implements Callable<V> {
/**

View File

@@ -30,10 +30,8 @@ import org.springframework.cloud.sleuth.SpanNamer;
* @author Spencer Gibb
* @author Marcin Grzejszczak
* @since 1.0.0
* @deprecated This type should have never been public and will be hidden or removed in
* 3.0
*/
@Deprecated
// public as most types in this package were documented for use
public class TraceRunnable implements Runnable {
/**

View File

@@ -36,10 +36,8 @@ import org.springframework.cloud.sleuth.SpanNamer;
*
* @author Gaurav Rai Mazra
* @since 1.0.0
* @deprecated This type should have never been public and will be hidden or removed in
* 3.0
*/
@Deprecated
// public as most types in this package were documented for use
public class TraceableExecutorService implements ExecutorService {
final ExecutorService delegate;

View File

@@ -29,10 +29,8 @@ import org.springframework.beans.factory.BeanFactory;
*
* @author Gaurav Rai Mazra
* @since 1.0.0
* @deprecated This type should have never been public and will be hidden or removed in
* 3.0
*/
@Deprecated
// public as most types in this package were documented for use
public class TraceableScheduledExecutorService extends TraceableExecutorService
implements ScheduledExecutorService {

View File

@@ -17,7 +17,6 @@
package org.springframework.cloud.sleuth.instrument.messaging;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -49,7 +48,6 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.aop.framework.ProxyFactoryBean;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
@@ -86,10 +84,7 @@ import org.springframework.util.ReflectionUtils;
*
* @author Marcin Grzejszczak
* @since 2.0.0
* @deprecated This type should have never been public and will be hidden or removed in
* 3.0
*/
@Deprecated
@Configuration(proxyBeanMethods = false)
@ConditionalOnBean(Tracing.class)
@ConditionalOnClass(MessagingTracing.class)
@@ -97,17 +92,17 @@ import org.springframework.util.ReflectionUtils;
TraceSpringMessagingAutoConfiguration.class })
@OnMessagingEnabled
@EnableConfigurationProperties(SleuthMessagingProperties.class)
// public allows @AutoConfigureAfter(TraceMessagingAutoConfiguration)
// for components needing MessagingTracing
public class TraceMessagingAutoConfiguration {
@Autowired(required = false)
List<MessagingTracingCustomizer> messagingTracingCustomizers = new ArrayList<>();
@Bean
@ConditionalOnMissingBean
// NOTE: stable bean name as might be used outside sleuth
MessagingTracing messagingTracing(Tracing tracing,
@Nullable @ProducerSampler SamplerFunction<MessagingRequest> producerSampler,
@Nullable @ConsumerSampler SamplerFunction<MessagingRequest> consumerSampler) {
@Nullable @ConsumerSampler SamplerFunction<MessagingRequest> consumerSampler,
@Nullable List<MessagingTracingCustomizer> messagingTracingCustomizers) {
MessagingTracing.Builder builder = MessagingTracing.newBuilder(tracing);
if (producerSampler != null) {
@@ -116,8 +111,10 @@ public class TraceMessagingAutoConfiguration {
if (consumerSampler != null) {
builder.consumerSampler(consumerSampler);
}
for (MessagingTracingCustomizer customizer : this.messagingTracingCustomizers) {
customizer.customize(builder);
if (messagingTracingCustomizers != null) {
for (MessagingTracingCustomizer customizer : messagingTracingCustomizers) {
customizer.customize(builder);
}
}
return builder.build();
}

View File

@@ -16,7 +16,6 @@
package org.springframework.cloud.sleuth.instrument.rpc;
import java.util.ArrayList;
import java.util.List;
import brave.Tracing;
@@ -25,7 +24,6 @@ import brave.rpc.RpcTracing;
import brave.rpc.RpcTracingCustomizer;
import brave.sampler.SamplerFunction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@@ -41,27 +39,24 @@ import org.springframework.lang.Nullable;
* Auto-configuration} related to RPC based communication.
*
* @since 2.2.0
* @deprecated This type should have never been public and will be hidden or removed in
* 3.0
*/
@Deprecated
@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(name = "spring.sleuth.rpc.enabled", havingValue = "true",
matchIfMissing = true)
@ConditionalOnBean(Tracing.class)
@ConditionalOnClass(RpcTracing.class)
@AutoConfigureAfter(TraceAutoConfiguration.class)
// public allows @AutoConfigureAfter(TraceRpcAutoConfiguration)
// for components needing RpcTracing
public class TraceRpcAutoConfiguration {
@Autowired(required = false)
List<RpcTracingCustomizer> rpcTracingCustomizers = new ArrayList<>();
@Bean
@ConditionalOnMissingBean
// NOTE: stable bean name as might be used outside sleuth
RpcTracing rpcTracing(Tracing tracing,
@Nullable @RpcClientSampler SamplerFunction<RpcRequest> clientSampler,
@Nullable @RpcServerSampler SamplerFunction<RpcRequest> serverSampler) {
@Nullable @RpcServerSampler SamplerFunction<RpcRequest> serverSampler,
@Nullable List<RpcTracingCustomizer> rpcTracingCustomizers) {
RpcTracing.Builder builder = RpcTracing.newBuilder(tracing);
if (clientSampler != null) {
@@ -70,8 +65,10 @@ public class TraceRpcAutoConfiguration {
if (serverSampler != null) {
builder.serverSampler(serverSampler);
}
for (RpcTracingCustomizer customizer : this.rpcTracingCustomizers) {
customizer.customize(builder);
if (rpcTracingCustomizers != null) {
for (RpcTracingCustomizer customizer : rpcTracingCustomizers) {
customizer.customize(builder);
}
}
return builder.build();
}

View File

@@ -16,7 +16,6 @@
package org.springframework.cloud.sleuth.instrument.web;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
@@ -30,14 +29,16 @@ import brave.http.HttpTracingCustomizer;
import brave.sampler.SamplerFunction;
import brave.sampler.SamplerFunctions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.sleuth.autoconfig.TraceAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.Ordered;
import org.springframework.lang.Nullable;
@@ -47,23 +48,26 @@ import org.springframework.lang.Nullable;
*
* @author Marcin Grzejszczak
* @since 2.0.0
* @deprecated This type should have never been public and will be hidden or removed in
* 3.0
*/
@Deprecated
@Configuration(proxyBeanMethods = false)
@ConditionalOnBean(TraceWebAutoConfiguration.class)
@ConditionalOnProperty(name = "spring.sleuth.http.enabled", havingValue = "true",
matchIfMissing = true)
@AutoConfigureAfter(TraceWebAutoConfiguration.class)
@EnableConfigurationProperties({ TraceKeys.class, SleuthHttpLegacyProperties.class })
// This was formerly conditional on TraceWebAutoConfiguration, which was
// conditional on "spring.sleuth.web.enabled". As this is conditional on
// "spring.sleuth.http.enabled", to be compatible with old behavior we have
// to be conditional on two properties.
@ConditionalOnProperty(
name = { "spring.sleuth.http.enabled", "spring.sleuth.web.enabled" },
havingValue = "true", matchIfMissing = true)
@ConditionalOnBean(Tracing.class)
@ConditionalOnClass(HttpTracing.class)
@AutoConfigureAfter(TraceAutoConfiguration.class)
@Import(TraceWebAutoConfiguration.class)
@EnableConfigurationProperties(TraceKeys.class)
// public allows @AutoConfigureAfter(TraceHttpAutoConfiguration)
// for components needing HttpTracing
public class TraceHttpAutoConfiguration {
static final int TRACING_FILTER_ORDER = Ordered.HIGHEST_PRECEDENCE + 5;
@Autowired(required = false)
List<HttpTracingCustomizer> httpTracingCustomizers = new ArrayList<>();
@Bean
@ConditionalOnMissingBean
// NOTE: stable bean name as might be used outside sleuth
@@ -76,7 +80,8 @@ public class TraceHttpAutoConfiguration {
@Nullable brave.http.HttpServerParser serverParser,
@HttpClientSampler SamplerFunction<HttpRequest> httpClientSampler,
@Nullable @ServerSampler HttpSampler serverSampler,
@Nullable @HttpServerSampler SamplerFunction<HttpRequest> httpServerSampler) {
@Nullable @HttpServerSampler SamplerFunction<HttpRequest> httpServerSampler,
@Nullable List<HttpTracingCustomizer> httpTracingCustomizers) {
if (httpServerSampler == null) {
httpServerSampler = serverSampler;
}
@@ -109,10 +114,11 @@ public class TraceHttpAutoConfiguration {
builder.serverParser(serverParser);
}
for (HttpTracingCustomizer customizer : this.httpTracingCustomizers) {
customizer.customize(builder);
if (httpTracingCustomizers != null) {
for (HttpTracingCustomizer customizer : httpTracingCustomizers) {
customizer.customize(builder);
}
}
return builder.build();
}

View File

@@ -30,7 +30,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.sleuth.instrument.web.TraceWebServletAutoConfiguration;
import org.springframework.cloud.sleuth.instrument.web.TraceHttpAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.AsyncClientHttpRequestFactory;
@@ -54,7 +54,7 @@ import org.springframework.web.client.AsyncRestTemplate;
matchIfMissing = true)
@ConditionalOnClass(AsyncRestTemplate.class)
@ConditionalOnBean(HttpTracing.class)
@AutoConfigureAfter(TraceWebServletAutoConfiguration.class)
@AutoConfigureAfter(TraceHttpAutoConfiguration.class)
public class TraceWebAsyncClientAutoConfiguration {
@Configuration(proxyBeanMethods = false)

View File

@@ -42,7 +42,7 @@ import org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoR
import org.springframework.boot.web.client.RestTemplateCustomizer;
import org.springframework.cloud.commons.httpclient.HttpClientConfiguration;
import org.springframework.cloud.gateway.filter.headers.HttpHeadersFilter;
import org.springframework.cloud.sleuth.instrument.web.TraceWebServletAutoConfiguration;
import org.springframework.cloud.sleuth.instrument.web.TraceHttpAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -69,7 +69,7 @@ import org.springframework.web.reactive.function.client.WebClient;
@Configuration(proxyBeanMethods = false)
@SleuthWebClientEnabled
@ConditionalOnBean(HttpTracing.class)
@AutoConfigureAfter(TraceWebServletAutoConfiguration.class)
@AutoConfigureAfter(TraceHttpAutoConfiguration.class)
@AutoConfigureBefore(HttpClientConfiguration.class)
public class TraceWebClientAutoConfiguration {

View File

@@ -26,7 +26,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
*
* @author Arthur Gavlyukovskiy
* @since 1.0.12
* 3.0
*/
@ConfigurationProperties("spring.sleuth.log.slf4j")
// TODO: Hide in 3.x, if it isn't already deleted

View File

@@ -33,10 +33,7 @@ import org.springframework.context.annotation.Configuration;
* @author Marcin Grzejszczak
* @see SamplerCondition
* @since 2.1.0
* @deprecated This type should have never been public and will be hidden or removed in
* 3.0
*/
@Deprecated
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties(SamplerProperties.class)
// This is not auto-configuration, but it was in the past. Leaving the name as

View File

@@ -46,10 +46,7 @@ import org.springframework.lang.Nullable;
*
* @author Marcin Grzejszczak
* @since 2.1.1
* @deprecated This type should have never been public and will be hidden or removed in
* 3.0
*/
@Deprecated
public final class TracingJmsListenerEndpointRegistry
extends JmsListenerEndpointRegistry {

View File

@@ -4,7 +4,6 @@ org.springframework.cloud.sleuth.annotation.SleuthAnnotationAutoConfiguration,\
org.springframework.cloud.sleuth.autoconfig.TraceAutoConfiguration,\
org.springframework.cloud.sleuth.propagation.SleuthTagPropagationAutoConfiguration,\
org.springframework.cloud.sleuth.instrument.web.TraceHttpAutoConfiguration,\
org.springframework.cloud.sleuth.instrument.web.TraceWebAutoConfiguration,\
org.springframework.cloud.sleuth.instrument.web.TraceWebServletAutoConfiguration,\
org.springframework.cloud.sleuth.instrument.web.client.TraceWebClientAutoConfiguration,\
org.springframework.cloud.sleuth.instrument.web.client.TraceWebAsyncClientAutoConfiguration,\