Invocation Chain Data Generation
The invocation chain is a specific application case of the domain model of distributed tracing. The invocation chain records each request and analyzes the invocation process.
Invocation Chain Model
Metadata:
- SpanEndpointType: invocation type (Root(“E”), Service(“S”), Client(“C”), Method(“M”));
- traceId: unique identifier of an invocation chain;
- spanId: invocation sequence of the current node in an invocation chain (unique when combined with SpanEndpointType)
- parentId: parent invocation node of the current node in an invocation chain.
Mapping rules: 1) Register the initial invocation (without parent invocation) of the caller (service or web) as the starting node E and generate the unique traceID;
2) Add “1” (“.1” to the first spanID) to the spanID for invocation among application components (such as httpclient and method invocation) within the system;
3) Span information of Service A and Service B differs in SpanEndpointType (each representing one end of the span) only for the invocation among systems.
Example:
- traceId;1;N;E
- traceId;1.1;1;C
- traceId;1.1;1;S
- traceId;1.1.1;1.1;C
- traceId;1.1.2;1.1;C
Implementation of the Invocation Chain Model
- The invocation chain employs UAV's GlobalFilter mechanism to implement JEEServiceRunGlobalFilterHandler and to intercept all requests to access Tomcat.
- Abstract three scenes: 1, server; 2, client; and 3, method. Create corresponding handlers.
- Add adapters (XXAdapter) to the client hook so as to adapt all data sources (such as HttpClient, MQ and JDBC).
- Output the invocation chain information to the log file with the mechanism aforesaid and collect logs with MA's collection mechanism.
Invocation Chain Architecture
1) Enable or disable the invocation chain dynamically with UAV's inline applets; 2) MOF collects the invocation chain information and outputs the information to log files; 3) MA's collection mechanism uploads logs to the specifized topic in UAV's RocketMQ; 4) HM's invocation chain handlers analyze and process the invocation chain data in RocketMQ and store the data in Elasticsearch; 5) HM provides external query interfaces for the front-end display of the console.