Link tracking implementation method and device of application program, electronic equipment and medium

By automatically loading the core modules and agents in the tracing dependency package when the application starts, the problem of complex deployment of existing non-intrusive tracing solutions is solved, achieving non-intrusive tracing functionality, reducing configuration threshold and operation and maintenance costs, and improving user experience.

CN121098710APending Publication Date: 2025-12-09GUANGZHOU HUYA TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511210614.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-27
Publication Date
2025-12-09

AI Technical Summary

Technical Problem

Existing non-intrusive tracing solutions are complex to deploy and have a poor user experience, especially in automated deployment and containerized environments, where they add extra configuration work and potential human error.

Method used

When the application starts, the core modules in the tracing dependency package are loaded into the currently running virtual machine process. The preset agent is loaded by executing the initialization logic, and the target class file is modified by the agent and functional plugin modules to realize the chain tracing function, including cross-thread task processing and request call related class files.

Benefits of technology

This enables the deployment of agent loading and tracing functions without requiring users to manually configure JVM startup parameters, reducing deployment complexity, improving user experience, and enhancing deployment flexibility and system stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121098710A_ABST
    Figure CN121098710A_ABST
Patent Text Reader

Abstract

The invention provides a link tracking implementation method and device of an application program, electronic equipment and a medium, and relates to the technical field of computers. The method comprises the steps that when an application program is started, a core module in a tracking dependency package is loaded to a currently running virtual machine process; loading a preset agent program into a virtual machine process by executing initialization logic in the core module; modifying the target class file through a preset agent program and a function plug-in module in the tracking dependency package so as to realize a link tracking function of the application program; the target class file comprises a class file related to cross-thread task processing and a class file related to request calling. By executing the initialization logic of the core module in the tracking dependency package, the agent program is automatically loaded when the application program is started, so that loading of the agent program and deployment of the link tracking function can be completed without manually configuring JVM starting parameters by a user, the deployment complexity is reduced, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular, to a link tracking implementation method and device of application program, electronic equipment and medium. BACKGROUND

[0002] With the wide application of micro-service architecture and cloud native technology, the observability of distributed system becomes more and more important. As a core component of the observability, link tracking can help developers understand the flow path and performance bottleneck of requests in the distributed system. Non-invasive link tracking gradually becomes the mainstream solution in the industry because it does not need to modify the business code.

[0003] The current mainstream non-invasive link tracking solution usually relies on Java Agent technology. The typical deployment method is to add the parameter '-javaagent: / path / to / agent.jar' in the Java application startup command. This parameter instructs the JVM (Java Virtual Machine) to load and initialize the specified Agent before the application class is loaded. The Agent then uses the Instrumentation API provided by JVM to perform bytecode enhancement and insert tracking code at key methods such as HTTP calls, database access, etc., thereby realizing the monitoring and tracking of request call links.

[0004] Although the above-mentioned non-invasive link tracking solution avoids modifying the business code of the application program, it requires users to manually modify the JVM startup parameters. For developers who are not familiar with the configuration of JVM startup parameters or in the environment of automated deployment and containerization, it will increase the additional configuration workload, introduce potential human errors, and increase the complexity of deployment. In addition, manual configuration of JVM startup parameters means that users need to deeply understand the deployment details of a specific product, which reduces the ease of use and promotion efficiency of the product. SUMMARY

[0005] Therefore, the purpose of the present application is to provide a link tracking implementation method and device of application program, electronic equipment and medium to solve the problem of high deployment complexity and poor user experience of the existing non-invasive link tracking solution.

[0006] In order to achieve the above-mentioned purpose, the technical solutions adopted by the embodiments of the present application are as follows: In a first aspect, the present application provides a link tracking implementation method of application program, which comprises: loading a core module in a tracking dependency package to the currently running virtual machine process when the application program starts; the core module comprises initialization logic, and the initialization logic is used to load a preset proxy program; loading the preset agent program into the virtual machine process by executing the initialization logic; modifying target class files by the preset agent program and the functional plug-in modules in the tracking dependent package to realize the link tracking function of the application program; the target class files include class files related to cross-thread task processing and class files related to request calling.

