How to configure Spring Cloud Zipkin Server with MySQL Persistence?

What exact dependencies and configuration are application.ymlneeded for the Spring Boot / Cloud Zipkin server (possibly the Zipkin Stream server) to save trace data using MySQL?

+4
source share
1 answer

The official documentation was useful, but I think that it did not explicitly include all the dependencies (at least for now). I had to do additional research for the samples to collect all the necessary dependencies and configuration. I wanted to share it, because I believe that it can be useful for someone else.

Spring : 1.4.0.RELEASE

Spring : 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

:

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

+6

Source: https://habr.com/ru/post/1652655/


All Articles