我正在尝试使用默认的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也会显示此错误
答案 0 :(得分: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>