Spring Cloud第九篇 | 分布式服务跟踪Sleuth

​本文是Spring Cloud专栏的第九篇文章,了解前八篇文章内容有助于更好的理解本文:html

  1. Spring Cloud第一篇 | Spring Cloud前言及其经常使用组件介绍概览前端

  2. Spring Cloud第二篇 | 使用并认识Eureka注册中心java

  3. Spring Cloud第三篇 | 搭建高可用Eureka注册中心node

  4. Spring Cloud第四篇 | 客户端负载均衡Ribbonlinux

  5. Spring Cloud第五篇 | 服务熔断Hystrixgit

  6. Spring Cloud第六篇 | Hystrix仪表盘监控Hystrix Dashboardgithub

  7. Spring Cloud第七篇 | 声明式服务调用Feignspring

  8. Spring Cloud第八篇 | Hystrix集群监控Turbin数据库

1、Sleuth前言

    随着业务的发展,系统规模也会变得愈来愈大,各微服务间的调用关系也变得愈来愈错综复杂。一般一个由客户端发起的请求在后端系统中会通过多个不一样的微服务调用来协同产生最后的请求结果,在复杂的微服务架构系统中,几乎每个前端请求都会造成一条复杂的分布式服务调用链路,在每条链路中任何一个依赖服务出现延迟太高或错误的时候都有可能引发请求最后的失败。这时候, 对于每一个请求,全链路调用的跟踪就变得愈来愈重要,经过实现对请求调用的跟踪能够帮助咱们快速发现错误根源以及监控分析每条请求链路上的性能瓶颈等。windows

    Spring Cloud组件中Spring Cloud Sleuth提供了一套完整的解决方案,下面将介绍Spring Cloud Sleuth的应用

2、Sleuth快速入门

一、为了保持其余模块的整洁性,从新搭建一个消费者(springcloud-consumer-sleuth),提供者(springcloud-consumer-sleuth),消费者和提供者都是和前面所用的都同样没有什么区别,注册中心仍是使用前面案例的注册中心(springcloud-eureka-server/8700),详细查看案例源码。

二、完成以上工做以后,咱们为服务提供者和服务消费者添加跟踪功能,经过Spring Cloud Sleuth的封装,咱们为应用增长服务跟踪能力的操做很是方便,只须要在服务提供者和服务消费者增长spring-cloud-starter-sleuth依赖便可

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>

三、访问消费者接口,而后查看控制台日志显示

消费者(springcloud-consumer-sleuth)打印的日志

2019-12-05 12:30:20.178  INFO [springcloud-consumer-sleuth,f6fb983680aab32b,f6fb983680aab32b,false] 8992 --- [nio-9090-exec-1] c.s.controller.SleuthConsumerController  : === consumer hello ===

提供者(springcloud-provider-sleuth)打印的日志

2019-12-05 12:30:20.972  INFO [springcloud-provider-sleuth,f6fb983680aab32b,c70932279d3b3a54,false] 788 --- [nio-8080-exec-1] c.s.controller.SleuthProviderController  : === provider hello ===

    从上面的控制台输出内容中,咱们能够看到多了一些形如 [springcloud-consumer-sleuth,f6fb983680aab32b,c70932279d3b3a54,false]的日志信息,而这些元素正是实现分布式服务跟踪的重要组成部分,每一个值的含义以下所述:

  • 第一个值: springcloud-consumer-sleuth,它记录了应用的名称,也就是application properties 中spring.application.name参数配置的属性

  • 第二个值:f6fb983680aab32b, Spring Cloud Sleuth生成的一个ID,称为Trace ID, 它用来标识一条请求链路。一条请求链路中包含一个Trace ID,多个Span ID

  • 第三个值:c70932279d3b3a54, Spring Cloud Sleuth生成的另一个ID,称为Span ID,它表示一个基本的工做单元,好比发送一个HTTP请求

  • 第四个值: false,表示是否要将该信息输出到Zipkin等服务中来收集和展现。上面四个值中的Trace ID和Span ID是Spring Cloud Sleuth实现分布式服务跟踪的核心,在一次服务请求链路的调用过程当中,会保持并传递同一个Trace ID,从而将整个分布于不一样微服务进程中的请求跟踪信息串联起来。以上面输出内容为例springcloud-consumer-sleuth和springcloud-provider-sleuth同属于一个前端服务请求资源,因此他们的Trace ID是相同的,处于同一条请求链路中。

