资讯专栏INFORMATION COLUMN

springboot+zipkin+docker实例

Wuv1Up / 782人阅读

摘要:脚本位置依赖内采样率,默认即如需测试时每次都看到则修改为,但对性能有影响,注意上线时修改为合理值运行查询参考规范推荐推荐谷歌的大规模分布式跟踪系统分布式服务的

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: false

zipkin:
  storage:
    type: mem #mysql #mem

application

@EnableZipkinStreamServer
@SpringBootApplication
public 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 server
sample:
  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)
@EnableAsync
public 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:15672
zipkin:
  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:
    - rabbitmq

trace_demo:
  image: trace-demo
  restart: always
  ports:
    - "9998:9998"
  links:
    - discovery
    - config
    - rabbitmq
    - zipkin    
运行

http://192.168.99.100:9411/

查询

参考

opentracing规范

Diving Deeper into ‘Getting Started with Spring Cloud’

Distributed Tracing with Spring Cloud Sleuth and Spring Cloud Zipkin(推荐)

docs-spring-cloud-sleuth(推荐)

Dapper:谷歌的大规模分布式跟踪系统

分布式服务的Trace——Google Dapper & Twitter Zipkin

Make RxJavaPlugins.reset() public

docker-zipkin

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/26604.html

相关文章

  • 微服务调用链追踪中心搭建

    摘要:一个客户端请求从发出到被响应经历了哪些组件哪些微服务请求总时长每个组件所花时长等信息我们有必要了解和收集,以帮助我们定位性能瓶颈进行性能调优,因此监控整个微服务架构的调用链十分有必要,本文将阐述如何使用搭建微服务调用链追踪中心。 showImg(https://segmentfault.com/img/remote/1460000014553707); 概述 一个完整的微服务系统包含...

    Pines_Cheng 评论0 收藏0
  • 利用Zipkin追踪Mysql数据库调用链

    摘要:注本文首发于公众号,可长按或扫描下面的小心心来订阅扩展组件是在微服务调用链追踪中心搭建一文中编写的与通信的工具组件,利用其追踪微服务调用链的,现在我们想追踪数据库调用链的话,可以扩展一下其功能。 showImg(https://segmentfault.com/img/remote/1460000014751186); 概述 在前面:微服务调用链追踪中心搭建 一文中我们利用Zipki...

    姘存按 评论0 收藏0
  • springboot(2.1.0)+springcloud(Greenwich.M1)实现链路追踪

    摘要:主要问题由于新版本新版本实现链路追踪的一些新特性,使得我在实现的过程上踩了不少坑。同样一些场景下需要保存链路追踪的数据,以备后面观察对比,所以同样需要一个来存储数据。方法一,通过修改基配置文件后启动。 主要问题      由于springboot新版本(2.1.0)、springcloud新版本(Greenwich.M1)实现链路追踪sleuth+zipkin的一些新特性,使得我在实...

    Joonas 评论0 收藏0
  • 使用Envoy 作Sidecar Proxy的微服务模式-3.分布式追踪

    摘要:在第三部分中,我们将了解如何在服务网格中启用分布式跟踪。在此部署模型中,被部署为服务的在本例中为客户端。会在服务调用之间添加一些追踪,并发送到或您的跟踪提供商目前支持和。这些示例的上游服务是。 本博客是深入研究Envoy Proxy和Istio.io 以及它如何实现更优雅的方式来连接和管理微服务系列文章的一部分。 这是接下来几个部分的想法(将在发布时更新链接): 断路器(第一部分) ...

    Fundebug 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<