[0007] In an optional implementation, the preset agent program includes a first agent program, the first agent program includes context transmission logic, and the first agent program is used for modifying the class files related to cross-thread task processing; the modifying target class files by the preset agent program and the functional plug-in modules in the tracking dependent package includes: inserting the context transmission logic into the class files related to cross-thread task processing by the first agent program to realize cross-thread context transmission.

[0008] In an optional implementation, the preset agent program includes a second agent program, the second agent program is used for modifying the class files related to request calling; the modifying target class files by the preset agent program and the functional plug-in modules in the tracking dependent package includes: loading the functional plug-in modules in the tracking dependent package by the second agent program, and inserting request calling tracking logic in the functional plug-in modules into the class files related to request calling to realize link tracking of the request calling process.

[0009] In an optional implementation, the loading the preset agent program into the virtual machine process by executing the initialization logic includes: loading the preset agent program into the virtual machine process by using a preset connection tool in the process of executing the initialization logic.

[0010] In an optional implementation, the loading the preset agent program into the virtual machine process by using a preset connection tool in the process of executing the initialization logic includes: obtaining a process identifier of a currently running virtual machine process in the process of executing the initialization logic, and establishing a connection between the core module and the virtual machine process by the process identifier and the preset connection tool; loading the preset agent program into the virtual machine process by the preset connection tool after the connection between the core module and the virtual machine process is established.

[0011] In a second aspect, the present application provides a device for implementing link tracking of an application, the device comprising: a loading module configured to load a core module in a tracking dependent package into a currently running virtual machine process when the application is started, wherein the core module comprises initialization logic configured to load a preset agent, and wherein the preset agent is loaded into the virtual machine process by executing the initialization logic; a class file modification module configured to modify target class files by using the preset agent and a function plug-in module in the tracking dependent package, so as to implement the link tracking function of the application, wherein the target class files comprise class files related to cross-thread task processing and class files related to request calling.

[0012] In an optional implementation, the preset agent comprises a first agent, the first agent comprises context transmission logic, and the first agent is configured to modify the class files related to cross-thread task processing, and the class file modification module is configured to insert the context transmission logic into the class files related to cross-thread task processing by using the first agent, so as to implement cross-thread context transmission.

[0013] In an optional implementation, the preset agent comprises a second agent, the second agent is configured to modify the class files related to request calling, and the class file modification module is configured to load the function plug-in module in the tracking dependent package by using the second agent, and insert request calling tracking logic in the function plug-in module into the class files related to request calling, so as to implement link tracking of the request calling process.

[0014] In a third aspect, the present application provides an electronic device comprising a processor, a memory, and a computer program stored on the memory and executable on the processor, wherein the computer program is executed by the processor to implement the steps of the method for implementing link tracking of an application according to any one of the preceding embodiments.

[0015] In a fourth aspect, the present application provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the method for implementing link tracking of an application according to any one of the preceding embodiments.

[0016] The application provides an application link tracking implementation method and device, electronic equipment and a medium, the method comprising: loading a core module in a tracking dependent package to a currently running virtual machine process when an application starts; the core module comprising initialization logic, the initialization logic being configured to load a preset agent program; loading the preset agent program into the virtual machine process by executing the initialization logic; modifying a target class file by using the preset agent program and a function plug-in module in the tracking dependent package to implement the link tracking function of the application; the target class file comprising a class file related to cross-thread task processing and a class file related to request calling. By executing the initialization logic of the core module in the tracking dependent package, the agent program is automatically loaded when the application starts, the loading of the agent program and the deployment of the link tracking function are implemented without manual configuration of the JVM start parameter, the deployment complexity is reduced, and the user experience is improved.

