Changed the name from decorateHooks to decorateQueues

This commit is contained in:
Marcin Grzejszczak
2021-02-25 15:22:00 +01:00
parent de33b91739
commit 36bc95976d
5 changed files with 25 additions and 24 deletions

View File

@@ -34,7 +34,7 @@ public class Pair {
}
public static Pair noHook() {
return new Pair("spring.sleuth.reactor.decorate-hooks", "false");
return new Pair("spring.sleuth.reactor.decorate-queues", "false");
}
public static Pair noSleuth() {

View File

@@ -1528,7 +1528,7 @@ To turn off this feature, set the `spring.sleuth.quartz.enabled` property to `fa
==== From Spring Cloud Sleuth 2.2.8 (inclusive)
With the new Reactor https://github.com/reactor/reactor-core/pull/2566[queue wrapping mechanism] (Reactor 3.3.14) we're instrumenting the way threads are switched by Reactor. You should observe significant improvement in performance. In order to disable this feature you have to set the `spring.sleuth.reactor.decorate-hooks` option to `false`. You'll fall back to the previous instrumentation mode mechanism.
With the new Reactor https://github.com/reactor/reactor-core/pull/2566[queue wrapping mechanism] (Reactor 3.3.14) we're instrumenting the way threads are switched by Reactor. You should observe significant improvement in performance. In order to disable this feature you have to set the `spring.sleuth.reactor.decorate-queues` option to `false`. You'll fall back to the previous instrumentation mode mechanism.
==== To Spring Cloud Sleuth 2.2.8 (exclusive)

View File

@@ -34,11 +34,11 @@ public class SleuthReactorProperties {
private boolean enabled = true;
/**
* When true uses the new decorate hooks feature from Project Reactor. Should allow
* When true uses the new decorate queues feature from Project Reactor. Should allow
* the feature set of {@link SleuthReactorProperties#decorateOnEach} with the least
* impact on the performance.
*/
private boolean decorateHooks = true;
private boolean decorateQueues = true;
/**
* When true decorates on each operator, will be less performing, but logging will
@@ -46,8 +46,8 @@ public class SleuthReactorProperties {
* operator, will be more performing, but logging might not always contain the tracing
* entries.
*
* If {@link SleuthReactorProperties#decorateHooks} is used, this decoration mode will
* NOT be used.
* If {@link SleuthReactorProperties#decorateQueues} is used, this decoration mode
* will NOT be used.
*/
private boolean decorateOnEach = true;
@@ -59,12 +59,12 @@ public class SleuthReactorProperties {
this.enabled = enabled;
}
public boolean isDecorateHooks() {
return this.decorateHooks;
public boolean isDecorateQueues() {
return this.decorateQueues;
}
public void setDecorateHooks(boolean decorateHooks) {
this.decorateHooks = decorateHooks;
public void setDecorateQueues(boolean decorateQueues) {
this.decorateQueues = decorateQueues;
}
public boolean isDecorateOnEach() {

View File

@@ -100,7 +100,7 @@ public class TraceReactorAutoConfiguration {
SleuthReactorProperties reactorProperties = this.springContext
.getBean(SleuthReactorProperties.class);
if (TraceReactorAutoConfiguration.TraceReactorConfiguration.IS_QUEUE_WRAPPER_ON_THE_CLASSPATH
&& reactorProperties.isDecorateHooks()) {
&& reactorProperties.isDecorateQueues()) {
if (log.isTraceEnabled()) {
log.trace("Resetting queue wrapper instrumentation");
}
@@ -175,7 +175,7 @@ class HooksRefresher implements ApplicationListener<RefreshScopeRefreshedEvent>
Hooks.resetOnEachOperator(SLEUTH_TRACE_REACTOR_KEY);
Hooks.resetOnLastOperator(SLEUTH_TRACE_REACTOR_KEY);
Hooks.removeQueueWrapper(SLEUTH_TRACE_REACTOR_KEY);
if (this.reactorProperties.isDecorateHooks()
if (this.reactorProperties.isDecorateQueues()
&& TraceReactorAutoConfiguration.TraceReactorConfiguration.IS_QUEUE_WRAPPER_ON_THE_CLASSPATH) {
if (log.isTraceEnabled()) {
log.trace("Adding queue wrapper instrumentation");
@@ -227,16 +227,16 @@ class HookRegisteringBeanDefinitionRegistryPostProcessor
static void setupHooks(ConfigurableApplicationContext springContext) {
ConfigurableEnvironment environment = springContext.getEnvironment();
Boolean decorateHooks = environment
.getProperty("spring.sleuth.reactor.decorate-hooks", Boolean.class);
if (wrapperNotOnClasspathButPropertyHasValue(decorateHooks)) {
Boolean decorateQueues = environment
.getProperty("spring.sleuth.reactor.decorate-queues", Boolean.class);
if (wrapperNotOnClasspathButPropertyHasValue(decorateQueues)) {
log.warn(
"You have explicitly set the decorate hooks option but you're using an old version of Reactor. Please upgrade to the latest Boot version (at least 2.3.9.RELEASE). Will fall back to the previous reactor instrumentation mode");
}
else {
decorateHooks = decorateHooks != null ? decorateHooks : Boolean.TRUE;
decorateQueues = decorateQueues != null ? decorateQueues : Boolean.TRUE;
}
if (wrapperOnClasspathHooksPropertyTurnedOn(decorateHooks)) {
if (wrapperOnClasspathHooksPropertyTurnedOn(decorateQueues)) {
if (log.isTraceEnabled()) {
log.trace("Adding queue wrapper instrumentation");
}
@@ -263,12 +263,14 @@ class HookRegisteringBeanDefinitionRegistryPostProcessor
decorateScheduler(springContext);
}
private static boolean wrapperOnClasspathHooksPropertyTurnedOn(Boolean decorateHooks) {
private static boolean wrapperOnClasspathHooksPropertyTurnedOn(
Boolean decorateHooks) {
return Boolean.TRUE.equals(decorateHooks)
&& TraceReactorAutoConfiguration.TraceReactorConfiguration.IS_QUEUE_WRAPPER_ON_THE_CLASSPATH;
}
private static boolean wrapperNotOnClasspathButPropertyHasValue(Boolean decorateHooks) {
private static boolean wrapperNotOnClasspathButPropertyHasValue(
Boolean decorateHooks) {
return !TraceReactorAutoConfiguration.TraceReactorConfiguration.IS_QUEUE_WRAPPER_ON_THE_CLASSPATH
&& decorateHooks != null;
}
@@ -286,7 +288,6 @@ class HookRegisteringBeanDefinitionRegistryPostProcessor
Hooks.resetOnEachOperator(SLEUTH_TRACE_REACTOR_KEY);
Hooks.resetOnLastOperator(SLEUTH_TRACE_REACTOR_KEY);
Hooks.removeQueueWrapper(SLEUTH_REACTOR_EXECUTOR_SERVICE_KEY);
Schedulers.resetOnScheduleHook(SLEUTH_REACTOR_EXECUTOR_SERVICE_KEY);
Schedulers.resetOnScheduleHook(
TraceReactorAutoConfiguration.SLEUTH_REACTOR_EXECUTOR_SERVICE_KEY);
}

View File

@@ -101,7 +101,7 @@ public class FlatMapTests {
FlatMapTests.TestConfiguration.class, Issue866Configuration.class)
.web(WebApplicationType.REACTIVE)
.properties("server.port=0", "spring.jmx.enabled=false",
"spring.sleuth.reactor.decorate-hooks=false",
"spring.sleuth.reactor.decorate-queues=false",
"spring.sleuth.reactor.decorate-on-each=true",
"spring.application.name=TraceWebFluxOnEachTests",
"security.basic.enabled=false",
@@ -117,7 +117,7 @@ public class FlatMapTests {
FlatMapTests.TestConfiguration.class, Issue866Configuration.class)
.web(WebApplicationType.REACTIVE)
.properties("server.port=0", "spring.jmx.enabled=false",
"spring.sleuth.reactor.decorate-hooks=false",
"spring.sleuth.reactor.decorate-queues=false",
"spring.sleuth.reactor.decorate-on-each=false",
"spring.application.name=TraceWebFluxOnLastTests",
"security.basic.enabled=false",
@@ -126,14 +126,14 @@ public class FlatMapTests {
assertReactorTracing(context);
try {
System.setProperty("spring.sleuth.reactor.decorate-hooks", "false");
System.setProperty("spring.sleuth.reactor.decorate-queues", "false");
System.setProperty("spring.sleuth.reactor.decorate-on-each", "false");
// trigger context refreshed
context.getBean(ContextRefresher.class).refresh();
assertReactorTracing(context);
}
finally {
System.clearProperty("spring.sleuth.reactor.decorate-hooks");
System.clearProperty("spring.sleuth.reactor.decorate-queues");
System.clearProperty("spring.sleuth.reactor.decorate-on-each");
}
}