Giter Club home page Giter Club logo

trace's Introduction

分布式日志追踪。在微服务之间调用时,通过request header传递 当前request id的方式,将【同一次请求链】串联起来。目前只支持微服务之间用 feign调用的情况,在每次发起feign请求时,都将request id设置 到当前request header中。

使用步骤

  • 引入依赖
  • 实现WebSubjectFactory,根据request/response pair生成Subject,比如
public class AnonymousWebSubjectFactory extends AbstractWebSubjectFactory {
    @Override
    public Subject createSubject(HttpServletRequest request, HttpServletResponse response) {
        String requestId = getOrCreateRequestId(request);
        String downStreamIp = request.getRemoteAddr();
        return new AnonymousWebSubject(requestId, downStreamIp);
    }
}
  • 注册WebSubjectFactory,比如
@Bean
public WebSubjectFactory getWebSubjectFactory() {
    return new AnonymousWebSubjectFactory();
}

核心概念

  • Subject
一个Subject实例,最直观的就是一个"User"。Subject代表了两个服务之间交互时,请求中所携带的用户,requestId等信息。
  • request id
1, 属于同一个动作的多个请求共享同一个request id。
比如,用户在页面点击【查看】功能,而这个功能在后台实际发起了5次请求,则这5次请求的request id一样

2,  使用http header传递reqest id,header name=Trace-Request-Id

trace's People

Stargazers

石兵 avatar lxw avatar

Watchers

James Cloos avatar wuda avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.