Ensures that sampler proxy gets eagerly resolved; fixes gh-2107

This commit is contained in:
Marcin Grzejszczak
2022-02-02 09:57:50 +01:00
parent 2f2ced8593
commit 2b9b76e5dc
2 changed files with 41 additions and 1 deletions

View File

@@ -151,6 +151,19 @@ class TraceFunctionAroundWrapperTests {
assertThat(tracer.spans).isEmpty();
}
@Test
void test_tracing_with_message_flux_to_flux_without_message() {
FunctionRegistration<MessageFluxToFluxFunction> registration = new FunctionRegistration<>(
new MessageFluxToFluxFunction(), "greeter").type(FunctionType.of(MessageFluxToFluxFunction.class));
catalog.register(registration);
FunctionInvocationWrapper function = catalog.lookup("greeter");
Object result = (Object) ((Flux) wrapper.apply("hello", function)).blockFirst();
assertThat(result).isEqualTo("hello");
assertThat(tracer.spans).isEmpty();
}
@Test
void test_tracing_with_consumer() {
GreeterConsumer consumer = new GreeterConsumer();
@@ -465,4 +478,18 @@ class TraceFunctionAroundWrapperTests {
}
static class MessageFluxToFluxFunction implements Function<Flux<Message<?>>, Flux<?>> {
private static final Logger log = LoggerFactory.getLogger(MessageFluxToFluxFunction.class);
@Override
public Flux<?> apply(Flux<Message<?>> input) {
return input.map(s -> {
log.info("Logging [{}] from map", s);
return s.getPayload();
});
}
}
}