デフォルトの mysql スパン ストアを使用して、Spring Cloud sleuth の実装を試していました。
(質問に基づいて変更)
Brixton.SR4とスプリングブート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 にもこのエラーが表示されます