Skip to content

TraceId Missing for Subsequent Kafka Messages in Spring Cloud Stream with Micrometer Observation #1198

@agustino-lim

Description

@agustino-lim

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions