Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding doOnSubscribe directly on receiveAutoAck breaks tracing propagation #392

Open
Thyago opened this issue Aug 7, 2024 · 0 comments
Open

Comments

@Thyago
Copy link

Thyago commented Aug 7, 2024

When adding a doOnSubscribe just after the ReactiveKafkaConsumerTemplate receiveAutoAck flux, leads to the loss of tracing context.
This was tested having Datadog Agent running, which injects parent_id and trace_id.

Expected Behavior

Having a simple doOnSubscribe under the ReactiveKafkaConsumerTemplate receiveAutoAck flux should not affect the tracing context.

Actual Behavior

When doOnSubscribe is added, the tracing is lost and no longer logged or propagated by the service.

Steps to Reproduce

  1. Have a tracing agent in place (Eg DataDog)
  2. Add a doOnSubscribe after the receiveAutoAck call:
@Service
@RequiredArgsConstructor
@Slf4j
public class EventListener {
    private final ReactiveKafkaConsumerTemplate<String, JsonNode> reactiveKafkaConsumerTemplate;

    @EventListener(ApplicationStartedEvent.class)
    public Disposable eventRunner() {
        return reactiveKafkaConsumerTemplate
            .receiveAutoAck()
            .doOnSubscribe(s -> log.info("Consumer started"))
            .flatMap(consumerRecord -> handleEvent(consumerRecord.value(), consumerRecord.headers()))
            .onErrorContinue((error, value) -> log.error("Error while consuming", error.getStackTrace()))
            .subscribe();
    }
}
  1. Listen to events and check for trace_id propagation

Environment

Behaviour tested on:

  • Spring Boot 3.2.5 up to 3.3.2 (Netty)
  • Datadog Java Agent 1.34.0 to 1.38.0
  • Reactor Kafka: 1.3.22 to 1.3.23
  • Java: 21
  • OS: Debian 10 (using Azul Zulu image with Java 21 and Debian 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant