spring cloud zipkin2 + kafka + es

做个笔记~
虽然官网建议用官方jar包,但是公司的情况用官方jar行不通,所以自定义一下。

spring boot 版本:2.0.4.RELEASE
spring cloud 版本:Finchley.SR1

zipkin server
  • pom.xml

        
            org.springframework.cloud
            spring-cloud-starter-netflix-eureka-client
            2.0.1.RELEASE
        
        
            org.springframework.boot
            spring-boot-starter-web
        
        
            org.springframework.boot
            spring-boot-starter-actuator
        
        
        
        
            io.zipkin.java
            zipkin-server
            2.11.1
        
        
            io.zipkin.java
            zipkin-autoconfigure-ui
            2.11.1
        
        
            io.zipkin.java
            zipkin-autoconfigure-collector-kafka
            2.11.4
        
        
            io.zipkin.java
            zipkin-autoconfigure-storage-elasticsearch-http
            2.8.4
        
    
  • 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

        
            org.springframework.cloud
            spring-cloud-starter-netflix-eureka-client
            2.0.1.RELEASE
        
        
            org.springframework.boot
            spring-boot-starter-web
        
        
            org.projectlombok
            lombok
        
        
            org.springframework.boot
            spring-boot-starter-actuator
        

        
        
            org.springframework.cloud
            spring-cloud-starter-zipkin
        
        
            org.springframework.kafka
            spring-kafka
        
    
  • 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);
    }
}
consumer-service 配置同 provider-service,不在赘述

你可能感兴趣的:(spring cloud zipkin2 + kafka + es)