Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Spring Cloud Zipkin Server with MySQL for persistence?

Which exact dependencies and application.yml configuration are required for Spring Boot/Cloud Zipkin server (potentially Zipkin Stream server) to persist the tracing data using MySQL?

like image 862
burcakulug Avatar asked Aug 26 '16 21:08

burcakulug


People also ask

How do you set up a zipkin server?

For windows installation, just download the latest Zipkin server from the maven repository and run the executable jar file using the below command. Once Zipkin is started, we can see the Web UI at http://localhost:9411/zipkin/. The above command will start the Zipkin server with the default configuration.

Is zipkin deprecated?

The default destination name is zipkin . spring-cloud-sleuth-stream is deprecated and incompatible with these destinations.

How do you turn on zipkin in spring boot?

Add the @EnableZipkinServer annotation in your main Spring Boot application class fie. The @EnableZipkinServer annotation is used to enable your application act as a Zipkin server.


1 Answers

The official documentation was helpful, but I think it didn't include all the dependencies explicitly (at least as of now). I had to do some extra research for samples to get all the required dependencies and configuration together. I wanted to share it, because I believe it could be helpful for someone else.

Spring Boot version: 1.4.0.RELEASE

Spring Cloud version: Brixton.SR4

POM:

    ...
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-server</artifactId>
    </dependency>
    <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-autoconfigure-storage-mysql</artifactId>
    </dependency>

    <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-autoconfigure-ui</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
   ...
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Brixton.SR4</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

Java:

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import zipkin.server.EnableZipkinServer;

@SpringBootApplication
@EnableZipkinServer
public class ZipkinServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(ZipkinServerApplication.class, args);
    }
}

application.yml:

spring:
  datasource:
    schema: classpath:/mysql.sql
    url: jdbc:mysql://localhost:3306/zipkin?autoReconnect=true
    username: root
    password: admin
    driver-class-name: com.mysql.jdbc.Driver
    initialize: true
    continue-on-error: true
  sleuth:
    enabled: false
zipkin:
  storage:
    type: mysql

References:

https://cloud.spring.io/spring-cloud-sleuth/

like image 105
burcakulug Avatar answered Oct 01 '22 08:10

burcakulug