Ensures that the primitive types are also supported for Stream; fixes gh-2068
This commit is contained in:
@@ -96,6 +96,14 @@ public class TraceFunctionAroundWrapper extends FunctionAroundWrapper
|
||||
else if (targetFunction.isInputTypePublisher() || targetFunction.isOutputTypePublisher()) {
|
||||
return reactorStream((Publisher) message, targetFunction);
|
||||
}
|
||||
else if (message != null && !(message instanceof Message)) {
|
||||
if (log.isDebugEnabled()) {
|
||||
String messageClass = message.getClass().getName();
|
||||
log.debug("We only support tracing for Message types. You need to wrap your function type ["
|
||||
+ messageClass + "] into [Message<" + messageClass + ">]");
|
||||
}
|
||||
return targetFunction.apply(message); // no instrumentation
|
||||
}
|
||||
return nonReactorStream((Message<byte[]>) message, targetFunction);
|
||||
}
|
||||
|
||||
|
||||
@@ -121,6 +121,19 @@ class TraceFunctionAroundWrapperTests {
|
||||
assertThatAllSpansAreStartedAndStopped();
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_tracing_with_function_and_input_as_non_message() {
|
||||
FunctionRegistration<GreeterFunction> registration = new FunctionRegistration<>(new GreeterFunction(),
|
||||
"greeter").type(FunctionType.of(GreeterFunction.class));
|
||||
catalog.register(registration);
|
||||
FunctionInvocationWrapper function = catalog.lookup("greeter");
|
||||
|
||||
String result = (String) wrapper.apply("hello", function);
|
||||
|
||||
assertThat(result).isEqualTo("HELLO");
|
||||
assertThat(tracer.spans).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_tracing_with_consumer() {
|
||||
GreeterConsumer consumer = new GreeterConsumer();
|
||||
|
||||
Reference in New Issue
Block a user