Logs everywhere
This commit is contained in:
@@ -47,12 +47,6 @@ public abstract class ReactorSleuth {
|
||||
private ReactorSleuth() {
|
||||
}
|
||||
|
||||
private static <T> SpanSubscriptionProvider spanSubscriptionProvider(
|
||||
BeanFactory beanFactory, Scannable scannable, CoreSubscriber<? super T> sub) {
|
||||
return new SpanSubscriptionProvider(beanFactory, sub, sub.currentContext(),
|
||||
scannable.name());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a span operator pointcut given a {@link Tracing}. This can be used in
|
||||
* reactor via {@link reactor.core.publisher.Flux#transform(Function)},
|
||||
@@ -67,6 +61,9 @@ public abstract class ReactorSleuth {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> Function<? super Publisher<T>, ? extends Publisher<T>> scopePassingSpanOperator(
|
||||
ConfigurableApplicationContext beanFactory) {
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("Scope passing operator [" + beanFactory + "]");
|
||||
}
|
||||
return (sourcePub -> {
|
||||
// TODO: Remove this once Reactor 3.1.8 is released
|
||||
// do the checks directly on actual original Publisher
|
||||
@@ -94,7 +91,7 @@ public abstract class ReactorSleuth {
|
||||
}
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace(
|
||||
"Spring Context is not yet refreshed, falling back to lazy span subscriber. Reactor Context is ["
|
||||
"Spring Context [" + beanFactory + "] is not yet refreshed, falling back to lazy span subscriber. Reactor Context is ["
|
||||
+ sub.currentContext() + "] and name is ["
|
||||
+ scannable.name() + "]");
|
||||
}
|
||||
|
||||
@@ -34,8 +34,7 @@ import reactor.util.context.Context;
|
||||
* @author Marcin Grzejszczak
|
||||
* @since 2.0.0
|
||||
*/
|
||||
final class ScopePassingSpanSubscriber<T> extends AtomicBoolean
|
||||
implements SpanSubscription<T> {
|
||||
final class ScopePassingSpanSubscriber<T> implements SpanSubscription<T> {
|
||||
|
||||
private static final Log log = LogFactory.getLog(ScopePassingSpanSubscriber.class);
|
||||
|
||||
@@ -111,4 +110,8 @@ final class ScopePassingSpanSubscriber<T> extends AtomicBoolean
|
||||
return this.context;
|
||||
}
|
||||
|
||||
private void clearSpan() {
|
||||
this.tracer.withSpanInScope(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class SpanSubscriptionProvider<T> implements Supplier<SpanSubscription<T>> {
|
||||
this.context = context;
|
||||
this.name = name;
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("Context [" + context + "], name [" + name + "]");
|
||||
log.trace("Spring context [" + beanFactory + "], Reactor context [" + context + "], name [" + name + "]");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,9 @@ public class TraceReactorAutoConfiguration {
|
||||
@ConditionalOnMissingBean
|
||||
static HookRegisteringBeanDefinitionRegistryPostProcessor traceHookRegisteringBeanDefinitionRegistryPostProcessor(
|
||||
ConfigurableApplicationContext context) {
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("Registering bean definition registry post processor for context [" + context + "]");
|
||||
}
|
||||
return new HookRegisteringBeanDefinitionRegistryPostProcessor(context);
|
||||
}
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ public final class TraceWebFilter implements WebFilter, Ordered {
|
||||
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
||||
if (tracer().currentSpan() != null) {
|
||||
if (tracer().currentSpan() != null) {
|
||||
// clear any previous trace
|
||||
tracer().withSpanInScope(null);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.trace.http.HttpTrace;
|
||||
import org.springframework.boot.actuate.trace.http.HttpTraceRepository;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.cloud.sleuth.DisableWebFluxSecurity;
|
||||
@@ -61,7 +60,8 @@ import static org.assertj.core.api.BDDAssertions.then;
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(properties = { "spring.main.web-application-type=reactive" }, classes = {
|
||||
SleuthSpanCreatorAspectWebFluxTests.TestEndpoint.class,
|
||||
SleuthSpanCreatorAspectWebFluxTests.TestConfiguration.class }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
SleuthSpanCreatorAspectWebFluxTests.TestConfiguration.class },
|
||||
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class SleuthSpanCreatorAspectWebFluxTests {
|
||||
|
||||
@@ -85,7 +85,6 @@ public class SleuthSpanCreatorAspectWebFluxTests {
|
||||
@AfterClass
|
||||
@BeforeClass
|
||||
public static void cleanup() {
|
||||
System.out.println("DUPA2");
|
||||
Hooks.resetOnLastOperator();
|
||||
TraceReactorAutoConfigurationAccessorConfiguration.close();
|
||||
}
|
||||
@@ -100,7 +99,7 @@ public class SleuthSpanCreatorAspectWebFluxTests {
|
||||
this.reporter.clear();
|
||||
this.repository.clear();
|
||||
log.info("Running app on port [" + this.port + "]");
|
||||
this.webClient = WebTestClient.bindToServer().baseUrl("http://localhost:" + port)
|
||||
this.webClient = WebTestClient.bindToServer().baseUrl("http://localhost:" + this.port)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -233,7 +232,6 @@ public class SleuthSpanCreatorAspectWebFluxTests {
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
@DisableWebFluxSecurity
|
||||
@ImportAutoConfiguration(TraceReactorAutoConfigurationAccessorConfiguration.class)
|
||||
protected static class TestConfiguration {
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
package org.springframework.cloud.sleuth.instrument.reactor;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
@@ -28,6 +31,8 @@ import org.springframework.context.annotation.Configuration;
|
||||
@Configuration
|
||||
public class Issue866Configuration {
|
||||
|
||||
private static final Log log = LogFactory.getLog(Issue866Configuration.class);
|
||||
|
||||
// we don't want to force direct dependencies between components
|
||||
// because Spring might just properly setup the context
|
||||
// we want to ensure that the HRBDRPP is always executed before
|
||||
@@ -37,6 +42,7 @@ public class Issue866Configuration {
|
||||
@Bean
|
||||
HookRegisteringBeanDefinitionRegistryPostProcessor overridingProcessorForTests(
|
||||
ConfigurableApplicationContext context) {
|
||||
log.info("Registering a HookRegisteringBeanDefinitionRegistryPostProcessor for context [" + context + "]");
|
||||
TestHook hook = new TestHook(context);
|
||||
Issue866Configuration.hook = hook;
|
||||
return hook;
|
||||
|
||||
@@ -5,17 +5,9 @@ import org.apache.commons.logging.LogFactory;
|
||||
import reactor.core.publisher.Hooks;
|
||||
import reactor.core.scheduler.Schedulers;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
@Configuration
|
||||
@AutoConfigureBefore(TraceReactorAutoConfiguration.class)
|
||||
public class TraceReactorAutoConfigurationAccessorConfiguration {
|
||||
|
||||
private static final Log log = LogFactory
|
||||
@@ -31,13 +23,4 @@ public class TraceReactorAutoConfigurationAccessorConfiguration {
|
||||
Schedulers.resetFactory();
|
||||
}
|
||||
|
||||
@Bean
|
||||
static HookRegisteringBeanDefinitionRegistryPostProcessor testTraceHookRegisteringBeanDefinitionRegistryPostProcessor(
|
||||
ConfigurableApplicationContext context) {
|
||||
log.info("Running clean up and creating the post processor");
|
||||
close();
|
||||
return TraceReactorAutoConfiguration.TraceReactorConfiguration
|
||||
.traceHookRegisteringBeanDefinitionRegistryPostProcessor(context);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -56,16 +56,10 @@ public class TraceWebFluxTests {
|
||||
|
||||
public static final String EXPECTED_TRACE_ID = "b919095138aa4c6e";
|
||||
|
||||
@BeforeClass
|
||||
@AfterClass
|
||||
public static void setup() {
|
||||
Hooks.resetOnLastOperator();
|
||||
TraceReactorAutoConfigurationAccessorConfiguration.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_instrument_web_filter() throws Exception {
|
||||
// setup
|
||||
TraceReactorAutoConfigurationAccessorConfiguration.close();
|
||||
ConfigurableApplicationContext context = new SpringApplicationBuilder(
|
||||
TraceWebFluxTests.Config.class)
|
||||
.web(WebApplicationType.REACTIVE)
|
||||
@@ -105,6 +99,7 @@ public class TraceWebFluxTests {
|
||||
|
||||
// cleanup
|
||||
context.close();
|
||||
TraceReactorAutoConfigurationAccessorConfiguration.close();
|
||||
}
|
||||
|
||||
private void clean(ArrayListSpanReporter accumulator, Controller2 controller2) {
|
||||
@@ -173,7 +168,6 @@ public class TraceWebFluxTests {
|
||||
@Configuration
|
||||
@EnableAutoConfiguration(exclude = { TraceWebClientAutoConfiguration.class })
|
||||
@DisableWebFluxSecurity
|
||||
@ImportAutoConfiguration(TraceReactorAutoConfigurationAccessorConfiguration.class)
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
|
||||
Reference in New Issue
Block a user