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

Open tracing with spring cloud with Kafka, Redis, mysql initiate new span always #295

Closed
chandresh-pancholi opened this issue Jun 24, 2020 · 9 comments · Fixed by #306
Closed

Comments

@chandresh-pancholi
Copy link

Hi,

I am written spring boot application using java-spring-cloud.

Request flow

REST --> Controller --> Kafka Producer --> Kafka Consumer --> Redis Set ---> Save into MySQL DB

I am receiving two different traces

  1. Rest --> Controller --> Kafka producer--> Kafka consumer
  2. Redis set

Mysql spans are not even generating.

@pavolloffay
Copy link
Contributor

How are you calling the redis client? If it is called in a new separate thread it might break the context propagation resulting in two traces.

cc) @malafeev could you please have a look?

@chandresh-pancholi
Copy link
Author

chandresh-pancholi commented Jun 24, 2020

Redis command

    private final LettuceConnectionFactory redisClusterConnection;

    public void set(String key, String value) {
        redisClusterConnection.getClusterConnection().set(key.getBytes(), value.getBytes());
    }

kafka consume

 @KafkaListener(topics = "${topic}", containerFactory = "factory", groupId = "${group.id}")
    public void activityConsume(ConsumerRecord<String, TestAvro> record) {    
        Activity activity = record.value();
        repository.save();
        redisCommand.set(String.format("%s:%s", "123", "456" ), 0);
    }

@malafeev
Copy link

@chandresh-pancholi how your consumer looks like? do you use @KafkaListener annotation?

@chandresh-pancholi
Copy link
Author

@malafeev , I have updated the comment. please check.

@malafeev
Copy link

yes, it's a limitation. We don't intercept @KafkaListener annotated method to activate consumer span.
It should be possible to extract span context from the record headers and then build child span of it but that's too much coding.

@chandresh-pancholi
Copy link
Author

That's alright but why it only shows redis span but not mysql.

@malafeev
Copy link

malafeev commented Jun 25, 2020

mysql (jdbc) span should be created, but what repository.save(); is doing? Does it use MySQL JDBC driver to persist entity?

Didn't you set
opentracing.spring.cloud.jdbc.withActiveSpanOnly property to true?
It should be false because there is no active span.

@chandresh-pancholi
Copy link
Author

Got it. Thanks @malafeev

@orange-buffalo
Copy link
Contributor

There is a PR to implement missing support of @KafkaListener in java-kafka-client (see opentracing-contrib/java-kafka-client#83). Should we reopen this issue or create a new one to integrate a new version of java-kafka-client?

orange-buffalo added a commit to orange-buffalo/java-spring-cloud that referenced this issue Oct 30, 2020
pavolloffay pushed a commit that referenced this issue Oct 30, 2020
…pentracing-contrib/java-kafka-client:0.1.15`. (#306)

Fixes #295.
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

Successfully merging a pull request may close this issue.

4 participants