3、跟踪原理

分布式系统中的服务跟踪在理论上并不复杂,主要包括下面两个关键点:

  1. 为了实现请求跟踪,当请求发送到分布式系统的入口端点时,只须要服务跟踪框架为该请求建立一个惟一的跟踪标识,同时在分布式系统内部流转的时候,框架始终保持传递该惟一标识,直到返回给请求方为止,这个惟一标识就是前文中提到的Trace ID。经过Trace ID的记录,咱们就能将全部请求过程的日志关联起来

  2. 为了统计各处理单元的时间延迟,当请求到达各个服务组件时,或是处理逻辑到达某个状态时,也经过一个惟一标识来标记它的开始、具体过程以及结束,该标识就是前面提到的Span ID。对于每一个Span来讲,它必须有开始和结束两个节点,经过记录开始Span和结束Span的时间戳,就能统计出该Span的时间延迟,除了时间 戳记录以外,它还能够包含一些其余元数据,好比事件名称、请求信息等

    在【2、sleuth快速入门】示例中,咱们轻松实现了日志级别的跟踪信息接入,这彻底归功于spring-cloud-starter-sleuth组件的实现,在SpringBoot应用中经过在工程中引入spring-cloud-starter-sleuth依赖以后,他会自动为当前应用构建起各通讯通道的跟踪机制,好比:

  • 经过RabbitMQ、Kafka(或者其余任何Spring Cloud Stream绑定器实现的消息中间件)传递的请求

  • 经过Zuul代理传递的请求

  • 经过RestTemplate发起的请求

    在【2、sleuth快速入门】示例中,因为springcloud-consumer-sleuth对springcloud-provider-sleuth发起的请求是经过RestTemplate实现的,因此spring-cloud-starter-sleuth组件会对该请求进行处理。在发送到springcloud-provider-sleuth以前,Sleuth会在该请求的Header中增长实现跟踪须要的重要信息,主要有下面这几个(更多关于头信息的定义能够经过查看org.springframework.cloud.sleuth.Span的源码获取)。

  • X-B3-TraceId:一条请求链路( Trace)的惟一标识,必需的值。

  • X-B3- SpanId:一个工做单元(Span)的惟一标识,必需的值。

  • X-B3- ParentSpanId:标识当前工做单元所属的上一个工做单元, Root Span(请求链路的第一个工做单元)的该值为空。

  • X-B3-Sampled:是否被抽样输出的标志,1表示须要被输出,0表示不须要被输出。

  • X-B3-Name:工做单元的名称

能够经过对springcloud-provider-sleuth的实现作一些修改来输出这些头信息,具体以下:

private final Logger logger = Logger.getLogger(SleuthProviderController.class.getName()); @RequestMapping("/hello") public String hello(HttpServletRequest request){ logger.info("=== provider hello ===,Traced={"+request.getHeader("X-B3-TraceId")+"},SpanId={"+request.getHeader("X-B3- SpanId")+"}"); return "Trace"; }

经过上面的改造,再次重启案例,而后访问咱们查看日志,能够看到提供者输出了正在处理的TraceId和SpanId信息。

消费者(springcloud-consumer-sleuth)打印的日志

2019-12-05 13:15:01.457  INFO [springcloud-consumer-sleuth,41697d7fa118c150,41697d7fa118c150,false] 10036 --- [nio-9090-exec-2] c.s.controller.SleuthConsumerController  : === consumer hello ===

提供者(springcloud-provider-sleuth)打印的日志

2019-12-05 13:15:01.865  INFO [springcloud-provider-sleuth,41697d7fa118c150,863a1245c86b580e,false] 11088 --- [nio-8080-exec-1] c.s.controller.SleuthProviderController  : === provider hello ===,Traced={41697d7fa118c150},SpanId={863a1245c86b580e}

