Search code examples
elasticsearchspring-cloudspring-data-elasticsearchzipkinspring-cloud-sleuth

Sleuth + Zipkins with Elasticsearch


Can anyone point me towards the required/working configuration to use Elasticsearch as a storage type with Zipkins with Sleuth?

pom.xml

'

<description>Spring Boot Zipkin Server</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.7.RELEASE</version>
</parent>

<properties>
    <docker.image.prefix>springio</docker.image.prefix>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
    <sonar.skip>true</sonar.skip>
    <zipkin.version>1.6.0</zipkin.version>
    <elasticsearch.version>2.3.4</elasticsearch.version>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Camden.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-sleuth</artifactId>
    </dependency>
    <!-- EXAMPLE FOR RABBIT BINDING -->
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-stream-binder-rabbit</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.restdocs</groupId>
        <artifactId>spring-restdocs-mockmvc</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <finalName>demo-zipkin-server</finalName>
            </configuration>
        </plugin>
    </plugins>
</build>

`

application.yml

server: port: 9411 spring: rabbitmq: host: ${RABBIT_HOST:localhost} eureka: client: register-with-eureka: true service-url: defaultZone: http://localhost:8761/eureka/ zipkin: self-tracing: enabled: false storage: type: elasticsearch elasticsearch: cluster: ${ES_CLUSTER:elasticsearch} hosts: ${ES_HOSTS:localhost:9300} index: ${ES_INDEX:zipkin} index-shards: ${ES_INDEX_SHARDS:5} index-replicas: ${ES_INDEX_REPLICAS:1}

Application doesn't start up with these config. It throws Caused by: java.lang.NoSuchMethodError: org.springframework.integration.amqp.support.DefaultAmqpHeaderMapper.inboundMappe


Solution

  • Classpath problems like you've posted are version-specific. Please update to most recent versions of dependencies.

    For example, you can start with a base project using start.spring.io or otherwise to get something with recent deps. You could also copy a project like this:

    https://github.com/openzipkin/sleuth-webmvc-example

    Zipkin currently has native support for elasticsearch (meaning it does not use the Elasticsearch driver). So, the dependency to automatically configure this is:

    <!-- override sleuth's zipkin version since we are using latest -->
    <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin</artifactId>
        <version>1.28.1</version>
    </dependency>
    <!-- add the dependency for elasticsearch via http -->
    <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-autoconfigure-storage-elasticsearch-http</artifactId>
        <version>1.28.1</version>
    </dependency>
    

    Minimally set zipkin.storage.type=elasticsearch. Then, set you are overriding taking note that elasticsearch's http port is 9200 not 9300

    Finally, please upvote native RabbitMQ support in zipkin so you don't need to do any of this! https://github.com/openzipkin/zipkin/issues/1614