[0017] In order to make the above objectives, characteristics and advantages of the present application more apparent, the following will describe a preferred embodiment in detail with reference to the attached drawings. BRIEF DESCRIPTION OF DRAWINGS

[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments. It should be understood that the following drawings only show some of the embodiments of the present application, and therefore should not be considered as a limitation to the scope. For those skilled in the art, other related drawings can also be obtained without creative labor on the basis of these drawings.

[0019] Figure 1 Fig. 1 shows a flow diagram of the application link tracking implementation method provided by the embodiments of the present application; Figure 2 Fig. 2 shows a schematic diagram of the tracking dependent package; Figure 3 Fig. 3 shows a functional module diagram of the application link tracking implementation device provided by the embodiments of the present application; Figure 4 Fig. 4 shows a block diagram of the electronic equipment provided by the embodiments of the present application.

[0020] Fig. 1 shows a block diagram of the electronic equipment provided by the embodiments of the present application. DETAILED DESCRIPTION

[0021] The technical solutions in the embodiments of the present application will be clearly and completely described with reference to the accompanying drawings of the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all. The components of the embodiments of the present application described and shown in the accompanying drawings can be arranged and designed in various different configurations.

[0022] Therefore, the detailed description of the embodiments of the present application provided below in the accompanying drawings is not intended to limit the scope of the claimed application, but only represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.

[0023] It should be noted that the relational terms such as "first" and "second" and the like are used only to distinguish one entity or operation from another, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the terms "comprising", "including" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or apparatus including a series of elements includes not only those elements, but also other elements not explicitly listed or inherent to such a process, method, article or apparatus. Without more limitations, the element defined by the statement "comprising a" does not exclude the presence of additional identical elements in the process, method, article or apparatus including the element.

[0024] The current non-invasive link tracking solution, although realizing code-level non-invasion, still has some deficiencies in the deployment level: the existing solution is forced to rely on the -javaagent parameter of JVM startup, which means that every time the deployment or upgrade is performed, the startup script or container configuration may need to be modified, increasing the operation and maintenance burden; for users pursuing "zero-configuration" or "out-of-the-box" experience, manual modification of the JVM startup parameter is still a threshold; although the code is non-invasive, the Agent configuration during deployment still constitutes a certain integration cost, especially in enterprise environments with a large number of microservices or complex deployment processes. Therefore, a more flexible and higher degree of automation deployment mechanism is urgently needed to truly realize the full-link non-invasive experience from code to deployment.

[0025] Based on this, the embodiment of the application provides a link tracking implementation method, device, electronic equipment and medium of an application program, the method comprises the steps of: loading a core module in a tracking dependent package to a currently running virtual machine process when the application program starts; the core module comprises initialization logic, and the initialization logic is used for loading a preset proxy program; the preset proxy program is loaded into the virtual machine process by executing the initialization logic in the core module; a target class file is modified by the preset proxy program and a functional plug-in module in the tracking dependent package, so that the link tracking function of the application program is realized; the target class file comprises a class file related to cross-thread task processing and a class file related to request calling. By executing the initialization logic of the core module in the tracking dependent package, the proxy program is automatically loaded when the application program starts, the loading of the proxy program and the deployment of the link tracking function are realized without manual configuration of the JVM start parameter, the deployment complexity is reduced, and the user experience is improved.

[0026] In the following, the embodiments of the application will be described in detail with reference to the drawings.

[0027] Please refer to Figure 1 , a flowchart of the link tracking implementation method of the application program provided by the embodiment of the application. It should be noted that the link tracking implementation method of the application program of the application is not limited to Figure 1 and the following specific order. It should be understood that in other embodiments, the order of some steps of the link tracking implementation method of the application program of the application can be exchanged according to actual needs, or some steps can be omitted or deleted. The link tracking implementation method of the application program can be applied to electronic equipment such as notebook computers, tablet computers, PC (Personal Computer, personal computer), servers, etc. In the following, the specific process shown in the figure will be described in detail. Figure 1

[0028] Step S101, loading a core module in a tracking dependent package to a currently running virtual machine process when the application program starts; the core module comprises initialization logic, and the initialization logic is used for loading a preset proxy program.

[0029] ​In the embodiment, the tracking dependent package can be understood as a kind of SDK (Software Development Kit, software development kit), and it is a software component set for realizing application link tracking function, is integrated into the build configuration of application in standard software dependent form, so as to be automatically loaded into the currently running virtual machine process when application is started.The tracking dependent package mainly includes a core module and one or more functional plug-in modules, the core module is a software module in the tracking dependent package responsible for dynamically loading agent, the core module includes initialization logic, and the initialization logic is used to load preset agent;The functional plug-in module is a software module in the tracking dependent package, which provides interception rules and request call tracking logic.As shown in Figure 2 The tracking dependent package (such as sdk-all) is a kind of schematic diagram.

[0030] Taking a Java application as an example, in the build phase of the application, the developer only needs to declare the tracking dependent package in the build configuration file (such as pom.xml) of the application, and the build tool will automatically package the core module and the functional plug-in module into the final application deployment package (such as JAR or WAR file), and automatically load these modules by Java class loader according to class loading rules when the application runs. It can be seen that the introduction mode of the above tracking dependent package completely follows the standard dependent management mechanism of Java platform, without modifying the source code of the application, and without configuring JVM startup parameters, realizing the non-invasive integration of the application.

[0031] In step S102, the preset agent is loaded into the virtual machine process by executing the initialization logic.

[0032] In the embodiment, the core module in the tracking dependent package contains specific initialization logic, after the core module of the tracking dependent package is loaded into the currently running virtual machine process, the initialization logic in the core module will be triggered to execute, and in the execution process of the initialization logic, the preset agent will be loaded into the virtual machine process. That is to say, the loading of the agent in the embodiment is completed by the core module through its initialization logic at runtime, rather than depending on JVM startup parameters, which indicates that the agent is dynamically loaded into the virtual machine process when the application runs.

[0033] In the embodiment, the initialization logic can be triggered automatically or explicitly in the start entry of the application program (such as the main method), the life cycle callback of the Spring framework, or through a static code block. In this way, the core module can be loaded when the application program starts, and the initialization logic in the core module is automatically triggered to execute. That is, through careful design of the initialization logic of the core module, the core module can be dynamically loaded with the proxy program before the core business logic of the application program starts to execute and after most frameworks and libraries are initialized.

[0034] In step S103, the target class file is modified by the preset proxy program and the functional plug-in module in the tracking dependent package to implement the link tracking function of the application program. The target class file includes a class file related to cross-thread task processing and a class file related to request calling.

[0035] In the embodiment, the class file related to request calling mainly includes a class file of the application program itself and a class file of a third-party library dependent on the application program. By modifying the class file related to request calling, the link tracking of the request calling process can be implemented, such as the link tracking of an RPC (Remote Procedure Call) request. The class file related to cross-thread task processing mainly includes a core class file in the Java standard library, such as a class file in the JUC (Java Util Concurrent) package, which is widely used in scenarios such as thread pools and asynchronous tasks, which are prone to cause the loss of link context between different threads. The core class file in the Java standard library is usually loaded when the virtual machine process starts, which is earlier than the loading time of the class file of the application program itself and the class file of the third-party library dependent on the application program. By modifying the class file related to cross-thread task processing, the cross-thread context transmission can be implemented. Therefore, the link tracking function of the application program in the embodiment mainly includes two parts of cross-thread context transmission and link tracking of the request calling process.

[0036] Once the proxy program is successfully loaded into the virtual machine process, the proxy program will have the ability to modify the bytecodes of the classes. Through the proxy program and the functional plug-in module, the bytecode enhancement operation can be performed on the class file of the application program, the class file of the third-party library, and the core class file in the Java standard library, that is, the bytecodes in these class files are modified, so as to implement the link tracking function of the application program.

[0037] It can be seen that the application program link tracking implementation method provided by the embodiment of the application loads the core module in the tracking dependent package into the currently running virtual machine process when the application program is started; the core module comprises initialization logic, and the initialization logic is used to load the preset agent program; the preset agent program is loaded into the virtual machine process by executing the initialization logic; the target class file is modified by the preset agent program and the function plug-in module in the tracking dependent package, so that the link tracking function of the application program is realized; the target class file comprises a class file related to cross-thread task processing and a class file related to request calling. By executing the initialization logic of the core module in the tracking dependent package, the agent program is automatically loaded when the application program is started, the loading of the agent program and the deployment of the link tracking function are realized without manual configuration of the JVM start parameter by the user, the deployment complexity is reduced, and the user experience is improved.

[0038] In an embodiment, the step S102 specifically comprises: in the process of executing the initialization logic, the preset agent program is loaded into the virtual machine process by using the preset connection tool.

[0039] In the embodiment, in order to realize the loading of the agent program without using the -javaagent parameter, the preset connection tool can be used to load the agent program into the virtual machine process in which the core module is located.

[0040] The preset connection tool can be a set of APIs (Application Programming Interface) provided by JVM, which is used to realize the connection of a Java process to another running Java process and dynamically load the agent program to the Java process. In the initialization logic of the core module, the API provided by JVM is called by programming, and the API allows the core module to be connected to the currently running virtual machine process and loads the agent program into the virtual machine process.

[0041] In an embodiment, the preset connection tool is used to load the preset agent program into the virtual machine process in the process of executing the initialization logic, specifically comprising: In the process of executing the initialization logic, the process identifier of the currently running virtual machine process is obtained, and the connection between the core module and the virtual machine process is established by using the process identifier and the preset connection tool; after the connection between the core module and the virtual machine process is established, the preset agent program is loaded into the virtual machine process by using the preset connection tool.

[0042] In the embodiment, in the process of executing the initialization logic in the core module, first, the process identifier of the currently running virtual machine process is obtained, and then the connection between the core module and the current virtual machine process is established by calling the preset connection tool with the process identifier as a parameter. After the connection is established, the pre-packaged agent program (such as a Java Agent JAR file) is dynamically loaded into the current virtual machine process through the preset connection tool, and the Java Agent JAR file usually contains the logic required for bytecode enhancement. The loading process does not need to rely on the -javaagent parameter at the start of the JVM, and the dynamic loading of the agent program is realized.

[0043] It can be understood that, considering that the above-mentioned preset connection tool provided by the JVM is usually used to connect external processes rather than its own process, and in the embodiment, the core module has been loaded into the virtual machine process and belongs to a part of the virtual machine process, the preset connection tool needs to be skillfully used, that is, the process identifier of the virtual machine process is first obtained, and then the preset connection tool is called to pass the process identifier as a parameter to establish the connection between the core module and the current virtual machine process. Since the process identifier points to the virtual machine process where the core module itself is located, this operation is essentially a process in which the core module realizes self-connection in the current virtual machine process, which bypasses the dependence on external processes and realizes self-boot loading of the core module.

[0044] For cross-thread context transfer, the first agent program can be used. That is, the above-mentioned agent program includes the first agent program, the first agent program includes the context transfer logic, and the first agent program is used to modify the class file related to cross-thread task processing. The modification of the target class file by the function plug-in module in the preset agent program and the tracking dependency package in step S103 can include: inserting the context transfer logic into the class file related to cross-thread task processing through the first agent program to realize cross-thread context transfer.

[0045] In the embodiment, the context transfer logic can be written into the first agent program by hard coding. After the first agent program is loaded into the virtual machine process, the first agent program performs a bytecode enhancement operation (bytecode rewriting) on the class file related to cross-thread task processing, that is, inserts the context transfer logic into the class file related to cross-thread task processing to realize cross-thread context transfer. Among them, the bytecode enhancement operation on the class file related to cross-thread task processing mainly focuses on thread-related classes, and by modifying the methods of these classes, the context transfer logic is inserted into them, so that the context information transmitted between different threads can be automatically captured and propagated, thereby ensuring the consistency and integrity of the link tracking information in a multi-threaded environment.

[0046] It should be noted that the class files related to cross-thread task processing are usually loaded before the first agent program, for example, the class files of the JUC package loaded first at the bottom need to be reloaded after being modified by bytecode rewriting according to the rules of the Java class loader to ensure that the modified class files take effect.

[0047] For link tracking of the request call process, the second agent program can be used. That is, the agent program includes the second agent program, and the second agent program is configured to modify the class files related to the request call. The modification of the target class files by the preset agent program and the functional plug-in module in the tracking dependent package in step S103 can include: loading the functional plug-in module in the tracking dependent package by the second agent program, and inserting the request call tracking logic in the functional plug-in module into the class files related to the request call, to realize link tracking of the request call process.

[0048] In this embodiment, the second agent program is configured to load and apply the functional plug-in module in the tracking dependent package to modify the bytecode of the class files of the application program and the class files of the third-party library, so as to realize link tracking of the request call process. Specifically, the functional plug-in module includes an interception rule and a request call tracking logic. The interception rule is mainly to define which classes, methods or code positions are intercepted. The request call tracking logic mainly refers to the enhanced logic to be inserted when the above positions are intercepted, for example, creating a new Span (the basic unit of link tracking, used to represent a call, a request or an operation, and recording the name, time, context, label, log and event of the operation), injecting a tracking context, extracting a tracking context, recording call time consumption, etc. The second agent program loads the class files of the application program and the class files of the third-party library according to the interception rule and the request call tracking logic defined in the functional plug-in module, and performs weaving processing, so as to realize automatic monitoring of the request call link without modifying the source code. It can be seen that the bytecode enhancement operations of the above two types of agent programs are dynamically executed at runtime, without modifying the source code or the compilation process, so as to realize truly non-invasive link tracking. By realizing the cross-thread context transmission capability through the first agent program, and automatically tracking the request call path through the second agent program, the technical solution of this embodiment greatly reduces the integration and maintenance cost of the link tracking system while ensuring the integrity of the link data, and provides a solid technical support for realizing the automatic and standardized observability system construction.

[0049] In summary, the link tracking implementation method of the application program provided in the embodiment of the application has the following significant beneficial effects compared with the prior art: Firstly, the embodiment of the application realizes an extremely simple integration and deployment mode, a user only needs to introduce a tracking dependent package in a build configuration file of an application program, and can complete integration of a link tracking function, without manually modifying any JVM start parameters. The tracking dependent package can dynamically load a required agent program through initialization logic of a core module when the application program starts, which greatly simplifies the integration and deployment process of the link tracking, and reduces the use threshold and operation and maintenance cost of the user.

[0050] Secondly, the embodiment of the application provides a truly "zero-configuration" non-invasive use experience, a developer can introduce the tracking dependent package like introducing an ordinary library, realizes non-invasion at a deployment level, does not need to care about configuration and deployment details of the agent program, and improves development efficiency and user experience.

[0051] Thirdly, the embodiment of the application significantly improves deployment flexibility, gets rid of dependence on JVM start parameters, and makes it more convenient to integrate the link tracking in a containerization, cloud native or automated deployment environment, and easy to automate and standardize.

[0052] Further, the embodiment of the application can also reduce operation and maintenance risks, reduces human errors that may be caused by manual configuration of JVM start parameters, and improves stability and reliability of the system.

[0053] Finally, the embodiment of the application also has wide applicability, and the mechanism of dynamically loading the agent program is independent of specific bytecode enhancement technologies, and can be applied to any scenario requiring dynamic loading of the agent program.

[0054] In order to perform the corresponding steps in the above embodiments and various possible manners, an implementation manner of a link tracking implementation device of an application program is given below. Please refer to Figure 3 A functional module diagram of the link tracking implementation device 600 of the application embodiment is provided. It should be noted that the link tracking implementation device 600 of the application embodiment has the same basic principles and technical effects as the above embodiments, and for brief description, the part not mentioned in the embodiment can be referred to the corresponding content in the above embodiments. The link tracking implementation device 600 of the application program includes a loading module 610 and a class file modification module 620.

[0055] The loading module 610 is configured to load a core module in a tracking dependent package to a currently running virtual machine process when the application program starts; the core module includes initialization logic, and the initialization logic is configured to load a preset agent program; and the preset agent program is loaded into the virtual machine process by executing the initialization logic.

[0056] It can be understood that the loading module 610 can perform steps S101 and S102.

[0057] The class file modification module 620 is configured to modify the target class file by using the preset agent program and the function plug-in module in the tracking dependent package, so as to realize the link tracking function of the application program; the target class file includes a class file related to cross-thread task processing and a class file related to request calling.

[0058] It can be understood that the class file modification module 620 can perform the step S103 described above.

[0059] Optionally, the loading module 610 is configured to load the preset agent program into the virtual machine process by using the preset connection tool in the process of executing the initialization logic.

[0060] Optionally, the loading module 610 is specifically configured to acquire the process identifier of the currently running virtual machine process in the process of executing the initialization logic, and establish the connection between the core module and the virtual machine process by using the process identifier and the preset connection tool; after the connection between the core module and the virtual machine process is established, the preset agent program is loaded into the virtual machine process by using the preset connection tool.

[0061] Optionally, the agent program includes a first agent program, and the first agent program includes the context transmission logic; the first agent program is configured to modify the class file related to cross-thread task processing. The class file modification module 620 is specifically configured to insert the context transmission logic into the class file related to cross-thread task processing by using the first agent program, so as to realize the cross-thread context transmission.

[0062] Optionally, the agent program includes a second agent program, and the second agent program is configured to modify the class file related to request calling. The class file modification module 620 is specifically configured to load the function plug-in module in the tracking dependent package by using the second agent program, and insert the request calling tracking logic in the function plug-in module into the class file related to request calling, so as to realize the link tracking of the request calling process.

[0063] Please refer to Figure 4 A block schematic diagram of an electronic device 100 according to an embodiment of the present application is shown in FIG. 1. The electronic device 100 includes a memory 110, a processor 120 and a communication module 130. The memory 110, the processor 120 and the communication module 130 are electrically connected with each other directly or indirectly to realize data transmission or interaction. For example, these elements can be electrically connected with each other through one or more communication buses or signal lines.

[0064] The memory 110 is used to store programs or data. The memory 110 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.

[0065] The processor 120 is used to read / write data or programs stored in the memory 110 and perform corresponding functions. For example, when a computer program stored in the memory 110 is executed by the processor 120, the link tracing implementation method of the application disclosed in the above embodiments can be implemented.

[0066] The communication module 130 is used to establish a communication connection between the electronic device 100 and other devices via a network, and to send and receive data via the network.

[0067] It should be understood that, Figure 4 The structure shown is only a schematic diagram of the electronic device 100. The electronic device 100 may also include components that are larger than... Figure 4 The more or fewer components shown, or having the same Figure 4 The different configurations shown. Figure 4 The components shown can be implemented using hardware, software, or a combination thereof.

[0068] This invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor 120, implements the link tracing method for the application disclosed in the above embodiments.

[0069] In several embodiments provided in the present application, it should be understood that the disclosed apparatus and method can also be implemented by other manners. The apparatus embodiments described above are merely illustrative, for example, the flowcharts and block diagrams in the drawings show the possible implementation architecture, function and operation of the apparatus, method and computer program product according to the embodiments of the present application. In this regard, each block in the flowcharts or block diagrams can represent a module, a program segment or a part of code, which contains one or more executable instructions for implementing the specified logic function. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur in different orders from those described in the drawings. For example, two consecutive blocks can actually be executed substantially in parallel, and they can also be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and the combination of blocks in the block diagrams and / or flowcharts, can be implemented by a dedicated hardware-based system for executing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.

[0070] In addition, each functional module in the embodiments of the present application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0071] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the embodiments of the method of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.

