Describe the bug
We are experiencing an issue with trace propagation in Spring Cloud Stream’s Kafka consumer while using Micrometer Observation. The traceId is present for the first Kafka message processed, but it is missing for all subsequent messages.
In our investigation, we found the following code in SimpleFunctionRegistry that might be relevant to the issue:
if (functionAroundWrapper != null && !this.wrapped) {
this.wrapped = true;
result = functionAroundWrapper.apply(input, this);
} else {
result = this.doApply(input);
}
It appears that the wrapped check may prevent subsequent messages from receiving the necessary trace context, potentially causing the traceId to be missing.
Sample
function-composition-kafka.zip