有收集資料那一定要有個介面看才比較方便, 這邊介紹如何建立 UI 的 Service
build.gradle 加上 io.zipkin.java:zipkin-autoconfigure-ui
buildscript {
ext {
springBootVersion = '1.4.1.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
jar {
baseName = 'ZipkinService'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.cloud:spring-cloud-starter-config')
compile('org.springframework.cloud:spring-cloud-starter-eureka')
compile('io.zipkin.java:zipkin-server')
runtime('io.zipkin.java:zipkin-autoconfigure-ui')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Camden.RELEASE"
}
}
程式部分
需要啟用 @EnableZipkinServer
ZipkinServiceApplication.java
package com.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import zipkin.server.EnableZipkinServer;
@EnableEurekaClient
@EnableZipkinServer
@SpringBootApplication
public class ZipkinServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ZipkinServiceApplication.class, args);
}
}
放在 Config-Service 那邊的配置
zipkin-service.yml
server.port: ${PORT:9411}
spring.datasource.initialize: false
spring.sleuth.enabled: false
zipkin.store.type: mem
啟動後
就可以看到這樣的 UI 了