A distributed transaction link tracing method and system
Patent Information
- Application Number
- CN202210642046.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-07
- Publication Date
- 2026-09-04
- Estimated Expiration
- 2042-06-07
AI Technical Summary
[0003]为此,本发明提供一种分布式事务链路追踪方法及系统,以解决现有技术中存在的分布式事务链路追踪方案局限性较高,从而导致对分布式事务的追踪性能较差的缺陷
[0038] The distributed transaction tracing method provided by this invention loads a kernel virtual machine application into the kernel of the corresponding operating system. The kernel virtual machine application includes a hash table and an incrementing counter. When a system call program in the kernel triggers the execution of the kernel virtual machine application, the current thread number of the kernel virtual machine application and the first socket address associated with the system call program are obtained. Based on the hash table, the incrementing counter, the first socket address, and the thread number, the tracing identifier of the procedure call session corresponding to the system call program is determined. The system call program is either a read system call program or a write system call program. Based on the tracing identifier, distributed transactions within the same process are traced. This method is suitable for scenarios where multi-threading is used to achieve concurrency within an application process. It can achieve full-link tracing of distributed transactions in applications with multi-threaded concurrency mechanisms without interference, effectively improving the stability of distributed transaction tracing.
Smart Images

Figure CN115168067B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer application performance monitoring technology, specifically to a distributed transaction tracing method and system. Additionally, it relates to an electronic device and a processor-readable storage medium. Background Technology
[0002] In the field of application performance monitoring (APM), distributed tracing methods are typically based on modifying Google's Remote Procedure Call (RPC) framework code. This allows a process, upon receiving a remote procedure call (RPC) request, to extract context information and inject it into subsequent RPC requests within the same distributed transaction. This enables all RPCs within a distributed system to share the same context information, thus tracing the distributed transaction. However, this method has significant limitations, primarily its intrusiveness to application code. For example, Google Dapper required modifications to the Google RPC framework codebase and recompilation of all applications to achieve distributed tracing capabilities. This necessitates adapting the tracing method for each programming language, RPC framework, and application-layer communication protocol. This adaptation requires injecting additional content into RPC messages to convey transaction context information, intruding on application code and resulting in poor performance for distributed transaction tracing. Therefore, designing a non-intrusive, high-performance distributed transaction tracing scheme is a pressing challenge. Summary of the Invention
[0003] To address this, the present invention provides a distributed transaction tracing method and system to overcome the shortcomings of existing distributed transaction tracing schemes, which have high limitations and result in poor performance in tracing distributed transactions.
[0004] In a first aspect, the present invention provides a distributed transaction tracing method, comprising:
[0005] The kernel virtual machine application is loaded into the kernel of the corresponding operating system; wherein, the kernel virtual machine application includes a hash table and an incrementing counter;
[0006] When the system call program in the kernel triggers the execution of the kernel virtual machine application, the thread number currently corresponding to the kernel virtual machine application and the first socket address currently associated with the system call program are obtained.
[0007] Based on the hash table, the incrementing counter, the first Socket address, and the thread number, the tracking identifier of the procedure call session corresponding to the system call program is determined; wherein, the system call program is a read system call program or a write system call program;
[0008] Based on the tracking identifier, distributed transactions within the same process are traced.
[0009] Furthermore, determining the tracing identifier of the procedure call session corresponding to the system call program based on the hash table, the incrementing counter, the first Socket address, and the thread number specifically includes:
[0010] If the kernel virtual machine application is triggered by the read system call procedure, then the hash table is queried to see if a target thread number corresponding to the thread number exists; if so, the current value of the increment counter is determined as the tracking identifier of the procedure call session corresponding to the system call procedure; if the second socket address currently associated with the system call procedure is equal to the first socket address, then the target thread number is deleted from the hash table; if no target thread number corresponding to the thread number exists in the hash table, then the current value of the increment counter is incremented by 1 to obtain a new value of the increment counter, and the new value is determined as the tracking identifier of the procedure call session corresponding to the system call procedure; the thread number and the corresponding first socket address are added to the hash table.
[0011] Furthermore, determining the tracing identifier of the procedure call session corresponding to the system call program based on the hash table, the incrementing counter, the first Socket address, and the thread number specifically includes:
[0012] If the kernel virtual machine application is triggered by the write system call program, then the hash table is queried to see if a target thread number corresponding to the thread number exists; if so, the current value of the increment counter is determined as the tracking identifier of the procedure call session corresponding to the system call program; if the second socket address currently associated with the system call program is equal to the first socket address, then the target thread number is deleted from the hash table; if no target thread number corresponding to the thread number exists in the hash table, then the current value of the increment counter is incremented by 1 to obtain a new value of the increment counter, and the new value is determined as the tracking identifier of the procedure call session corresponding to the system call program; the thread number and the corresponding first socket address are added to the hash table.
[0013] Furthermore, the distributed transaction refers to at least two transactions executed by any one of the threads at different times when multiple threads run concurrently within the same process; wherein, all procedure call sessions with the same trace identifier generated within the same process belong to the same transaction.
[0014] Furthermore, the distributed transaction tracing method further includes:
[0015] Based on the Transmission Control Protocol sequence number recorded in the first Socket address, determine the characteristic signatures corresponding to the procedure call request and the procedure call response respectively; wherein, the procedure call session includes the procedure call request and the procedure call response;
[0016] Based on the aforementioned signature, distributed transactions within different processes are traced.
[0017] Furthermore, the step of performing link tracing on distributed transactions within different processes based on the feature signature specifically includes:
[0018] In a procedure call session between different processes, the feature signatures corresponding to the procedure call request and the procedure call response are matched and compared. Based on the matching and comparison results, the procedure call session corresponding to different processes is determined, so as to realize cross-process tracing.
[0019] Furthermore, the kernel virtual machine application is pre-compiled eBPF bytecode.
[0020] Secondly, the present invention also provides a distributed transaction tracing system, comprising:
[0021] A program loading unit is used to load a kernel virtual machine application into the kernel of the corresponding operating system; wherein, the kernel virtual machine application includes a hash table and an incrementing counter;
[0022] The data acquisition unit is used to acquire the thread number currently corresponding to the kernel virtual machine application and the first Socket address currently associated with the system call program when the system call program in the kernel triggers the execution of the kernel virtual machine application.
[0023] The tracking identifier determination unit is used to determine the tracking identifier of the procedure call session corresponding to the system call program based on the hash table, the auto-incrementing counter, the first Socket address, and the thread number; wherein the system call program is a read system call program or a write system call program;
[0024] The link tracing unit is used to perform link tracing on distributed transactions within the same process based on the tracing identifier.
[0025] Furthermore, the tracking identifier determination unit is specifically used for:
[0026] If the kernel virtual machine application is triggered by the read system call procedure, then the hash table is queried to see if a target thread number corresponding to the thread number exists; if so, the current value of the increment counter is determined as the tracking identifier of the procedure call session corresponding to the system call procedure; if the second socket address currently associated with the system call procedure is equal to the first socket address, then the target thread number is deleted from the hash table; if no target thread number corresponding to the thread number exists in the hash table, then the current value of the increment counter is incremented by 1 to obtain a new value of the increment counter, and the new value is determined as the tracking identifier of the procedure call session corresponding to the system call procedure; the thread number and the corresponding first socket address are added to the hash table.
[0027] Furthermore, the tracking identifier determination unit is specifically used for:
[0028] If the kernel virtual machine application is triggered by the write system call program, then the hash table is queried to see if a target thread number corresponding to the thread number exists; if so, the current value of the increment counter is determined as the tracking identifier of the procedure call session corresponding to the system call program; if the second socket address currently associated with the system call program is equal to the first socket address, then the target thread number is deleted from the hash table; if no target thread number corresponding to the thread number exists in the hash table, then the current value of the increment counter is incremented by 1 to obtain a new value of the increment counter, and the new value is determined as the tracking identifier of the procedure call session corresponding to the system call program; the thread number and the corresponding first socket address are added to the hash table.
[0029] Furthermore, the distributed transaction refers to at least two transactions executed by any one of the threads at different times when multiple threads run concurrently within the same process; wherein, all procedure call sessions with the same trace identifier generated within the same process belong to the same transaction.
[0030] Furthermore, the distributed transaction tracing system also includes:
[0031] The signature determination unit is used to determine the signatures corresponding to the procedure call request and the procedure call response respectively based on the transmission control protocol sequence number recorded in the first socket address; wherein, the procedure call session includes the procedure call request and the procedure call response;
[0032] The link tracing unit is also used to perform link tracing on distributed transactions within different processes based on the feature signature.
[0033] Furthermore, the link tracing unit is specifically used for:
[0034] In a procedure call session between different processes, the feature signatures corresponding to the procedure call request and the procedure call response are matched and compared. Based on the matching and comparison results, the procedure call session corresponding to different processes is determined, so as to realize cross-process tracing.
[0035] Furthermore, the kernel virtual machine application is pre-compiled eBPF bytecode.
[0036] Thirdly, the present invention also provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the distributed transaction tracing method as described in any of the preceding claims.
[0037] Fourthly, the present invention also provides a processor-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the distributed transaction tracing method as described in any of the preceding claims.
[0038] The distributed transaction tracing method provided by this invention loads a kernel virtual machine application into the kernel of the corresponding operating system. The kernel virtual machine application includes a hash table and an incrementing counter. When a system call program in the kernel triggers the execution of the kernel virtual machine application, the current thread number of the kernel virtual machine application and the first socket address associated with the system call program are obtained. Based on the hash table, the incrementing counter, the first socket address, and the thread number, the tracing identifier of the procedure call session corresponding to the system call program is determined. The system call program is either a read system call program or a write system call program. Based on the tracing identifier, distributed transactions within the same process are traced. This method is suitable for scenarios where multi-threading is used to achieve concurrency within an application process. It can achieve full-link tracing of distributed transactions in applications with multi-threaded concurrency mechanisms without interference, effectively improving the stability of distributed transaction tracing. Attached Figure Description
[0039] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0040] Figure 1 This is a flowchart illustrating the distributed transaction tracing method provided in an embodiment of the present invention;
[0041] Figure 2 This is a schematic diagram of distributed transaction tracing within the same process provided in an embodiment of the present invention;
[0042] Figure 3 This is a schematic diagram illustrating distributed transaction tracing between different processes provided in an embodiment of the present invention;
[0043] Figure 4 This is a schematic diagram of the structure of the distributed transaction tracing system provided in an embodiment of the present invention;
[0044] Figure 5 This is a schematic diagram of the physical structure of the electronic device provided in an embodiment of the present invention. Detailed Implementation
[0045] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0046] This invention implements a zero-intrusion distributed transaction tracing method based on the Linux Kernel's eBPF (Extended Berkeley Packet Filter) mechanism. This method is suitable for scenarios where multi-threading is used to achieve concurrency within an application process.
[0047] The following is a detailed description of embodiments of the distributed transaction tracing method described in this invention. Figure 1 The diagram shown is a flowchart of the distributed transaction tracing method provided in this embodiment of the invention. The specific implementation process includes the following steps:
[0048] Step 101: Load the kernel virtual machine application into the kernel of the corresponding operating system; wherein the kernel virtual machine application includes a hash table and an incrementing counter.
[0049] Specifically, the kernel virtual machine application is pre-compiled eBPF (extended Berkeley Packet Filter) bytecode, a technology that allows user-written programs to run within the operating system kernel without modifying kernel code or loading kernel modules. The operating system can be Linux, Windows, etc. The hash table and incrementing counter are pre-compiled into the kernel virtual machine application. The hash table records and queries the thread number of the response, and the incrementing counter determines the tracking identifier of the procedure call session. In this embodiment, the monitoring agent sends eBPF bytecode to the Linux system kernel for injection into the Linux system kernel's read system call function and write system call function. The agent is a pre-defined computing entity that can continuously and autonomously function in a distributed or collaborative system, often simply referred to as an "intelligent agent."
[0050] Step 102: When the system call program in the kernel triggers the execution of the kernel virtual machine application, obtain the thread number currently corresponding to the kernel virtual machine application and the first socket address currently associated with the system call program.
[0051] In this embodiment of the invention, the system call program is a read system call program or a write system call program of the Linux system kernel. Before executing this step, the kernel virtual machine application needs to be started in advance, and the hash table and the incrementing counter need to be initialized. After initialization, the kernel virtual machine application is triggered to execute through the system call program in the kernel of the operating system, so as to obtain the thread number currently corresponding to the kernel virtual machine application and the first socket address currently associated with the system call program.
[0052] Specifically, such as Figure 2 As shown, process 1 achieves concurrency by running multiple threads (responding to multiple RPC requests at the same time), but any single thread can only respond to one RPC request at a time until that RPC request is terminated. Figure 1Transaction 1 consists of RPC calls 1-6, and Transaction 2 consists of RPC calls 7-12. Specifically, 1 represents the first RPC request, 2 the second RPC request, 3 the second RPC response, 4 the third RPC request, 5 the third RPC response, and 6 the first RPC response in Transaction 1. The first RPC response and the first RPC request form one RPC session, the second RPC request and the second RPC response form another, and the third RPC request and the third RPC response form yet another. Similarly, 7 represents the first RPC request, 8 the second RPC request, 9 the second RPC response, 10 the third RPC request, 11 the third RPC response, and 12 the first RPC response in Transaction 1. Again, the first RPC response and the first RPC request form one RPC session, the second RPC request and the second RPC response form another, and the third RPC request and the third RPC response form yet another. Transaction 1 and Transaction 2 are different distributed transactions executed by thread 1 at different times. To enable transaction tracking, in step 101, this method uses a monitoring agent to send eBPF bytecode (i.e., B) to the Linux kernel. After injecting it into the kernel's read or write system call function, the execution flow is as follows: Start B and initialize the hash table (i.e., H) and the increment counter (i.e., C); when the read or write system call function in the kernel triggers the execution of B, obtain the current kernel thread number (i.e., S) and the address of the socket associated with the system call (i.e., A).
[0053] Step 103: Based on the hash table, the incrementing counter, the first Socket address, and the thread number, determine the tracking identifier of the procedure call session corresponding to the system call program. The system call program is either a read system call program or a write system call program.
[0054] In this embodiment of the invention, if the kernel virtual machine application (i.e., B) is triggered by the read system call program, the hash table is queried to see if a target thread number corresponding to the thread number exists; if so, the current value of the increment counter is determined as the tracking identifier (i.e., tracking ID) of the procedure call session (i.e., RPC session) corresponding to the system call program; if the second socket address currently associated with the system call program is equal to the first socket address, the target thread number is deleted from the hash table; if no target thread number corresponding to the thread number exists in the hash table, the current value of the increment counter is incremented by 1 to obtain a new value of the increment counter, and the new value is determined as the tracking identifier of the procedure call session corresponding to the system call program; the thread number and the corresponding first socket address are added to the hash table.
[0055] Specifically, the system caller corresponds to the RPC session's tracking ID (T). If B is triggered by the read system caller, the thread number S is queried in the hash table H; if S is not in H, the increment counter C is incremented by 1 (i.e., the current value of the increment counter is increased by 1) to obtain the new value, and T is assigned the new C (the new value); S and the corresponding Socket address A are inserted into the hash table H, i.e., H[S] = A, for example, ... Figure 1 In transaction 1, the socket address A corresponding to the first RPC request is inserted into the hash table H, and the second RPC request, second RPC response, second RPC request, and second RPC response are executed sequentially. If S is in H, T is assigned the value C. If the current socket address A is equal to H[S] (that is, the first RPC response in transaction 1 is executed, and the socket address corresponding to the first RPC response is equal to the socket address A corresponding to the first RPC request), then S is deleted from H, indicating that the execution process of transaction 1 is completed.
[0056] Accordingly, if the kernel virtual machine application is triggered by the write system call program, the hash table is queried to see if a target thread number corresponding to the thread number exists; if so, the current value of the increment counter is determined as the tracking identifier (i.e., tracking ID) of the procedure call session (i.e., RPC session) corresponding to the system call program; if the second socket address currently associated with the system call program is equal to the first socket address, the target thread number is deleted from the hash table; if no target thread number corresponding to the thread number exists in the hash table, the current value of the increment counter is incremented by 1 to obtain a new value of the increment counter, and the new value is determined as the tracking identifier of the procedure call session corresponding to the system call program; the thread number and the corresponding first socket address are added to the hash table. Similarly, the tracking ID (i.e., T) of the RPC session corresponding to the system call program is also added. If B is triggered by the write system call, the thread number S is queried in the hash table H; if S is not in H, the increment counter C is incremented by 1 (i.e., the current value of the increment counter is increased by 1) to obtain the new value, and T is assigned the new C (the new value); S and the corresponding Socket address A are inserted into the hash table H, i.e., H[S] = A, for example, ... Figure 1In transaction 1, the socket address A corresponding to the first RPC request is inserted into the hash table H, and the second RPC request, second RPC response, second RPC request, and second RPC response are executed sequentially. If S is in H, T is assigned the value C. If the current socket address A is equal to H[S] (that is, the first RPC response in transaction 1 is executed, and the socket address corresponding to the first RPC response is equal to the socket address A corresponding to the first RPC request), then S is deleted from H, indicating that the execution process of transaction 1 is completed.
[0057] Step 104: Perform link tracing on distributed transactions within the same process based on the tracing identifier.
[0058] The distributed transaction refers to at least two transactions executed by any one thread at different times when multiple threads run concurrently within the same process; wherein all procedure call sessions with the same trace identifier generated within the same process belong to the same transaction. This utilizes the application's multi-threaded concurrency model (i.e., Figure 2 As shown, the tracking ID of an RPC is calculated so that tracking IDs belonging to the same distributed transaction are the same, and tracking IDs belonging to different distributed transactions are different, thus achieving tracing within a process. That is, all RPC calls generated by the same process that share the same tracking ID T belong to the same transaction (e.g., transaction 1 or transaction 2).
[0059] Furthermore, in this embodiment of the invention, the feature signatures corresponding to the procedure call request and procedure call response can be determined based on the Transmission Control Protocol Sequence Number (i.e., TCP Sequence Number) recorded in the first Socket address; wherein the procedure call session includes the procedure call request and the procedure call response; and distributed transaction tracing within different processes is performed based on the feature signatures. Specifically, the process of performing distributed transaction tracing within different processes based on the feature signatures includes: in procedure call sessions between different processes, matching and comparing the feature signatures corresponding to the procedure call request and the procedure call response, and determining the corresponding procedure call sessions for different processes based on the matching and comparison results, thereby achieving cross-process tracing.
[0060] In practical implementation, a signature X can be recorded for each request and response of all RPC sessions. The value of signature X can be determined based on the TCP Sequence number recorded in the Socket. After marking the tracking ID (i.e., T) of all RPC sessions of all processes, distributed transaction tracing can be implemented based on the analysis of T: RPC calls between different processes are matched by comparing the signature X of the RPC request and RPC response. When the signature X of a certain RPC request and response of process A is equal to the signature X of a certain RPC request (i.e., N) of process B, it is considered that M and N are actually two collections of the same RPC request on the client and server processes (specifically, as shown in the image). Figure 3 (As shown). By using TCP Sequence numbers to match RPC sessions collected across different processes, cross-process tracing is achieved. Ultimately, full-link tracing of the entire distributed transaction is realized.
[0061] The method described in this invention achieves zero-intrusion tracing for applications using thread-based concurrency. By calculating the tracing ID through eBPF, it is independent of the application's development framework and application-layer communication protocol. It requires no modification to the code of the tracing application, no recompilation of the application, no insertion of additional context information into the application-layer communication protocol, and makes no changes to the application communication content. It enables zero-intrusion full-link tracing of distributed transactions in any application using multi-threaded concurrency mechanisms. In one example of this invention, it supports tracing distributed transactions in Java and Python applications written using any of the various RPC frameworks (using different application-layer communication protocols, including RFC-standard HTTP protocols and application-defined private application communication protocols).
[0062] The distributed transaction tracing method described in this invention loads a kernel virtual machine application into the kernel of the corresponding operating system. The kernel virtual machine application includes a hash table and an incrementing counter. When a system call program in the kernel triggers the execution of the kernel virtual machine application, the current thread number of the kernel virtual machine application and the first socket address associated with the system call program are obtained. Based on the hash table, the incrementing counter, the first socket address, and the thread number, the tracing identifier of the procedure call session corresponding to the system call program is determined. The system call program is either a read system call program or a write system call program. Based on the tracing identifier, distributed transactions within the same process are traced. This method is suitable for scenarios where multi-threading is used to achieve concurrency within an application process. It can achieve full-link tracing of distributed transactions in applications with multi-threaded concurrency mechanisms without interference, effectively improving the stability of distributed transaction tracing.
[0063] Corresponding to the distributed transaction tracing method provided above, this invention also provides a distributed transaction tracing system. Since the embodiments of this system are similar to the method embodiments described above, the description is relatively simple. For relevant details, please refer to the description in the method embodiment section above. The embodiments of the distributed transaction tracing system described below are merely illustrative. Please refer to... Figure 4 As shown, it is a schematic diagram of the structure of a distributed transaction tracing system provided in an embodiment of the present invention.
[0064] The distributed transaction tracing system of the present invention specifically includes the following parts:
[0065] The program loading unit 401 is used to load a kernel virtual machine application into the kernel of the corresponding operating system; wherein, the kernel virtual machine application includes a hash table and an incrementing counter;
[0066] The data acquisition unit 402 is used to acquire the thread number currently corresponding to the kernel virtual machine application and the first socket address currently associated with the system call program when the system call program in the kernel triggers the execution of the kernel virtual machine application.
[0067] The tracking identifier determination unit 403 is used to determine the tracking identifier of the procedure call session corresponding to the system call program based on the hash table, the auto-incrementing counter, the first Socket address, and the thread number; wherein the system call program is a read system call program or a write system call program;
[0068] Link tracing unit 404 is used to perform link tracing on distributed transactions within the same process based on the tracing identifier.
[0069] Furthermore, the tracking identifier determination unit is specifically used for:
[0070] If the kernel virtual machine application is triggered by the read system call procedure, then the hash table is queried to see if a target thread number corresponding to the thread number exists; if so, the current value of the increment counter is determined as the tracking identifier of the procedure call session corresponding to the system call procedure; if the second socket address currently associated with the system call procedure is equal to the first socket address, then the target thread number is deleted from the hash table; if no target thread number corresponding to the thread number exists in the hash table, then the current value of the increment counter is incremented by 1 to obtain a new value of the increment counter, and the new value is determined as the tracking identifier of the procedure call session corresponding to the system call procedure; the thread number and the corresponding first socket address are added to the hash table.
[0071] Furthermore, the tracking identifier determination unit is specifically used for:
[0072] If the kernel virtual machine application is triggered by the write system call program, then the hash table is queried to see if a target thread number corresponding to the thread number exists; if so, the current value of the increment counter is determined as the tracking identifier of the procedure call session corresponding to the system call program; if the second socket address currently associated with the system call program is equal to the first socket address, then the target thread number is deleted from the hash table; if no target thread number corresponding to the thread number exists in the hash table, then the current value of the increment counter is incremented by 1 to obtain a new value of the increment counter, and the new value is determined as the tracking identifier of the procedure call session corresponding to the system call program; the thread number and the corresponding first socket address are added to the hash table.
[0073] Furthermore, the distributed transaction refers to at least two transactions executed by any one of the threads at different times when multiple threads run concurrently within the same process; wherein, all procedure call sessions with the same trace identifier generated within the same process belong to the same transaction.
[0074] Furthermore, the distributed transaction tracing system also includes:
[0075] The signature determination unit is used to determine the signatures corresponding to the procedure call request and the procedure call response respectively based on the transmission control protocol sequence number recorded in the first socket address; wherein, the procedure call session includes the procedure call request and the procedure call response;
[0076] The link tracing unit is also used to perform link tracing on distributed transactions within different processes based on the feature signature.
[0077] Furthermore, the link tracing unit is specifically used for:
[0078] In a procedure call session between different processes, the feature signatures corresponding to the procedure call request and the procedure call response are matched and compared. Based on the matching and comparison results, the procedure call session corresponding to different processes is determined, so as to realize cross-process tracing.
[0079] Furthermore, the kernel virtual machine application is pre-compiled eBPF bytecode.
[0080] The distributed transaction tracing system described in this invention loads a kernel virtual machine application into the kernel of the corresponding operating system. The kernel virtual machine application includes a hash table and an incrementing counter. When a system call program in the kernel triggers the execution of the kernel virtual machine application, it obtains the thread number currently corresponding to the kernel virtual machine application and the first socket address currently associated with the system call program. Based on the hash table, the incrementing counter, the first socket address, and the thread number, it determines the tracing identifier of the procedure call session corresponding to the system call program. The system call program is either a read system call program or a write system call program. Based on the tracing identifier, it performs tracing of distributed transactions within the same process. This system is suitable for scenarios where multi-threading is used to achieve concurrency within an application process. It can achieve full-link tracing of distributed transactions in applications with multi-threaded concurrency mechanisms without interference, effectively improving the stability of distributed transaction tracing.
[0081] Corresponding to the distributed transaction tracing method provided above, this invention also provides an electronic device. Since the embodiment of this electronic device is similar to the method embodiment described above, it is described simply. For relevant details, please refer to the description in the method embodiment section above. The electronic device described below is merely illustrative. Figure 5 The diagram illustrates the physical structure of an electronic device according to an embodiment of the present invention. The electronic device may include a processor 501, a memory 502, a communication bus 503 (i.e., the aforementioned system bus), and a lookup engine 505. The processor 501 and memory 502 communicate with each other via the communication bus 503 and communicate with external systems via a communication interface 504. The processor 501 can call logical instructions in the memory 502 to execute a distributed transaction tracing method. This method includes: loading a kernel virtual machine application into the kernel of the corresponding operating system; wherein the kernel virtual machine application includes a hash table and an incrementing counter; when a system call program in the kernel triggers the execution of the kernel virtual machine application, obtaining the current thread number of the kernel virtual machine application and the first socket address currently associated with the system call program; determining the tracing identifier of the procedure call session corresponding to the system call program based on the hash table, the incrementing counter, the first socket address, and the thread number; wherein the system call program is a read system call program or a write system call program; and performing tracing of distributed transactions within the same process based on the tracing identifier.
[0082] Furthermore, the logical instructions in the aforementioned memory 502 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as memory chips, USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0083] On the other hand, embodiments of the present invention also provide a computer program product, the computer program product including a computer program stored on a processor-readable storage medium, the computer program including program instructions, and when the program instructions are executed by a computer, the computer is able to execute the distributed transaction tracing method provided in the above-described method embodiments. The method includes: loading a kernel virtual machine application into the kernel of a corresponding operating system; wherein the kernel virtual machine application includes a hash table and an incrementing counter; when a system call program in the kernel triggers the execution of the kernel virtual machine application, obtaining the thread number currently corresponding to the kernel virtual machine application and the first socket address currently associated with the system call program; determining the tracing identifier of the procedure call session corresponding to the system call program based on the hash table, the incrementing counter, the first socket address, and the thread number; wherein the system call program is a read system call program or a write system call program; and performing tracing of distributed transactions within the same process based on the tracing identifier.
[0084] In another aspect, embodiments of the present invention also provide a processor-readable storage medium storing a computer program, which, when executed by a processor, implements the distributed transaction tracing method provided in the above embodiments. The method includes: loading a kernel virtual machine application into the kernel of a corresponding operating system; wherein the kernel virtual machine application includes a hash table and an incrementing counter; when a system call program in the kernel triggers the execution of the kernel virtual machine application, obtaining the thread number currently corresponding to the kernel virtual machine application and the first socket address currently associated with the system call program; determining a tracing identifier for the procedure call session corresponding to the system call program based on the hash table, the incrementing counter, the first socket address, and the thread number; wherein the system call program is a read system call program or a write system call program; and performing tracing of distributed transactions within the same process based on the tracing identifier.
[0085] The processor-readable storage medium can be any available medium or data storage device that the processor can access, including but not limited to magnetic memory (e.g., floppy disk, hard disk, magnetic tape, magneto-optical disk (MO)), optical memory (e.g., CD, DVD, BD, HVD), and semiconductor memory (e.g., ROM, EPROM, EEPROM, non-volatile memory (NAND FLASH), solid-state drive (SSD)).
[0086] The system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0087] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0088] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A distributed transaction tracing method, characterized in that, include: The kernel virtual machine application is loaded into the kernel of the corresponding operating system; wherein, the kernel virtual machine application includes a hash table and an incrementing counter; When the system call program in the kernel triggers the execution of the kernel virtual machine application, the thread number currently corresponding to the kernel virtual machine application and the first socket address currently associated with the system call program are obtained. Based on the hash table, the incrementing counter, the first Socket address, and the thread number, the tracking identifier of the procedure call session corresponding to the system call program is determined; wherein, the system call program is a read system call program or a write system call program; Based on the tracking identifier, perform link tracing of distributed transactions within the same process; The step of determining the tracking identifier of the procedure call session corresponding to the system call program based on the hash table, the incrementing counter, the first Socket address, and the thread number specifically includes: If the kernel virtual machine application is triggered by the read system call program or the write system call program, then the hash table is searched to see if a target thread number corresponding to the thread number exists. If so, the current value of the increment counter is determined as the tracking identifier of the procedure call session corresponding to the system call program. If the second socket address currently associated with the system call program is equal to the first socket address, then the target thread number is deleted from the hash table. If no target thread number corresponding to the thread number exists in the hash table, then the current value of the increment counter is incremented by 1 to obtain a new value for the increment counter, and the new value is determined as the tracking identifier of the procedure call session corresponding to the system call program. The thread number and the corresponding first socket address are added to the hash table.
2. The distributed transaction tracing method according to claim 1, characterized in that, The distributed transaction refers to at least two transactions executed by any one of the threads at different times when multiple threads run concurrently within the same process; wherein, all procedure call sessions with the same trace identifier generated within the same process belong to the same transaction.
3. The distributed transaction tracing method according to claim 1, characterized in that, Also includes: Based on the Transmission Control Protocol sequence number recorded in the first Socket address, determine the characteristic signatures corresponding to the procedure call request and the procedure call response respectively; wherein, the procedure call session includes the procedure call request and the procedure call response; Based on the aforementioned signature, distributed transactions within different processes are traced.
4. The distributed transaction tracing method according to claim 3, characterized in that, The link tracing of distributed transactions within different processes based on the feature signature specifically includes: In a procedure call session between different processes, the feature signatures corresponding to the procedure call request and the procedure call response are matched and compared. Based on the matching and comparison results, the procedure call session corresponding to different processes is determined, so as to realize cross-process tracing.
5. The distributed transaction tracing method according to claim 1, characterized in that, The kernel virtual machine application is pre-compiled eBPF bytecode.
6. A distributed transaction tracing system based on the distributed transaction tracing method according to any one of claims 1-5, characterized in that, include: A program loading unit is used to load a kernel virtual machine application into the kernel of the corresponding operating system; wherein, the kernel virtual machine application includes a hash table and an incrementing counter; The data acquisition unit is used to acquire the thread number currently corresponding to the kernel virtual machine application and the first Socket address currently associated with the system call program when the system call program in the kernel triggers the execution of the kernel virtual machine application. The tracking identifier determination unit is used to determine the tracking identifier of the procedure call session corresponding to the system call program based on the hash table, the auto-incrementing counter, the first Socket address, and the thread number; wherein the system call program is a read system call program or a write system call program; The link tracing unit is used to perform link tracing on distributed transactions within the same process based on the tracing identifier.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the distributed transaction tracing method as described in any one of claims 1 to 5.
8. A processor-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the distributed transaction tracing method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Distributed link tracking method under micro-service architecture
CN110730246A
System and method for tracking changes in system memory
US11126563B1