zipkin-server
pom
io.zipkin zipkin-ui 1.39.3 org.springframework.boot spring-boot-starter-jdbc org.springframework.cloud spring-cloud-sleuth-zipkin-stream 1.0.0.RELEASE org.springframework.cloud spring-cloud-starter-stream-rabbit 1.0.0.RELEASE com.h2database h2
application.yaml
spring: rabbitmq: addresses: rabbitmq# datasource:# #脚本位置:依赖spanstore-jdbc-0.9.3.jar内## schema: classpath:/mysql.sql# url: jdbc:mysql://zipkin_mysql:3306/zipkin# username: zipkin# password: zipkin# # Switch this on to create the schema on startup:# initialize: true# continueOnError: true sleuth: # not use sleuth stream to trace zipkin server itself enabled: false #refer to org.springframework.cloud.sleuth.instrument.hystrix.SleuthHystrixAutoConfiguration.java hystrix: strategy: enabled: falsezipkin: storage: type: mem #mysql #mem
application
@EnableZipkinStreamServer@SpringBootApplicationpublic class ZipkinServerApplication { public static void main(String[] args){ SpringApplication.run(ZipkinServerApplication.class,args); }}
zipkin-client
pom
org.springframework.boot spring-boot-starter-aop org.springframework.cloud spring-cloud-sleuth-stream 1.0.0.RELEASE org.springframework.cloud spring-cloud-starter-stream-rabbit 1.0.0.RELEASE org.springframework.cloud spring-cloud-starter-ribbon 1.0.6.RELEASE io.reactivex rxjava io.reactivex rxjava 1.1.5
application.yml
spring:# mq stream format to send trace data rabbitmq: addresses: rabbitmq #zipkin config zipkin: #defult is true,to use zipkin,false:not use enabled: true baseUrl: http://zipkin:9411/ sleuth: sampler: # 采样率,默认0.1即10%,如需测试时每次都看到trace则修改为1.0,但对性能有影响,注意上线时修改为合理值 percentage: 1.0 hystrix: strategy: enabled: true #https://github.com/ReactiveX/RxJava/issues/2297 rxjava: schedulers: hook: enabled: false # stream format to send trace msg: enable sleuth.stream to use stream # default is true,refer to SleuthStreamAutoConfiguration.java stream: enabled: true # skip tracing urls' pattern,refer to org.springframework.cloud.sleuth.instrument.web.TraceWebAutoConfiguration #web: #skipPattern: /eureka.*# zipkin properties for ServiceApplication.java to debug when there is no zipkin serversample: zipkin: # When enabled=false, traces log to the console. Comment to send to zipkin enabled: true
application
@SpringBootApplication@EnableDiscoveryClient@EnableFeignClients@EnableCircuitBreaker@EnableHystrix@EnableHystrixDashboard@EnableAspectJAutoProxy(proxyTargetClass = true)@EnableAsyncpublic class TraceDemoApplication { @Bean Sampler sampler() { return new AlwaysSampler(); } public static void main(String[] args){ SpringApplication.run(TraceDemoApplication.class,args); }}
docker-compose
rabbitmq: image: rabbitmq:management expose: - 5672 - 15672 ports: - 5672:5672 - 15672:15672zipkin: image: zipkin-server restart: always ports: # Listen port for the Scribe transport - "9410:9410" # Historical port used for the Zipkin HTTP Api - "9411:9411" - "9901:9901" links: - rabbitmqtrace_demo: image: trace-demo restart: always ports: - "9998:9998" links: - discovery - config - rabbitmq - zipkin
运行
查询
参考
(
推荐
)(
推荐
)