amazon-ec2spring-bootcassandrazipkinspring-cloud-sleuth

Spring Cassandra driver always connected to localhost


im trying to connect my Spring Boot app to a Cassandra 2.2.8 cluster on EC2 instances (2 nodes). my use is tracing with Sleuth and Zipkin.

when the tracing start, the driver always point to localhost :

com.datastax.driver.core.Cluster : New Cassandra host localhost/127.0.0.1:9042 added

this is my application.properties

spring.datasource.url=jdbc:cassandra://url-node-1:9042
spring.datasource.contactPoints=url-node-1,url-node-2
zipkin.storage.type=cassandra
spring.datasource.initialize=true
spring.datasource.continue-on-error=true
spring.sleuth.enabled=false

and this is my pom.xml :

<dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-autoconfigure-storage-cassandra</artifactId>
        <version>1.17.1</version>
        <exclusions>
            <exclusion>
                <artifactId>cassandra-driver-core</artifactId>
                <groupId>com.datastax.cassandra</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.datastax.cassandra</groupId>
        <artifactId>cassandra-driver-core</artifactId>
        <version>3.1.0</version>
    </dependency>
    <dependency>
        <groupId>com.datastax.cassandra</groupId>
        <artifactId>cassandra-driver-mapping</artifactId>
        <version>3.1.0</version>
    </dependency>

Solution

  • Zipkin's connection to cassandra is independent from the normal spring setup. We use some very specific setup. you'll want to set properties in the namespace of zipkin.storage.cassandra

    https://github.com/openzipkin/zipkin/blob/master/zipkin-server/src/main/resources/zipkin-server-shared.yml#L40