sleuth和zipkin调试流程图(rpc响应-上报sr,ss和本地处理)
2020-03-06 17:52:30   0  举报             
     
         
 springcloud的sleuth分布式链路方案客户端非入口后台上报跟踪信息源码流程图
    作者其他创作
 大纲/内容
   if (spanFromRequest != null) { 
  给第四个span的父span(第三个span)添加ss事件,并上报第三个span
  路径判断是否跳过,采样器是否配置
  this.tracer.continueSpan(spanFromRequest);
  请求和响应信息存list内存中
  一系列处理
  spanFromRequest != null
  Y:给父span添加ss事件并上报父span
  org.springframework.boot.actuate.trace.WebRequestTraceFilter#enhanceTrace
  加入一些标签anotation如请求方式,url等等
  Span spanFromRequest = (Span) request.getAttribute(TRACE_REQUEST_ATTR);
  请求进入服务器,经过一系列过滤器进入TraceFilter
  Y:减的动作
  spanFromRequest.logEvent(Span.SERVER_SEND);
  spanFromRequest.hasSavedSpan()
  Servlet {@link Filter} that logs all requests to a {@link TraceRepository}.
  N:给当前span添加ss事件(此span没有父span)
  String uri = this.urlPathHelper.getPathWithinApplication(request);
  this.tracer.close(spanFromRequest);
  addRequestTags(request);
  N:再次将采样器加到response中’
  Add headers before filter chain in case one of the filters flushes the response
  Y
  关闭当前span并上报
  过滤器
  isAsyncStarted(request) || request.isAsyncStarted()
  创建第四个span
  组合请求路径
  org.springframework.boot.actuate.trace.WebRequestTraceFilter#doFilterInternal
  Y:不创建span,维持
  org.springframework.cloud.sleuth.instrument.web.TraceFilter#doFilterInternal
  经过内部反射调用等一系列处理进入WebRequestTraceFilter过滤器
  关闭第四个span并上报
  String name = HTTP_COMPONENT + \":\" + uri;
  根据org.springframework.cloud.sleuth.instrument.web.TraceFilter.TRACE从request获取span对象
  N:将采样器kv形式加入response
  上步获取的span如判断是否为空如此span在此jvm进程中创建,则获取的spanFromRequest 不为空
  Span parent =  spanFromRequest.getSavedSpan();\t\t\t\t\tif (parent.isRemote()) {\t\t\t\t\t\tparent.logEvent(Span.SERVER_SEND);\t\t\t\t\t\tparent.stop();\t\t\t\t\t\tthis.spanReporter.report(parent);\t\t\t\t\t}
  this.repository.add(trace);
  以上步的请求路径作为参数创建新的span
  this.tracer.detach(spanFromRequest);
  给第四个span添加ss事件
  获取请求接口的方法路径
   
 
 
 
 
  0 条评论
 下一页
  
   
   
   
   
  
  
  
  
  
  
  
  
 