Java call key chain tracking technology (a) general overview

First, call the effect chain track

Comprises call chain trace
1. call chain to the rear end of the front end of
the call chain between the interior of a single service 2. The method
calls between the chains 3. Micro service
call link between application services and database 4.
The third party applications and services the middle of the service call chain, such as Redis, MQ

Role call chain tracking are:
1. positioning a plurality of micro service calls fault which is the point of failure.
2. Performance Analysis Analysis 3.SQL 5. The method service calls or call logic and data flow analysis is reasonable analysis, which is especially useful for new, read and execute SQL call chain will know specifically what do

Second, the call chain tracking requirements

Then the call chain involves tracking demand which, Figure:


1. The front-end and back-end between the plurality of micro-messaging service you need to call the past, otherwise it will cut off the call chain
2. Each micro service to be able to get the call stack, call stack and call attention to different order, just get called the order is not enough, try comparison:

Left only reflects the calling sequence, it does not reflect the call stack information, and the right not only embodies the calling sequence also reflects the call stack information.
3. Internal information call micro service to be able to pass, and do not invade 4. interact with the database of micro-services to be able to get to the calling of SQL

Third, the key technologies involved in the Java call chain tracking

  1. Call transfer information, this information can be passed via http header
  1. As long as a front end disposed in the transmission request like. But generally do not usually call the time-consuming tracking front-end, as will be more like a network interactions.
  2. For micro-services need to intercept call request requests to set the chain information to the message header, may be accomplished by writing RestTemplate Fegin interceptors and interceptor in the spring.
  1. Micro Services to obtain the call stack, using the spring of developers will naturally think of using AOP to intercept, but spring AOP intercept calls between multiple methods of the same kind of inconvenient, intrusive, and therefore not suitable. The best way is to use javaagent, to intercept the code by way of injection.
  2. Internal micro-messaging service call needs to pass through the variable range of threads, Java in ThreadLocal have provided this capability.
  3. Java call stack trace also provides this capability, you can get information about the current method call stack.
  4. SQL monitor, using mybatis mybatis will occur with interceptors, in this way some cases will not work (of unknown cause), and relies on mybatis, so the application of the method to intercept more of the underlying SQL, is one way to achieve self- JDBC proxy class, another way is to use a third-party open source SQL monitoring tool.
    end.

Micro-channel public number:


Adding "Java stack combat battalion" knowledge planet, participate in discussions, share the code more real!
t.zsxq.com/RNzfi2j

Guess you like

Origin juejin.im/post/5d4858b3e51d4561eb0b2633