use of org.springframework.cloud.sleuth.util.ArrayListSpanReporter in project spring-cloud-sleuth by spring-cloud.
the class FactoryUser method should_work_with_flat_maps.
@Test
public void should_work_with_flat_maps() {
// given
ConfigurableApplicationContext context = new SpringApplicationBuilder(FlatMapTests.TestConfiguration.class, Issue866Configuration.class).web(WebApplicationType.REACTIVE).properties("server.port=0", "spring.jmx.enabled=false", "spring.application.name=TraceWebFluxTests", "security.basic.enabled=false", "management.security.enabled=false").run();
ArrayListSpanReporter accumulator = context.getBean(ArrayListSpanReporter.class);
int port = context.getBean(Environment.class).getProperty("local.server.port", Integer.class);
RequestSender sender = context.getBean(RequestSender.class);
TestConfiguration config = context.getBean(TestConfiguration.class);
FactoryUser factoryUser = context.getBean(FactoryUser.class);
sender.port = port;
accumulator.clear();
Awaitility.await().untilAsserted(() -> {
// when
accumulator.clear();
String firstTraceId = flatMapTraceId(accumulator, callFlatMap(port).block());
// then
thenAllWebClientCallsHaveSameTraceId(firstTraceId, sender);
thenSpanInFooHasSameTraceId(firstTraceId, config);
accumulator.clear();
// when
String secondTraceId = flatMapTraceId(accumulator, callFlatMap(port).block());
// then
then(firstTraceId).as("Id will not be reused between calls").isNotEqualTo(secondTraceId);
thenSpanInFooHasSameTraceId(secondTraceId, config);
// and
then(Arrays.stream(capture.toString().split("\n")).filter(s -> s.contains("Received a request to uri")).map(s -> s.split(",")[1]).collect(Collectors.toList())).as("TraceFilter should not have any trace when receiving a request").containsOnly("");
// and #866
then(factoryUser.wasSchedulerWrapped).isTrue();
});
}
use of org.springframework.cloud.sleuth.util.ArrayListSpanReporter in project spring-cloud-sleuth by spring-cloud.
the class TraceWebFluxTests method should_instrument_web_filter.
@Test
public void should_instrument_web_filter() throws Exception {
// setup
ConfigurableApplicationContext context = new SpringApplicationBuilder(TraceWebFluxTests.Config.class).web(WebApplicationType.REACTIVE).properties("server.port=0", "spring.jmx.enabled=false", "spring.sleuth.web.skipPattern=/skipped", "spring.application.name=TraceWebFluxTests", "security.basic.enabled=false", "management.security.enabled=false").run();
ArrayListSpanReporter accumulator = context.getBean(ArrayListSpanReporter.class);
int port = context.getBean(Environment.class).getProperty("local.server.port", Integer.class);
Controller2 controller2 = context.getBean(Controller2.class);
clean(accumulator, controller2);
// when
ClientResponse response = whenRequestIsSent(port);
// then
thenSpanWasReportedWithTags(accumulator, response);
clean(accumulator, controller2);
// when
ClientResponse nonSampledResponse = whenNonSampledRequestIsSent(port);
// then
thenNoSpanWasReported(accumulator, nonSampledResponse, controller2);
// when
ClientResponse skippedPatternResponse = whenRequestIsSentToSkippedPattern(port);
// then
thenNoSpanWasReported(accumulator, skippedPatternResponse, controller2);
// cleanup
context.close();
}
Aggregations