[0072] The above is only the preferred embodiment of the present application and is not used to limit the present application. For those skilled in the art, the present application can have various modifications and changes. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A method for implementing link tracing in an application, characterized in that, The method includes: When the application starts, the core module in the tracking dependency package is loaded into the currently running virtual machine process; the core module includes initialization logic, which is used to load a preset agent program; By executing the initialization logic, the preset agent program is loaded into the virtual machine process; The target class file is modified by the preset agent program and the functional plugin module in the tracing dependency package to realize the link tracing function of the application; the target class file includes class files related to cross-thread task processing and class files related to request invocation.

2. The application link tracing implementation method according to claim 1, characterized in that, The preset proxy program includes a first proxy program, which includes context passing logic. The first proxy program is used to modify the class file related to cross-thread task processing. Modifying the target class file through the preset proxy program and the functional plugin module in the dependency tracking package includes: The first agent program inserts the context passing logic into the class file related to cross-thread task processing to achieve cross-thread context passing.

3. The application link tracing implementation method according to claim 1, characterized in that, The preset proxy program includes a second proxy program, which is used to modify the class file related to the request call; the modification of the target class file through the preset proxy program and the functional plugin module in the dependency tracking package includes: The second agent loads the functional plugin module in the tracing dependency package and inserts the request call tracing logic in the functional plugin module into the class file related to the request call, so as to realize the link tracing of the request call process.

