美文网首页
集成 zipkin 链路追踪

集成 zipkin 链路追踪

作者: A文艺钦年 | 来源:发表于2018-08-27 19:31 被阅读68次

    部署 server 端

    运行 jar 包启动, java 环境需要1.8以上

    curl -sSL https://zipkin.io/quickstart.sh | bash -s
    # 使用elasticsearch 作为数据库存储
    STORAGE_TYPE=elasticsearch ES_HOSTS=http://server1:9200,http://server2,http://server3:9200 RABBIT_ADDRESSES=server1:5672,server2:5672java -jar zipkin.jar
    

    使用 docker 端方式

    docker run -d -p 9411:9411 openzipkin/zipkin
    

    然后访问 http://localhost:9411 即可打开zipkin web端

    设置client

    zipkin 可以设置存储在内存、mysql、elasticsearch 中,通过两种方式传递消息:http 和 rabbitmq
    我这里的配置使用的是 elasticsearch + rabbitmq

    pom.xml添加依赖:

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-sleuth</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-zipkin</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-stream-binder-rabbit</artifactId>
    </dependency>
    
    

    application.yml 添加:

    spring:
      sleuth:
            web:
              client:
                enabled: true
            sampler:
              probability: 1.0 # 将采样比例设置为 1.0,也就是全部都需要。默认是 0.1
    

    相关文章

      网友评论

          本文标题:集成 zipkin 链路追踪

          本文链接:https://www.haomeiwen.com/subject/aopziftx.html