1

我正在尝试使用默认的 mysql span 存储实现 spring cloud sleuth。

(根据问题修改)

我使用了 Brixton.SR4 和 spring boot 1.3.7 和 Java 8

服务很简单

@SpringBootApplication
@EnableDiscoveryClient
@EnableZipkinStreamServer
public class TraceCollectionServiceApplication {

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

}

pom文件如下:

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

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

启动时的异常跟踪如下

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)

UI 也显示此错误

用户界面错误

4

1 回答 1

2

我会回答 spring-cloud-dependencies Brixton.SR5 ......

^^ 将 spring-cloud-sleuth 设置为 1.0.6.RELEASE ^^ 将 zipkin 设置为 1.1.5 ^^ 针对 3.8.2 构建

现在 spring boot 1.3.7 首先出现,并且(通过 spring-boot-dependencies)将 jooq 设置为 3.7.4,这与 3.8.2 运行时不兼容。

最简单的方法是在你的 pom 中声明 jooq,像这样..

<!-- For zipkin. Remove when using Spring boot 1.4+ -->
<dependency>
  <groupId>org.jooq</groupId>
  <artifactId>jooq</artifactId>
  <version>3.8.2</version>
</dependency>
于 2016-08-25T06:48:56.507 回答