做个笔记~
虽然官网建议用官方jar包,但是公司的情况用官方jar行不通,所以自定义一下。
spring boot 版本:2.0.4.RELEASE
spring cloud 版本:Finchley.SR1
zipkin server
- pom.xml
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!--zipkin-->
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-server</artifactId>
<version>2.11.1</version>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-ui</artifactId>
<version>2.11.1</version>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-collector-kafka</artifactId>
<version>2.11.4</version>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-storage-elasticsearch-http</artifactId>
<version>2.8.4</version>
</dependency>
</dependencies>
- application.yml
server:
port: 9411
tomcat:
uri-encoding: UTF-8
spring:
application:
name: zipkin-server
zipkin:
storage:
type: elasticsearch
elasticsearch:
hosts: http://localhost:9200
# username: elastic
# password: changeme
cluster: elasticsearch
index: zipkin
index-shards: 1
index-replicas: 1
collector:
kafka:
bootstrap-servers: localhost:9092
zookeeper: localhost:2181
topic: zipkin
eureka:
instance:
lease-expiration-duration-in-seconds: 15
lease-renewal-interval-in-seconds: 5
prefer-ip-address: true
health-check-url-path: /actuator/health
client:
registry-fetch-interval-seconds: 5
service-url:
defaultZone: http://127.0.0.1:8761/eureka/
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
metrics:
web:
server:
auto-time-requests: false
- 启动类
@SpringBootApplication
@EnableEurekaClient
@EnableZipkinServer
public class ZipkinServerApplication {
public static void main(String[] args) {
SpringApplication.run(ZipkinServerApplication.class, args);
}
}
provider-service
- pom.xml
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!--zipkin-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
</dependencies>
- application.yml
server:
port: 8080
tomcat:
uri-encoding: UTF-8
spring:
application:
name: provider
sleuth:
sampler:
probability: 1.0
zipkin:
sender:
type: kafka
kafka:
topic: zipkin
kafka:
bootstrap-servers: localhost:9092
eureka:
instance:
lease-expiration-duration-in-seconds: 15
lease-renewal-interval-in-seconds: 5
prefer-ip-address: true
health-check-url-path: /actuator/health
client:
registry-fetch-interval-seconds: 5
service-url:
defaultZone: http://127.0.0.1:8761/eureka/
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
- 启动类
@SpringBootApplication
@EnableEurekaClient
public class ProviderApplication {
public static void main(String[] args) {
SpringApplication.run(ProviderApplication.class, args);
}
}