SOFATracer uses a TraceId to link the call logs of a request across different servers. The TraceId is usually generated by the first server that receives the request.
TraceId generation rule
SOFATracer uses a TraceId to link the call logs of a request across different servers. The TraceId is usually generated by the first server that receives the request.
The TraceId is composed of the server IP address, ID generation time, an auto-incrementing sequence, and the current process ID. For example:
0ad1348f1403169275002100356696The first 8 digits, 0ad1348f, represent the IP address of the machine that generated the TraceId. This is a hexadecimal number. Each two-digit pair represents a segment of the IP address. When converted to decimal, these pairs form the IP address, such as 10.209.52.143. This lets you identify the first server that processed the request.
The next 13 digits, 1403169275002, represent the timestamp when the TraceId was generated. The following 4 digits, 1003, represent an auto-incrementing sequence. The sequence starts at 1000 and increases to 9000. After reaching 9000, it resets to 1000. The last 5 digits, 56696, represent the current process ID. The process ID is added to the end of the TraceId to prevent conflicts when multiple processes run on a single machine.
The current TraceId generation rule is based on Alibaba's EagleEye component.
SpanId generation rule
In SOFATracer, the SpanId represents the position of a specific call within the entire call trace tree.
Suppose a web system A receives a user request. The SOFATracer MVC log for this system records a SpanId of `0`, which represents the root vertex of the entire call trace. If system A processes this request by sequentially invoking systems B, C, and D through RPC, the SpanIds in its SOFATracer RPC client log are `0.1`, `0.2`, and `0.3`. The SpanIds in the SOFATracer RPC server logs for systems B, C, and D are also `0.1`, `0.2`, and `0.3`. If system C then calls systems E and F while processing the request, the corresponding SpanIds in its SOFATracer RPC client log are `0.2.1` and `0.2.2`. The SpanIds in the SOFATracer RPC server logs for systems E and F are also `0.2.1` and `0.2.2`.
Collecting all the SpanIds from a single request forms a complete trace tree.
For a distributed call with the TraceId 0a1234 (a simplified example), the SpanId generation process creates the trace tree shown in the following figure:

The current SpanId generation rule is based on Alibaba's EagleEye component.