Search code examples
spring-cloudspring-cloud-sleuth

error on running spring cloud sleuth with mysql impl


I was trying out the implementation of spring cloud sleuth using the default mysql span store.

(Modified based on question)

I used Brixton.SR4 and spring boot 1.3.7 and Java 8

The service was simple

@SpringBootApplication
@EnableDiscoveryClient
@EnableZipkinStreamServer
public class TraceCollectionServiceApplication {

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

}

the pom file is as follows:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.cisco.phisphere.tracecollectionservice</groupId>
    <artifactId>tracecollectionservice</artifactId>
    <packaging>jar</packaging>

    <name>tracecollectionservice</name>
    <description>Distributed Trace Collection Service</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.7.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
    </properties>

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


    <dependencies>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
        <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>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>io.zipkin.java</groupId>
            <artifactId>zipkin-server</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>io.zipkin.java</groupId>
            <artifactId>zipkin-autoconfigure-ui</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>


    <build>

        <finalName>tracecollectionservice</finalName>

        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>

    </build>

</project>

This is the configuration in the application.yml

spring:
  application:
    name: tracecollectionservice

  datasource:
    schema: classpath:/mysql.sql
    url: jdbc:mysql://localhost:3306/test
    username: root
    # Switch this on to create the schema on startup:
    initialize: true
    continueOnError: true
    driverClassName: com.mysql.jdbc.Driver

  sleuth:
    enabled: false

zipkin:
  storage:
    type: mysql

info:
  component: Trace Collection Service
  app:
    name: Trace Collection Service
    description: the trace collections service
    version: 1.0.0
  build:
    artifact: com.cisco.phisphere.collectionservice
    name: collectionservice
    description: This service collections transaction and other things
    version: 1.0.0

server:
  port: 9411

management:
  context-path: /manage
  security:
    enabled: false

security:
  basic:
    enabled: false
  user:
    name: phiuser
    password: SecretPassword



eureka:
  # these are settings for the client that gets services
  client:
    # enable these two settings if you want discovery to work
    registerWithEureka: true
    fetchRegistry: true
    serviceUrl:
      # we use the secure form having user/password in the main
      defaultZone: http://localhost:8761/eureka/
  # this describes the actual instance that is registered and parameters around it
  instance:
    statusPageUrlPath: /manage/info
    homePageUrlPath: /manage
    healthCheckUrlPath: /manage/health
    preferIpAddress: true
    aSGName: phisphereCluster
    metadataMap:
      swaggerEnabled: false

The exception trace on start was the following

Exception in thread "ZipkinMySQLStorage-2" java.lang.VerifyError: zipkin/storage/mysql/internal/generated/tables/ZipkinSpans
    at zipkin.storage.mysql.MySQLSpanConsumer.accept(MySQLSpanConsumer.java:65)
    at zipkin.storage.InternalBlockingToAsyncSpanConsumerAdapter$1.complete(InternalBlockingToAsyncSpanConsumerAdapter.java:34)
    at zipkin.storage.InternalBlockingToAsyncSpanConsumerAdapter$1.complete(InternalBlockingToAsyncSpanConsumerAdapter.java:32)
    at zipkin.storage.InternalCallbackRunnable.run(InternalCallbackRunnable.java:29)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

The UI also displays this error

Erro on UI


Solution

  • I'll answer for spring-cloud-dependencies Brixton.SR5...

    ^^ sets spring-cloud-sleuth to 1.0.6.RELEASE ^^ sets zipkin to 1.1.5 ^^ is built against 3.8.2

    Now spring boot 1.3.7 comes first, and (via spring-boot-dependencies) sets jooq to 3.7.4 which is runtime incompatible with 3.8.2.

    Easiest way out is to declare jooq in your pom, like this..

    <!-- For zipkin. Remove when using Spring boot 1.4+ -->
    <dependency>
      <groupId>org.jooq</groupId>
      <artifactId>jooq</artifactId>
      <version>3.8.2</version>
    </dependency>