4、抽样收集

    经过Trace ID和Span ID已经实现了对分布式系统中的请求跟踪,而记录的跟踪信息最终会被分析系统收集起来,并用来实现对分布式系统的监控和分析功能,好比,预警延迟过长的请求链路、查询请求链路的调用明细等。此时,咱们在对接分析系统时就会碰到个问题:分析系统在收集跟踪信息的时候,须要收集多少跟踪信息才合适呢?

    理论上来讲,咱们收集的跟踪信息越多就能够越好地反映出系统的实际运行状况,并给出更精准的预警和分析。可是在高并发的分布式系统运行时,大量的请求调用会产生海量的跟踪日志信息,若是收集过多的跟踪信息将会对整个分布式系统的性能形成必定的影响,同时保存大量的日志信息也须要很多的存储开销。因此,在Sleuth中采用了抽象收集的方式来为跟踪信息打上收集标识,也就是咱们以前在日志信息中看到的第4个布尔类型的值,他表明了该信息是否被后续的跟踪信息收集器获取和存储。

public abstract class Sampler { /** * Returns true if the trace ID should be measured. * * @param traceId The trace ID to be decided on, can be ignored */
  public abstract boolean isSampled(long traceId); }

    经过实现isSampled方法, Spring Cloud Sleuth会在产生跟踪信息的时候调用它来为跟踪信息生成是否要被收集的标志。须要注意的是,即便isSampled返回了false,它仅表明该跟踪信息不被输出到后续对接的远程分析系统(好比Zipkin中,对于请求的跟踪活动依然会进行,因此咱们在日志中仍是能看到收集标识为fase的记录。

    默认状况下, Sleuth会使用SamplerProperties实现的抽样策略,以请求百分比的方式配置和收集跟踪信息。咱们能够经过在application.yml中配置下面的参数对其百分比值进行设置,它的默认值为0.1,表明收集10%的请求跟踪信息。

spring: sleuth: sampler: probability: 0.1

    在开发调试期间,一般会收集所有跟踪信息并输出到远程仓库,咱们能够将其值设置为1,或者也能够注入Sampler对象SamplerProperties策略,好比

@Bean public Sampler defaultSampler() { return Sampler.ALWAYS_SAMPLE; }

    因为跟踪日志信息数据的价值每每仅在最近一段时间内很是有用,好比一周。那么咱们在设计抽样策略时,主要考虑在不对系统形成明显性能影响的状况下,以在日志保留时间窗内充分利用存储空间的原则来实现抽样策略。

5、与Zipkin整合

    因为日志文件都离散地存储在各个服务实例的文件系之上,仅经过查看日志信息文件来分咱们的请求链路依然是一件至关麻烦的事情,因此咱们须要一些工具来帮助集中收集、存储和搜索这些跟踪信息,好比ELK日志平台,虽然经过ELK平台提供的收集、存储、搜索等强大功能,咱们对跟踪信息的管理和使用已经变得很是便利。可是在ELK平台中的数据分析维度缺乏对请求链路中各阶段时间延迟的关注,不少时候咱们追溯请求链路的一个缘由是为了找出整个调用链路中出现延迟太高的瓶颈源,或为了实现对分布式系统作延迟监控等与时间消耗相关的需求,这时候相似ELK这样的日志分析系统就显得有些乏力了。对于这样的问题,咱们就能够引入Zipkin来得以轻松解决。

    Zipkin是Twitter的一个开源项目,它基于Google Dapper实现。咱们可使用它来收集各个服务器上请求链路的跟踪数据,并经过它提供的REST API接口来辅助査询跟踪数据以实现对分布式系统的监控程序,从而及时发现系统中出现的延迟升高问题并找出系统 性能瓶颈的根源。除了面向开发的API接口以外,它还提供了方便的UI组件来帮助咱们直观地搜索跟踪信息和分析请求链路明细,好比能够査询某段时间内各用户请求的处理时间等。

    下图展现了Zipkin的基础架构,他主要由4个核心组成:

  • Collector:收集器组件,它主要处理从外部系统发送过来的跟踪信息,将这些信息转换为 Zipkin内部处理的Span格式,以支持后续的存储、分析、展现等功能。

  • Storage:存储组件,它主要处理收集器接收到的跟踪信息,默认会将这些信息存储在内存中。咱们也能够修改此存储策略,经过使用其余存储组件将跟踪信息存储到数据库中。

  • RESTful API:API组件,它主要用来提供外部访问接口。好比给客户端展现跟踪信息,或是外接系统访问以实现监控等。

  • Web UI:UI组件,基于AP组件实现的上层应用。经过UI组件,用户能够方便而又直观地查询和分析跟踪信息。

一、构建server-zipkin

    在Spring Cloud为F版本的时候,已经不须要本身构建Zipkin Server了,只须要下载jar便可,下载地址:https://dl.bintray.com/openzipkin/maven/io/zipkin/zipkin-server/

Zipkin的github地址:https://github.com/openzipkin

二、下载完成jar 包以后,须要运行jar,以下

java -jar zipkin-server-2.10.1-exec.jar
访问浏览器http://localhost:9411,如图咱们能够看到zipkin的管理界面

三、为应用引入和配置Zipkin服务

    咱们须要对应用作一些配置,以实现将跟踪信息输出到Zipkin Server。咱们使用【2、sleuth快速入门】中实现的消费者(springcloud-consumer-sleuth),提供者(springcloud-provider-sleuth)为例,对他们进行改造,都加入整合Zipkin的依赖

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>

四、在消费者(springcloud-consumer-sleuth),提供者(springcloud-provider-sleuth)中增长Zipkin Server的配置信息,具体信息以下所示,默认是链接地址为:http://localhost:9411

spring: zipkin: base-url: http://localhost:9411

五、测试与分析

    到这里咱们已经完成了配置Zipkin Server的全部基本工做,而后访问几回消费者接口http://localhost:9090/consumer/hello,当在日志中出现跟踪信息的最后一个值为true的时候,说明该跟踪信息会输出给Zipkin Server,以下日志

2019-12-05 15:47:25.600 INFO [springcloud-consumer-sleuth,cbdbbebaf32355ab,cbdbbebaf32355ab,false] 8564 --- [nio-9090-exec-9] c.s.controller.SleuthConsumerController : === consumer hello === 2019-12-05 15:47:27.483 INFO [springcloud-consumer-sleuth,8f332a4da3c05f62,8f332a4da3c05f62,false] 8564 --- [nio-9090-exec-6] c.s.controller.SleuthConsumerController : === consumer hello === 2019-12-05 15:47:42.127 INFO [springcloud-consumer-sleuth,61b922906800ac60,61b922906800ac60,true] 8564 --- [nio-9090-exec-2] c.s.controller.SleuthConsumerController : === consumer hello === 2019-12-05 15:47:42.457 INFO [springcloud-consumer-sleuth,1acae9ebecc4d36d,1acae9ebecc4d36d,false] 8564 --- [nio-9090-exec-4] c.s.controller.SleuthConsumerController : === consumer hello === 2019-12-05 15:47:42.920 INFO [springcloud-consumer-sleuth,b2db9e00014ceb88,b2db9e00014ceb88,false] 8564 --- [nio-9090-exec-7] c.s.controller.SleuthConsumerController : === consumer hello === 2019-12-05 15:47:43.457 INFO [springcloud-consumer-sleuth,ade4d5a7d97ca16b,ade4d5a7d97ca16b,false] 8564 --- [nio-9090-exec-9] c.s.controller.SleuthConsumerController : === consumer hello ===

    因此此时能够在Zipkin Server的管理界面中选择合适的查询条件,单击Find Traces按钮,就能够查询出刚才在日志中出现的跟踪信息了(也能够根据日志信息中的Treac ID,在页面右上角的输入框中来搜索),页面以下所示:

    点击下方springcloud-consumer-sleuth端点的跟踪信息,还能够获得Sleuth 跟踪到的详细信息,其中包括咱们关注的请求时间消耗等。

    点击导航栏中的《依赖分析》菜单,还能够查看Zipkin Server根据跟踪信息分析生成的系统请求链路依赖关系图,以下所示

6、Zipkin将数据存储到ElasticSearch中

    在【5、与Zipkin整合】中链路收集的数据默认存储在Zipkin服务的内存中,Zipkin服务一重启这些数据就没了,在开发环境中咱们图方便省方即可以直接将数据存储到内存中,可是在生产环境,咱们须要将这些数据持久化。咱们能够将其存储在MySQL中,实际使用中数据量可能会比较大,因此MySQL并非一种很好的选择,能够选择用Elasticsearch来存储数据,Elasticsearch在搜索方面有先天的优点。

一、上面几个步骤使用的 zipkin-server-2.10.1-exec.jar 是之前下载的,再此使用的zipkin server版本为2.19.2,下载地址:https://dl.bintray.com/openzipkin/maven/io/zipkin/zipkin-server/

二、zipkin-server-2.19.2-exec.jar 版本仅支持Elasticsearch5-7.x版本,注意版本对应,自行上elastic官网下载安装Elasticsearch5-7.x版本,ES服务准备就绪完成以后。

三、启动zipkin服务命令以下:

java -DSTORAGE_TYPE=elasticsearch -DES_HOSTS=http://47.112.11.147:9200 -jar zipkin-server-2.19.2-exec.jar

另外还有一些其它可配置参数,具体参考:https://github.com/openzipkin/zipkin/tree/master/zipkin-server#elasticsearch-storage

* `ES_HOSTS`: A comma separated list of elasticsearch base urls to connect to ex. http://host:9200.
              Defaults to "http://localhost:9200". * `ES_PIPELINE`: Indicates the ingest pipeline used before spans are indexed. No default. * `ES_TIMEOUT`: Controls the connect, read and write socket timeouts (in milliseconds) for Elasticsearch Api. Defaults to 10000 (10 seconds) * `ES_INDEX`: The index prefix to use when generating daily index names. Defaults to zipkin. * `ES_DATE_SEPARATOR`: The date separator to use when generating daily index names. Defaults to '-'. * `ES_INDEX_SHARDS`: The number of shards to split the index into. Each shard and its replicas are assigned to a machine in the cluster. Increasing the number of shards and machines in the cluster will improve read and write performance. Number of shards cannot be changed for existing indices, but new daily indices will pick up changes to the setting. Defaults to 5. * `ES_INDEX_REPLICAS`: The number of replica copies of each shard in the index. Each shard and its replicas are assigned to a machine in the cluster. Increasing the number of replicas and machines in the cluster will improve read performance, but not write performance. Number of replicas can be changed for existing indices. Defaults to 1. It is highly discouraged to set this to 0 as it would mean a machine failure results in data loss. * `ES_USERNAME` and `ES_PASSWORD`: Elasticsearch basic authentication, which defaults to empty string. Use when X-Pack security (formerly Shield) is in place. * `ES_HTTP_LOGGING`: When set, controls the volume of HTTP logging of the Elasticsearch Api. Options are BASIC, HEADERS, BODY

四、咱们修改springcloud-provider-sleuth,springcloud-consumer-sleuth的application.yml文件将抽样几率修改成1,方便测试

spring: sleuth: sampler: probability: 1

五、而后访问http://localhost:9090/consumer/hello接口几回,再次访问kibana能够看到索引已经建立了

六、能够看到里面已经存储数据了

七、访问zipkin能够看到信息

八、可是依赖中没有任何信息

九、zipkin会在ES中建立以zipkin开头日期结尾的索引,而且默认以天为单位分割,使用ES存储模式时,zipkin中的依赖信息会没法显示,经过zipkin官网能够看到,咱们须要经过zipkin-dependencies工具包计算

十、zipkin-dependencies生成依赖链

    zipkin-dependencies基于spark job来生成全局的调用链,此处下载

zipkin-dependencies的版本为2.4.1

github地址:https://github.com/openzipkin/zipkin-dependencies

下载地址:https://dl.bintray.com/openzipkin/maven/io/zipkin/dependencies/zipkin-dependencies/

十一、下载完成以后启动

这个jar包就不要再windows上启动了,启动不了,启动到你怀疑人生。在linux上执行

官方网文档给了个Linux案例:

STORAGE_TYPE=cassandra3 java -jar zipkin-dependencies.jar `date -u -d '1 day ago' +%F`

    STORAGE_TYPE为存储类型,我门这里使用的是ES因此修改成elasticsearch,后面的date参数命令能够用来显示或设定系统的日期与时间,不了解的自行百度。

启动命令为:

ZIPKIN_LOG_LEVEL=DEBUG ES_NODES_WAN_ONLY=true STORAGE_TYPE=elasticsearch  ES_HOSTS=http://47.112.11.147:9200 java -Xms256m -Xmx1024m -jar zipkin-dependencies-2.4.1.jar `date -u -d '1 day ago' +%F`

    下载完成后经过上述命令启动zipkin-dependencies,这里要注意的是程序只会根据当日的zipkin数据实时计算一次依赖关系,咱们是昨天(2019-12-17)收集到ES的数据,因此今天 (2019-12-18)咱们在启动命令中指定前一天,就能生成依赖数据以索引zipkin:dependency-2019-12-17方式存入ES中,而后就退出了(Done),所以要作到实时更新依赖的话须要周期性执行zipkin-dependencies,例如使用Linux中的crontab定时调度等等。

执行后日志以下:

[root@VM_0_8_centos local]# ZIPKIN_LOG_LEVEL=DEBUG ES_NODES_WAN_ONLY=true STORAGE_TYPE=elasticsearch  ES_HOSTS=http://47.112.11.147:9200 java -Xms256m -Xmx1024m -jar zipkin-dependencies-2.4.1.jar `date -u -d '1 day ago' +%F`
19/12/18 21:44:10 WARN Utils: Your hostname, VM_0_8_centos resolves to a loopback address: 127.0.0.1; using 172.21.0.8 instead (on interface eth0) 19/12/18 21:44:10 WARN Utils: Set SPARK_LOCAL_IP if you need to bind to another address 19/12/18 21:44:10 DEBUG ElasticsearchDependenciesJob: Spark conf properties: spark.ui.enabled=false
19/12/18 21:44:10 DEBUG ElasticsearchDependenciesJob: Spark conf properties: es.index.read.missing.as.empty=true
19/12/18 21:44:10 DEBUG ElasticsearchDependenciesJob: Spark conf properties: es.nodes.wan.only=true
19/12/18 21:44:10 DEBUG ElasticsearchDependenciesJob: Spark conf properties: es.net.ssl.keystore.location=
19/12/18 21:44:10 DEBUG ElasticsearchDependenciesJob: Spark conf properties: es.net.ssl.keystore.pass=
19/12/18 21:44:10 DEBUG ElasticsearchDependenciesJob: Spark conf properties: es.net.ssl.truststore.location=
19/12/18 21:44:10 DEBUG ElasticsearchDependenciesJob: Spark conf properties: es.net.ssl.truststore.pass=
19/12/18 21:44:10 INFO ElasticsearchDependenciesJob: Processing spans from zipkin:span-2019-12-17/span 19/12/18 21:44:10 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable 19/12/18 21:44:12 WARN Java7Support: Unable to load JDK7 types (annotations, java.nio.file.Path): no Java7 support added 19/12/18 21:44:13 WARN Resource: Detected type name in resource [zipkin:span-2019-12-17/span]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:13 WARN Resource: Detected type name in resource [zipkin:span-2019-12-17/span]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:13 WARN Resource: Detected type name in resource [zipkin:span-2019-12-17/span]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:16 WARN Resource: Detected type name in resource [zipkin:span-2019-12-17/span]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:16 WARN Resource: Detected type name in resource [zipkin:span-2019-12-17/span]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:16 WARN Resource: Detected type name in resource [zipkin:span-2019-12-17/span]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:16 WARN Resource: Detected type name in resource [zipkin:span-2019-12-17/span]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:17 WARN Resource: Detected type name in resource [zipkin:span-2019-12-17/span]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:17 WARN Resource: Detected type name in resource [zipkin:span-2019-12-17/span]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:17 WARN Resource: Detected type name in resource [zipkin:span-2019-12-17/span]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:17 WARN Resource: Detected type name in resource [zipkin:span-2019-12-17/span]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:17 WARN Resource: Detected type name in resource [zipkin:span-2019-12-17/span]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:17 WARN Resource: Detected type name in resource [zipkin:span-2019-12-17/span]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:18 DEBUG DependencyLinker: building trace tree: traceId=a5253479e359638b 19/12/18 21:44:18 DEBUG DependencyLinker: traversing trace tree, breadth-first 19/12/18 21:44:18 DEBUG DependencyLinker: processing {"traceId":"a5253479e359638b","id":"a5253479e359638b","kind":"SERVER","name":"get /consumer/hello","timestamp":1576591155280041,"duration":6191,"localEndpoint":{"serviceName":"springcloud-consumer-sleuth","ipv4":"192.168.0.104"},"remoteEndpoint":{"ipv6":"::1","port":62085},"tags":{"http.method":"GET","http.path":"/consumer/hello","mvc.controller.class":"SleuthConsumerController","mvc.controller.method":"hello"}} 19/12/18 21:44:18 DEBUG DependencyLinker: root's client is unknown; skipping
19/12/18 21:44:18 DEBUG DependencyLinker: processing {"traceId":"a5253479e359638b","parentId":"a5253479e359638b","id":"8d6b8fb1bbb4f48c","kind":"CLIENT","name":"get","timestamp":1576591155281192,"duration":3999,"localEndpoint":{"serviceName":"springcloud-consumer-sleuth","ipv4":"192.168.0.104"},"tags":{"http.method":"GET","http.path":"/provider/hello"}} 19/12/18 21:44:18 DEBUG DependencyLinker: processing {"traceId":"a5253479e359638b","parentId":"a5253479e359638b","id":"8d6b8fb1bbb4f48c","kind":"SERVER","name":"get /provider/hello","timestamp":1576591155284040,"duration":1432,"localEndpoint":{"serviceName":"springcloud-provider-sleuth","ipv4":"192.168.0.104"},"remoteEndpoint":{"ipv4":"192.168.0.104","port":62182},"tags":{"http.method":"GET","http.path":"/provider/hello","mvc.controller.class":"SleuthProviderController","mvc.controller.method":"hello"},"shared":true} 19/12/18 21:44:18 DEBUG DependencyLinker: found remote ancestor {"traceId":"a5253479e359638b","parentId":"a5253479e359638b","id":"8d6b8fb1bbb4f48c","kind":"CLIENT","name":"get","timestamp":1576591155281192,"duration":3999,"localEndpoint":{"serviceName":"springcloud-consumer-sleuth","ipv4":"192.168.0.104"},"tags":{"http.method":"GET","http.path":"/provider/hello"}} 19/12/18 21:44:18 DEBUG DependencyLinker: incrementing link springcloud-consumer-sleuth -> springcloud-provider-sleuth 19/12/18 21:44:18 DEBUG DependencyLinker: building trace tree: traceId=54af196ac59ee13e 19/12/18 21:44:18 DEBUG DependencyLinker: traversing trace tree, breadth-first 19/12/18 21:44:18 DEBUG DependencyLinker: processing {"traceId":"54af196ac59ee13e","id":"54af196ac59ee13e","kind":"SERVER","name":"get /consumer/hello","timestamp":1576591134958091,"duration":139490,"localEndpoint":{"serviceName":"springcloud-consumer-sleuth","ipv4":"192.168.0.104"},"remoteEndpoint":{"ipv6":"::1","port":62085},"tags":{"http.method":"GET","http.path":"/consumer/hello","mvc.controller.class":"SleuthConsumerController","mvc.controller.method":"hello"}} 19/12/18 21:44:18 DEBUG DependencyLinker: root's client is unknown; skipping
19/12/18 21:44:18 DEBUG DependencyLinker: processing {"traceId":"54af196ac59ee13e","parentId":"54af196ac59ee13e","id":"1a827ae864bd2399","kind":"CLIENT","name":"get","timestamp":1576591134962066,"duration":133718,"localEndpoint":{"serviceName":"springcloud-consumer-sleuth","ipv4":"192.168.0.104"},"tags":{"http.method":"GET","http.path":"/provider/hello"}} 19/12/18 21:44:18 DEBUG DependencyLinker: processing {"traceId":"54af196ac59ee13e","parentId":"54af196ac59ee13e","id":"1a827ae864bd2399","kind":"SERVER","name":"get /provider/hello","timestamp":1576591135064214,"duration":37707,"localEndpoint":{"serviceName":"springcloud-provider-sleuth","ipv4":"192.168.0.104"},"remoteEndpoint":{"ipv4":"192.168.0.104","port":62089},"tags":{"http.method":"GET","http.path":"/provider/hello","mvc.controller.class":"SleuthProviderController","mvc.controller.method":"hello"},"shared":true} 19/12/18 21:44:18 DEBUG DependencyLinker: found remote ancestor {"traceId":"54af196ac59ee13e","parentId":"54af196ac59ee13e","id":"1a827ae864bd2399","kind":"CLIENT","name":"get","timestamp":1576591134962066,"duration":133718,"localEndpoint":{"serviceName":"springcloud-consumer-sleuth","ipv4":"192.168.0.104"},"tags":{"http.method":"GET","http.path":"/provider/hello"}} 19/12/18 21:44:18 DEBUG DependencyLinker: incrementing link springcloud-consumer-sleuth -> springcloud-provider-sleuth 19/12/18 21:44:18 INFO ElasticsearchDependenciesJob: Saving dependency links to zipkin:dependency-2019-12-17/dependency 19/12/18 21:44:18 WARN Resource: Detected type name in resource [zipkin:dependency-2019-12-17/dependency]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:18 WARN Resource: Detected type name in resource [zipkin:dependency-2019-12-17/dependency]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:18 WARN Resource: Detected type name in resource [zipkin:dependency-2019-12-17/dependency]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:18 WARN Resource: Detected type name in resource [zipkin:dependency-2019-12-17/dependency]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:19 WARN Resource: Detected type name in resource [zipkin:dependency-2019-12-17/dependency]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:19 WARN Resource: Detected type name in resource [zipkin:dependency-2019-12-17/dependency]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:19 WARN Resource: Detected type name in resource [zipkin:dependency-2019-12-17/dependency]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:19 WARN Resource: Detected type name in resource [zipkin:dependency-2019-12-17/dependency]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:19 WARN Resource: Detected type name in resource [zipkin:dependency-2019-12-17/dependency]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:19 WARN Resource: Detected type name in resource [zipkin:dependency-2019-12-17/dependency]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:19 WARN Resource: Detected type name in resource [zipkin:dependency-2019-12-17/dependency]. Type names are deprecated and will be removed in a later release. 19/12/18 21:44:19 INFO ElasticsearchDependenciesJob: Processing spans from zipkin-span-2019-12-17
19/12/18 21:44:20 INFO ElasticsearchDependenciesJob: No dependency links could be processed from spans in index zipkin-span-2019-12-17
19/12/18 21:44:20 INFO ElasticsearchDependenciesJob: Done

十二、上面有一个配置:ES_NODES_WAN_ONLY=true

Whether the connector is used against an Elasticsearch instance in a cloud/restricted environment over the WAN, such as Amazon Web Services. In this mode, the connector disables discovery and only connects through the declared es.nodes during all operations, including reads and writes. Note that in this mode, performance is highly affected.

    该配置的含义为经过公网我访问云上或者一些限制性网络上的ES实例时,如AWS,经过声明该配置就会禁用发现其它节点的行为,后续的读和写都只会经过这个指定的节点进行操做,增长了该属性就能够访问云上或者受限制网络中的ES,可是也由于读写都是经过这个节点,于是性能上会受到比较大的影响。zipkin-dependencies的github上也就简单说明,若是这个配置为true,将仅使用在ES_HOSTS主机中设置的值,例如ES集群在Docker中。

1三、查看kibana中生成的索引

1四、而后查看zipkin中的依赖项,咱们能够看到信息了

 

详细参考案例源码:https://gitee.com/coding-farmer/springcloud-learn

 

原文出处:https://www.cnblogs.com/coding-farmer/p/12069275.html

相关文章
相关标签/搜索