4. The application link tracing implementation method according to any one of claims 1-3, characterized in that, The step of loading the preset agent program into the virtual machine process by executing the initialization logic includes: During the execution of the initialization logic, the preset agent program is loaded into the virtual machine process using a preset connection tool.

5. The application link tracing implementation method according to claim 4, characterized in that, During the execution of the initialization logic, the preset agent program is loaded into the virtual machine process using a preset connection tool, including: During the execution of the initialization logic, the process identifier of the currently running virtual machine process is obtained, and a connection between the core module and the virtual machine process is established through the process identifier and the preset connection tool. After the core module establishes a connection with the virtual machine process, the preset agent program is loaded into the virtual machine process through the preset connection tool.

6. A link tracing implementation device for an application, characterized in that, The device includes: A loading module is used to load the core module from the dependency tracking package into the currently running virtual machine process when the application starts; the core module includes initialization logic, which is used to load a preset agent program; by executing the initialization logic, the preset agent program is loaded into the virtual machine process; The class file modification module is used to modify the target class file through the preset agent program and the functional plugin module in the tracing dependency package to realize the link tracing function of the application; the target class file includes class files related to cross-thread task processing and class files related to request invocation.

7. The application link tracing implementation method according to claim 6, characterized in that, The preset proxy program includes a first proxy program, which includes context passing logic. The first proxy program is used to modify the class file related to cross-thread task processing. The class file modification module is used to insert the context passing logic into the class file related to cross-thread task processing through the first proxy program to realize cross-thread context passing.

8. The application link tracing implementation method according to claim 6, characterized in that, The preset proxy program includes a second proxy program, which is used to modify the class file related to the request call; the class file modification module is used to load the functional plugin module in the tracing dependency package through the second proxy program, and insert the request call tracing logic in the functional plugin module into the class file related to the request call, so as to realize the link tracing of the request call process.

9. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the link tracing implementation method of the application as described in any one of claims 1-5.

10. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the steps of the link tracing implementation method of the application as described in any one of claims 1-5.

Citation Information

Cited By

  • Tomcat container application thread pool isolation method and device based on Java Agent and medium

    CN121918940A