SpringCloud_Zipkin Dear 丶 2021-10-06 03:24 357阅读 0赞 ### SpringCloud\_Zipkin ### * 依赖pom.xml * 配置文件bootstrap.yml * 配置源码 # 依赖pom.xml # <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> <parent> <groupId>org.pingruan</groupId> <artifactId>vander-framework-parent</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <groupId>org.pingruan.springboot</groupId> <artifactId>vander-zipkin-center</artifactId> <name>分布式链路跟踪系统</name> <description>微服务之间的调用链分享跟踪</description> <dependencies> <!-- 服务监控 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> </dependency> <dependency> <groupId>io.zipkin.java</groupId> <artifactId>zipkin-server</artifactId> <exclusions> <exclusion> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-slf4j-impl</artifactId> </exclusion> <exclusion> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>io.zipkin.java</groupId> <artifactId>zipkin-autoconfigure-ui</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>io.zipkin.java</groupId> <artifactId>zipkin-autoconfigure-storage-elasticsearch-http</artifactId> <version>2.8.4</version> </dependency> </dependencies> </project> # 配置文件bootstrap.yml # server: port: 9006 spring: application: name: vander-zipkin-center management: metrics: web: server: auto-time-requests: false #---------------数据持久化-es配置--------------- zipkin: storage: type: elasticsearch elasticsearch: hosts: http://192.168.164.100:9200 # username: elastic # password: changeme cluster: elasticsearch index: zipkin index-shards: 5 index-replicas: 1 #------------注册中心配置------------------ eureka: client: registerWithEureka: true #服务注册开关 fetchRegistry: true #服务发现开关 serviceUrl: #Eureka客户端与Eureka服务端进行交互的地址,多个中间用逗号分隔 defaultZone: ${EUREKA_SERVERS:http://root:qwe123@server1:9001/eureka/} instance: prefer-ip-address: true #将自己的ip地址注册到Eureka服务中 ip-address: ${IP_ADDRESS:127.0.0.1} instance-id: ${spring.application.name}:${server.port} #指定实例id # 配置源码 # /** * 分布式链路跟踪系统 * * 被监控服务 * 添加依赖: * <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-zipkin</artifactId> </dependency> * * 添加配置: * spring.sleuth.sampler.percentage=1.0 # 0.1-1 1表示全部采样 * spring.zipkin.base-url=http://localhost:9006 * spring.zipkin.sender.type=web # 可以使用队列rabbitmq kafaka * @author vander * */ @EnableDiscoveryClient @SpringBootApplication @EnableZipkinServer public class SpringBootZipkinCenter { public static void main(String[] args) { SpringApplication.run(SpringBootZipkinCenter.class, args); } }
还没有评论,来说两句吧...