Application program monitoring method and device
The method and device provide on-demand monitoring by scanning and configuring application metadata, weaving monitoring logic into bytecode, enabling flexible and accurate tracking of specific methods in virtual machines.
Patent Information
- Application Number
- CN202111177133.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-09
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2041-10-09
AI Technical Summary
Existing application monitoring systems lack on-demand monitoring capabilities and flexibility, particularly for virtual machines, as they cannot track specified methods according to developer wishes and require full-link tracking.
A method and device that allows for on-demand monitoring by scanning metadata of class names, method names, and parameter numbers, enabling user-configurable monitoring through a server-side configuration interface, and weaving monitoring logic into bytecode using dynamic attach technology.
Enables flexible, on-demand monitoring of specific application methods without restarting, allowing real-time tracking and long-term monitoring with high flexibility and accuracy.
Smart Images

Figure CN113868090B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and specifically relates to an application monitoring method and device. Background Art
[0002] With the popularity of cross-platform languages that can be compiled once and run everywhere, various programming language virtual machines have emerged, such as JVM (Java Virtual Machine). For applications running on programming language virtual machines, the virtual machines themselves provide corresponding performance monitoring methods and tools to ensure that problems can be located and analyzed after problems occur in the application.
[0003] In the prior art, full-link tracking systems such as skywalking and pinpoint are used to monitor applications running on virtual machines. Such systems perform tracking based on common technical frameworks and track all links of service interfaces. They can help find which stage of the link has a "bad" call, but they cannot support tracking monitoring of specified methods according to the developer's wishes, cannot perform on-demand monitoring, and have poor flexibility. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide an application monitoring method and device, which can solve the problems existing in the prior art that on-demand monitoring cannot be achieved and the flexibility is poor.
[0005] In a first aspect, an embodiment of the present application provides an application monitoring method, which is applied to a virtual machine side, and the method includes:
[0006] Obtain metadata loaded when the target application is started and run, wherein the metadata includes: class name, method name and number of parameters;
[0007] The metadata is uploaded to a server, and a monitoring item configuration instruction issued by the server is received, wherein the server displays a plurality of configurable items on a monitoring item configuration page after receiving the metadata, each of the configurable items includes a class name, a method name, and a number of parameters that have a corresponding relationship in the metadata, and the monitoring item configuration instruction is an instruction triggered by a user for at least one configurable item displayed on the monitoring item configuration page;
[0008] According to the monitoring item configuration instruction, a target item in the target application is monitored, wherein the target item is a configurable item selected by the user on the monitoring item configuration page.
[0009] Optionally, as an embodiment, the monitoring project configuration instruction carries the monitoring logic information of the target project;
[0010] The monitoring of the target project in the target application according to the monitoring project configuration instruction includes:
[0011] By using a dynamic attach technology, the monitoring logic information is woven into the bytecode of the target project of the target application program to obtain an edited bytecode;
[0012] When the edited bytecode is executed, data during the execution is collected;
[0013] Based on the data collected during the execution, monitoring data is generated, and the monitoring data is uploaded to the server, wherein the monitoring data carries an identifier of the target project in the target application.
[0014] Optionally, as an embodiment, the step of obtaining metadata loaded when the target application is started and when it is running includes:
[0015] When the startup of the target application is detected, the loading logic of the bytecode of the target application is intercepted, the field and method information in the code unit loaded by the bytecode loader is scanned, and the code unit loaded by the bytecode loader at runtime is monitored to obtain the metadata loaded at startup and runtime.
[0016] In a second aspect, an embodiment of the present application provides an application monitoring method, which is applied to a server, and the method includes:
[0017] Receive metadata uploaded by the virtual machine end when the target application is started and loaded during operation, wherein the metadata includes: class name, method name and number of parameters;
[0018] According to the metadata, display the monitoring project configuration page corresponding to the target application, wherein the monitoring project configuration page displays multiple configurable items, each of which includes a class name, method name, and parameter number information that have a corresponding relationship in the metadata;
[0019] Receiving a selection input triggered by a user on at least one configurable item on the monitoring item configuration page, and generating a monitoring item configuration instruction in response to the selection input;
[0020] The monitoring project configuration instruction is issued to the virtual machine end, wherein the monitoring project configuration instruction is used to instruct the virtual machine end to monitor the target project in the target application, and the target project is a configurable project selected by the user on the monitoring project configuration page.
[0021] Optionally, as an embodiment, the generating of the monitoring item configuration instruction includes:
[0022] Acquire monitoring logic information of the target project;
[0023] Generate a monitoring item configuration instruction carrying the monitoring logic information.
[0024] In a third aspect, an embodiment of the present application provides an application monitoring device, which is applied to a virtual machine side, and the device includes:
[0025] An acquisition module, used to acquire metadata loaded when the target application is started and run, wherein the metadata includes: class name, method name and number of parameters;
[0026] An upload module, used for uploading the metadata to a server;
[0027] A first receiving module is used to receive a monitoring item configuration instruction issued by the server, wherein the server displays a plurality of configurable items on a monitoring item configuration page after receiving the metadata, each of the configurable items includes a class name, a method name, and a number of parameters that have a corresponding relationship in the metadata, and the monitoring item configuration instruction is an instruction triggered by a user for at least one configurable item displayed on the monitoring item configuration page;
[0028] The monitoring module is used to monitor the target item in the target application according to the monitoring item configuration instruction, wherein the target item is a configurable item selected by the user on the monitoring item configuration page.
[0029] Optionally, as an embodiment, the monitoring project configuration instruction carries the monitoring logic information of the target project;
[0030] The monitoring module comprises:
[0031] An editing submodule, used for weaving the monitoring logic information into the bytecode of the target project of the target application program through a dynamic attach technology to obtain an edited bytecode;
[0032] A collection submodule, used for collecting data during the execution process when the edited bytecode is executed;
[0033] A first generating submodule, configured to generate monitoring data based on the collected data during the execution process;
[0034] The uploading submodule is used to upload the monitoring data to the server, wherein the monitoring data carries the identifier of the target project in the target application.
[0035] Optionally, as an embodiment, the acquisition module includes:
[0036] The first acquisition submodule is used to intercept the loading logic of the bytecode of the target application when it is detected that the target application is started, scan the field and method information in the code unit loaded by the bytecode loader, and monitor the code unit loaded by the bytecode loader at runtime to obtain the metadata loaded at startup and runtime.
[0037] In a fourth aspect, an embodiment of the present application provides an application monitoring device, which is applied to a server, and the device includes:
[0038] The second receiving module is used to receive metadata uploaded by the virtual machine when the target application is started and loaded during operation, wherein the metadata includes: class name, method name and number of parameters;
[0039] A display module is used to display a monitoring project configuration page corresponding to the target application according to the metadata, wherein the monitoring project configuration page displays a plurality of configurable items, each of which includes a class name, a method name and a number of parameter information that have a corresponding relationship in the metadata;
[0040] A third receiving module is used to receive a user's selection input for triggering at least one configurable item on the monitoring item configuration page;
[0041] A generating module, for generating a monitoring item configuration instruction in response to the selection input;
[0042] The sending module is used to send the monitoring project configuration instruction to the virtual machine end, wherein the monitoring project configuration instruction is used to instruct the virtual machine end to monitor the target project in the target application, and the target project is a configurable project selected by the user on the monitoring project configuration page.
[0043] Optionally, as an embodiment, the generating module includes:
[0044] A second acquisition submodule, configured to acquire monitoring logic information of the target item in response to the selection input;
[0045] The second generating submodule is used to generate a monitoring item configuration instruction carrying the monitoring logic information.
[0046] In a fifth aspect, an embodiment of the present application provides an electronic device, which includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method described in the first aspect or the second aspect.
[0047] In a sixth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the method described in the first aspect or the second aspect are implemented.
[0048] In the seventh aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the steps of the method described in the first aspect or the second aspect.
[0049] In an embodiment of the present application, after the virtual machine side obtains the metadata loaded when the target application is started and run, the metadata is uploaded to the server side. After receiving the metadata, the server side displays multiple configurable items on the monitoring project configuration page. Each configurable item contains a class name, method name and parameter number information that have a corresponding relationship in the metadata. The user can select the project to be monitored on the monitoring project configuration page. After the user completes the selection, the server side sends the corresponding monitoring project configuration instructions to the virtual machine side, and the virtual machine side monitors the corresponding target project in the target application according to the monitoring project configuration instructions.
[0050] Compared with the prior art, in the embodiment of the present application, all classes and methods that may need to be monitored in the target application are scanned on the virtual machine side and reported to the server side. After being processed by the server side, they are displayed to the user in the form of a configuration page. The user selects the classes and methods to be monitored on the configuration page according to actual needs. After the user completes the selection, the server side remotely sends the corresponding monitoring instructions to the virtual machine side, instructing the virtual machine side to monitor the classes and methods that the user wants to monitor. Through the mutual cooperation between the virtual machine side and the server side, on-demand monitoring is achieved with high flexibility. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 It is an architecture diagram of an application monitoring method provided in an embodiment of the present application;
[0052] Figure 2 is a flow chart of another application monitoring method provided by an embodiment of the present application;
[0053] Figure 3 This is an example diagram of a monitoring project configuration page provided in an embodiment of the present application;
[0054] Figure 4 is a flow chart of another application monitoring method provided in an embodiment of the present application;
[0055] Figure 5 is a structural block diagram of an application monitoring device provided in an embodiment of the present application;
[0056] Figure 6is a structural block diagram of another application monitoring device provided in an embodiment of the present application;
[0057] Figure 7 is a structural schematic diagram of an electronic device provided in an embodiment of the present application;
[0058] Figure 8 It is a schematic diagram of the hardware structure of an electronic device implementing various embodiments of the present application. DETAILED DESCRIPTION
[0059] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0060] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0061] With the popularity of cross-platform languages that "compile once, run everywhere", various programming language virtual machines have emerged. For programs running on programming language virtual machines (such as JVM), the virtual machine itself provides corresponding performance monitoring means and tools. Often after a problem occurs, such as when a Java program has a memory leak or overflow, the dump snapshot of the heap is exported through commands such as jmap for analysis. Such tools have a significant effect on troubleshooting problems such as memory overflow and thread deadlock. However, due to the uneven technical level of developers, some less "serious" runtime problems are often caused by the unreasonable implementation of certain business logic. Such problems often make people aimless and difficult to track. For example, the overall service status is good, but only one of the http interface responses occasionally responds slowly. We need to find the "bad" code block in the business logic and provide it to developers for targeted optimization.
[0062] At present, there are various performance positioning systems in the industry to assist in locating these problems. For example, full-link tracking systems represented by skywalking and pinpoint can track service interface links, but most of them are based on common technical frameworks for tracking. They can help find which stage of the link has a "bad" call, but cannot support tracking monitoring of specified custom methods according to the wishes of developers, cannot achieve on-demand monitoring, and have poor flexibility.
[0063] In order to solve the above technical problems, an embodiment of the present application provides an application monitoring method and device.
[0064] The following is a detailed description of the application monitoring method provided by the embodiment of the present application through specific embodiments and their application scenarios in conjunction with the accompanying drawings.
[0065] Figure 1 is an architecture diagram of an application monitoring method provided in an embodiment of the present application, such as Figure 1 As shown, it includes: a virtual machine side and a server side, wherein the target application and the monitoring system are installed in the virtual machine side, and the background service is installed in the server side. The monitoring system is used to monitor the running process of the target application and transmit the monitoring data to the background service. The background service is used to receive the data sent by the monitoring system and send control instructions to the monitoring system to instruct the monitoring system to monitor the target application according to the user's needs. In actual applications, the target application and the monitoring system in the virtual machine side can be started at the same time by specifying the startup parameters.
[0066] Figure 2 is a flowchart of another application monitoring method provided in an embodiment of the present application, which is applied to a virtual machine side, such as Figure 2 As shown, the method may include the following steps: step 201, step 202 and step 203, wherein:
[0067] In step 201, metadata loaded when the target application is started and run is obtained, wherein the metadata includes: class name, method name and number of parameters.
[0068] In the embodiment of the present application, all classes and methods that the user may need to monitor in the target application are obtained by obtaining metadata loaded when the target application is started and run.
[0069] Considering that virtual machines all have their own startup enhancement technology, which supports initial configuration pull, reporting link establishment and class scanning before executing business service logic, in the embodiment of the present application, the startup bytecode enhancement and running bytecode enhancement technology of the virtual machine can be used to obtain the metadata loaded when the target application is started and when it is running. Specifically, the above step 201 can include the following steps:
[0070] When the target application is detected to be started, the loading logic of the bytecode of the target application is intercepted, the field and method information in the code unit loaded by the bytecode loader is scanned, and the code unit loaded by the runtime bytecode loader is monitored to obtain the metadata loaded at startup and runtime.
[0071] In the embodiment of the present application, the loading logic of the bytecode of the target application can be intercepted by an interceptor in the virtual machine.
[0072] In step 202, the metadata is uploaded to the server, and the monitoring project configuration instruction issued by the server is received. After receiving the metadata, the server displays multiple configurable items on the monitoring project configuration page, each configurable item includes a class name, method name and parameter number information that have a corresponding relationship in the metadata, and the monitoring project configuration instruction is an instruction triggered by the user for at least one configurable item displayed on the monitoring project configuration page.
[0073] In an embodiment of the present application, after obtaining the metadata loaded when the target application is started and run, the metadata is uploaded to the server for storage so that the server can display the monitoring project configuration page corresponding to the target application based on the metadata, provide users with a friendly operation interface and operation method, and simplify user operations.
[0074] In an example, Figure 3 As shown, a monitoring project configuration page is shown, which includes 6 configurable items. Each configuration item includes a correspondence between a class name, a method name, and the number of parameters. The user can select the target project that needs to be monitored by the virtual machine by checking the "square box" at the front of each item. For example, if the user checks the first three configuration items in the monitoring project configuration page, the server will generate monitoring project configuration instructions for monitoring these three projects in the target application (at this time, these three projects are target projects) according to the user's selection, and send them to the virtual machine. The configuration takes effect in real time without restarting.
[0075] In an embodiment of the present application, the server provides a configuration page for users to add code monitoring requirements. When generating monitoring project configuration instructions, the monitoring logic information of the monitoring project is obtained, and the monitoring project configuration instructions carrying the monitoring logic information are generated.
[0076] In step 203, according to the monitoring item configuration instruction, the target item in the target application is monitored, wherein the target item is a configurable item selected by the user on the monitoring item configuration page.
[0077] In the embodiment of the present application, after receiving the monitoring project configuration instruction from the server, the virtual machine monitors the target project selected by the user in the target application to achieve on-demand monitoring.
[0078] In the embodiment of the present application, the monitoring logic can be woven into the bytecode of the corresponding target class through the dynamic attach technology of the virtual machine. When the service executes the corresponding method code, the execution time is counted, the method parameters are collected, the method exceptions are captured, and the monitoring data unit is encapsulated, and the name, ID, IP and other identification information of the current service are marked and reported to the server. Specifically, the above step 203 can include the following steps:
[0079] Through dynamic attach technology, the monitoring logic information in the monitoring project configuration instructions is woven into the bytecode of the target project of the target application to obtain the edited bytecode; when the edited bytecode is executed, the data of the execution process is collected; based on the collected data of the execution process, monitoring data is generated and uploaded to the server, wherein the monitoring data carries the identifier of the target project in the target application.
[0080] In an example, if the monitoring logic information is to calculate the execution time of a class, a function A of the read time can be woven at the beginning position of the bytecode of the class, and a function B of the read time can be woven at the end position of the bytecode of the class. After the bytecode of the class is executed, the time of function B is subtracted from that of function A to obtain the execution time of the class.
[0081] As can be seen from the above embodiment, in this embodiment, after the virtual machine side obtains the metadata loaded when the target application is started and running, the metadata is uploaded to the server side. After receiving the metadata, the server side displays multiple configurable items on the monitoring project configuration page, each configurable item contains a class name, method name and parameter number information with a corresponding relationship in the metadata, and the user can select the project to be monitored on the monitoring project configuration page. After the user has completed the selection, the server side sends the corresponding monitoring project configuration instruction to the virtual machine side, and the virtual machine side monitors the corresponding target project in the target application according to the monitoring project configuration instruction. Compared with the prior art, in the embodiment of the present application, all classes and methods that may need to be monitored in the target application are scanned on the virtual machine side, reported to the server side, and displayed to the user in the form of a configuration page after being processed by the server side. The user selects the classes and methods that he wants to monitor on the configuration page according to actual needs. After the user completes the selection, the server side remotely sends the corresponding monitoring instruction to the virtual machine side, instructing the virtual machine side to monitor the classes and methods that the user wants to monitor. Through the mutual cooperation between the virtual machine side and the server side, on-demand monitoring is achieved, and the flexibility is high.
[0082] It can be seen that in the embodiments of the present application, by combining the bytecode enhancement technology at the startup of the virtual machine with the running bytecode enhancement technology, all classes and methods that the user may need to monitor are scanned, and monitoring instructions are remotely configured and issued to monitor any method that the user wants to monitor. It can be dynamically effective without restarting, and long-term real-time monitoring can be performed. Even if the service is restarted, all corresponding monitoring tasks will be automatically started.
[0083] Figure 4 is a flowchart of another application monitoring method provided in an embodiment of the present application, which is applied to a server, such as Figure 4 As shown, the method may include the following steps: step 401, step 402, step 403 and step 404, wherein:
[0084] In step 401, metadata uploaded by the virtual machine and loaded when the target application is started and run is received, wherein the metadata includes: class name, method name and number of parameters.
[0085] In step 402, a monitoring project configuration page corresponding to the target application is displayed according to the metadata, wherein the monitoring project configuration page displays multiple configurable items, each of which contains a corresponding class name, method name and parameter number information in the metadata.
[0086] In an embodiment of the present application, the server displays the configurable monitoring classes and methods belonging to the target application on a configuration page for user selection.
[0087] In step 403, a selection input triggered by a user on at least one configurable item on the monitoring item configuration page is received, and a monitoring item configuration instruction is generated in response to the selection input, wherein the monitoring item configuration instruction is used to instruct the virtual machine side to monitor a target item in a target application, and the target item is a configurable item selected by the user on the monitoring item configuration page.
[0088] In the embodiment of the present application, the selection input may be a check operation or a click operation.
[0089] In an embodiment of the present application, monitoring logic information of a target project is obtained, and a monitoring project configuration instruction carrying the monitoring logic information is generated, wherein the monitoring logic information can be automatically generated by the server according to user selection input.
[0090] In step 404, a monitoring project configuration instruction is sent to the virtual machine.
[0091] In the embodiment of the present application, after receiving the monitoring project configuration instruction, the virtual machine monitors the target project selected by the user in the target application and reports the monitoring data to the server.
[0092] In the embodiment of the present application, the server receives the monitoring data uploaded by the virtual machine, and can aggregate the monitoring data and store it in a time series database. Specifically, dimension aggregation and index calculation can be performed according to the time series, and stored in the time series database for user query and subsequent display.
[0093] In the embodiment of the present application, the server can also obtain some monitoring indicators, and match the monitoring data reported by the virtual machine with the monitoring indicators according to the rules, so as to achieve the purpose of issuing an alarm when an abnormality is found.
[0094] As can be seen from the above embodiment, in this embodiment, after the virtual machine side obtains the metadata loaded when the target application is started and running, the metadata is uploaded to the server side. After receiving the metadata, the server side displays multiple configurable items on the monitoring project configuration page, each configurable item contains a class name, method name and parameter number information with a corresponding relationship in the metadata, and the user can select the project to be monitored on the monitoring project configuration page. After the user has completed the selection, the server side sends the corresponding monitoring project configuration instruction to the virtual machine side, and the virtual machine side monitors the corresponding target project in the target application according to the monitoring project configuration instruction. Compared with the prior art, in the embodiment of the present application, all classes and methods that may need to be monitored in the target application are scanned on the virtual machine side, reported to the server side, and displayed to the user in the form of a configuration page after being processed by the server side. The user selects the classes and methods that he wants to monitor on the configuration page according to actual needs. After the user completes the selection, the server side remotely sends the corresponding monitoring instruction to the virtual machine side, instructing the virtual machine side to monitor the classes and methods that the user wants to monitor. Through the mutual cooperation between the virtual machine side and the server side, on-demand monitoring is achieved, and the flexibility is high.
[0095] It should be noted that the application monitoring method provided in the embodiment of the present application can be executed by an application monitoring device, or a control module in the application monitoring device for executing the method for loading an application monitoring. In the embodiment of the present application, the application monitoring device provided in the embodiment of the present application is described by taking the application monitoring device executing the method for loading an application monitoring as an example.
[0096] Figure 5 is a structural block diagram of an application monitoring device provided in an embodiment of the present application, such as Figure 5 As shown, the application monitoring device 500, applied to the virtual machine side, may include: an acquisition module 501, an upload module 502, a first receiving module 503 and a monitoring module 504, wherein:
[0097] The acquisition module 501 is used to acquire metadata loaded when the target application is started and run, wherein the metadata includes: class name, method name and number of parameters;
[0098] An upload module 502, used to upload the metadata to a server;
[0099] A first receiving module 503 is used to receive a monitoring item configuration instruction issued by the server, wherein the server displays multiple configurable items on a monitoring item configuration page after receiving the metadata, each of which includes a class name, a method name, and a number of parameters in a corresponding relationship in the metadata, and the monitoring item configuration instruction is an instruction triggered by a user for at least one configurable item displayed on the monitoring item configuration page;
[0100] The monitoring module 504 is used to monitor the target item in the target application according to the monitoring item configuration instruction, wherein the target item is a configurable item selected by the user on the monitoring item configuration page.
[0101] As can be seen from the above embodiment, in this embodiment, after the virtual machine side obtains the metadata loaded when the target application is started and running, the metadata is uploaded to the server side. After receiving the metadata, the server side displays multiple configurable items on the monitoring project configuration page, each configurable item contains a class name, method name and parameter number information with a corresponding relationship in the metadata, and the user can select the project to be monitored on the monitoring project configuration page. After the user has completed the selection, the server side sends the corresponding monitoring project configuration instruction to the virtual machine side, and the virtual machine side monitors the corresponding target project in the target application according to the monitoring project configuration instruction. Compared with the prior art, in the embodiment of the present application, all classes and methods that may need to be monitored in the target application are scanned on the virtual machine side, reported to the server side, and displayed to the user in the form of a configuration page after being processed by the server side. The user selects the classes and methods that he wants to monitor on the configuration page according to actual needs. After the user completes the selection, the server side remotely sends the corresponding monitoring instruction to the virtual machine side, instructing the virtual machine side to monitor the classes and methods that the user wants to monitor. Through the mutual cooperation between the virtual machine side and the server side, on-demand monitoring is achieved, and the flexibility is high.
[0102] Optionally, as an embodiment, the monitoring project configuration instruction carries the monitoring logic information of the target project;
[0103] The monitoring module 504 may include:
[0104] An editing submodule, used for weaving the monitoring logic information into the bytecode of the target project of the target application program through a dynamic attach technology to obtain an edited bytecode;
[0105] A collection submodule, used for collecting data during the execution process when the edited bytecode is executed;
[0106] A first generating submodule, configured to generate monitoring data based on the collected data during the execution process;
[0107] The uploading submodule is used to upload the monitoring data to the server, wherein the monitoring data carries the identifier of the target project in the target application.
[0108] Optionally, as an embodiment, the acquisition module 501 may include:
[0109] The first acquisition submodule is used to intercept the loading logic of the bytecode of the target application when it is detected that the target application is started, scan the field and method information in the code unit loaded by the bytecode loader, and monitor the code unit loaded by the bytecode loader at runtime to obtain the metadata loaded at startup and runtime.
[0110] Figure 6 is a structural block diagram of another application monitoring device provided in an embodiment of the present application, such as Figure 6 As shown, the application monitoring device 600, applied to the server, may include: a second receiving module 601, a display module 602, a third receiving module 603, a generating module 604 and a sending module 605, wherein:
[0111] The second receiving module 601 is used to receive metadata uploaded by the virtual machine when the target application is started and loaded during operation, wherein the metadata includes: class name, method name and number of parameters;
[0112] Display module 602, used for displaying the monitoring project configuration page corresponding to the target application according to the metadata, wherein the monitoring project configuration page displays multiple configurable items, each of which includes a class name, method name and parameter number information that has a corresponding relationship in the metadata;
[0113] The third receiving module 603 is used to receive a user's selection input for triggering at least one configurable item on the monitoring item configuration page;
[0114] A generating module 604, for generating a monitoring item configuration instruction in response to the selection input;
[0115] The sending module 605 is used to send the monitoring project configuration instruction to the virtual machine end, wherein the monitoring project configuration instruction is used to instruct the virtual machine end to monitor the target project in the target application, and the target project is a configurable project selected by the user on the monitoring project configuration page.
[0116] As can be seen from the above embodiment, in this embodiment, after the virtual machine side obtains the metadata loaded when the target application is started and running, the metadata is uploaded to the server side. After receiving the metadata, the server side displays multiple configurable items on the monitoring project configuration page, each configurable item contains a class name, method name and parameter number information with a corresponding relationship in the metadata, and the user can select the project to be monitored on the monitoring project configuration page. After the user has completed the selection, the server side sends the corresponding monitoring project configuration instruction to the virtual machine side, and the virtual machine side monitors the corresponding target project in the target application according to the monitoring project configuration instruction. Compared with the prior art, in the embodiment of the present application, all classes and methods that may need to be monitored in the target application are scanned on the virtual machine side, reported to the server side, and displayed to the user in the form of a configuration page after being processed by the server side. The user selects the classes and methods that he wants to monitor on the configuration page according to actual needs. After the user completes the selection, the server side remotely sends the corresponding monitoring instruction to the virtual machine side, instructing the virtual machine side to monitor the classes and methods that the user wants to monitor. Through the mutual cooperation between the virtual machine side and the server side, on-demand monitoring is achieved, and the flexibility is high.
[0117] Optionally, as an embodiment, the generating module 604 may include:
[0118] A second acquisition submodule, configured to acquire monitoring logic information of the target item in response to the selection input;
[0119] The second generating submodule is used to generate a monitoring item configuration instruction carrying the monitoring logic information.
[0120] The application monitoring device in the embodiment of the present application can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a palmtop computer, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and the non-mobile electronic device can be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0121] The application monitoring device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0122] The application monitoring device provided in the embodiment of the present application can achieve Figure 1 To avoid repetition, the various processes implemented in the method embodiment will not be described again here.
[0123] Alternatively, if Figure 7 As shown, an embodiment of the present application also provides an electronic device 700, including a processor 701, a memory 702, and a program or instruction stored in the memory 702 and executable on the processor 701. When the program or instruction is executed by the processor 701, each process of the above-mentioned application monitoring method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0124] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0125] Figure 8 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.
[0126] The electronic device 800 includes but is not limited to: a radio frequency unit 801, a network module 802, an audio output unit 803, an input unit 804, a sensor 805, a display unit 806, a user input unit 807, an interface unit 808, a memory 809, and a processor 810 and other components.
[0127] Those skilled in the art will appreciate that the electronic device 800 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 810 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Figure 8 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.
[0128] When the electronic device is a virtual machine, the processor 810 is used to obtain metadata loaded when the target application is started and run, wherein the metadata includes: class name, method name and number of parameters; upload the metadata to the server, and receive the monitoring project configuration instruction issued by the server, wherein the server displays multiple configurable items on the monitoring project configuration page after receiving the metadata, each of the configurable items includes a class name, method name and parameter number information that has a corresponding relationship in the metadata, and the monitoring project configuration instruction is an instruction triggered by the user for at least one configurable item displayed on the monitoring project configuration page; according to the monitoring project configuration instruction, monitor the target project in the target application, wherein the target project is the configurable project selected by the user on the monitoring project configuration page.
[0129] Optionally, as an embodiment, when the monitoring project configuration instruction carries the monitoring logic information of the target project, the processor 810 is also used to weave the monitoring logic information into the bytecode of the target project of the target application through dynamic attach technology to obtain an edited bytecode; when the edited bytecode is executed, data during the execution process is collected; based on the collected data during the execution process, monitoring data is generated, and the monitoring data is uploaded to the server, wherein the monitoring data carries the identifier of the target project in the target application.
[0130] Optionally, as an embodiment, the processor 810 is also used to intercept the loading logic of the bytecode of the target application when detecting that the target application is started, scan the field and method information in the code unit loaded by the bytecode loader, and monitor the code unit loaded by the bytecode loader at runtime to obtain the metadata loaded at startup and runtime.
[0131] When the electronic device is a server, the processor 810 is further used to receive metadata uploaded by the virtual machine when the target application is started and loaded during operation, wherein the metadata includes: class name, method name and number of parameters; according to the metadata, display the monitoring project configuration page corresponding to the target application, wherein the monitoring project configuration page displays multiple configurable items, each of which includes a class name, method name and number of parameters information in the metadata that has a corresponding relationship;
[0132] A user input unit 807, used to receive a user's selection input for triggering at least one configurable item on the monitoring item configuration page;
[0133] Processor 810 is also used to generate a monitoring project configuration instruction in response to the selection input; and send the monitoring project configuration instruction to the virtual machine end, wherein the monitoring project configuration instruction is used to instruct the virtual machine end to monitor the target project of the target application, and the target project is a configurable project selected by the user on the monitoring project configuration page.
[0134] Optionally, as an embodiment, the processor 810 is further configured to obtain monitoring logic information of the target project; and generate a monitoring project configuration instruction carrying the monitoring logic information.
[0135] It can be seen that in the embodiment of the present application, after the virtual machine obtains the metadata loaded when the target application is started and running, the metadata is uploaded to the server. After receiving the metadata, the server displays multiple configurable items on the monitoring project configuration page, each configurable item contains a class name, method name and parameter number information with a corresponding relationship in the metadata, and the user can select the project to be monitored on the monitoring project configuration page. After the user has completed the selection, the server sends the corresponding monitoring project configuration instruction to the virtual machine, and the virtual machine monitors the corresponding target project in the target application according to the monitoring project configuration instruction. Compared with the prior art, in the embodiment of the present application, all classes and methods that may need to be monitored in the target application are scanned on the virtual machine side, reported to the server, and displayed to the user in the form of a configuration page after being processed by the server. The user selects the classes and methods that he wants to monitor on the configuration page according to actual needs. After the user completes the selection, the server remotely sends the corresponding monitoring instruction to the virtual machine side, instructing the virtual machine side to monitor the classes and methods that the user wants to monitor. Through the mutual cooperation between the virtual machine side and the server side, on-demand monitoring is achieved, and the flexibility is high.
[0136] It should be understood that in the embodiment of the present application, the input unit 804 may include a graphics processor (Graphics Processing Unit, GPU) 8041 and a microphone 8042, and the graphics processor 8041 processes the image data of the static picture or video obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode. The display unit 806 may include a display panel 8061, and the display panel 8061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 807 includes a touch panel 8071 and other input devices 8072. The touch panel 8071 is also called a touch screen. The touch panel 8071 may include two parts: a touch detection device and a touch controller. Other input devices 8072 may include but are not limited to a physical keyboard, a function key (such as a volume control button, a switch button, etc.), a trackball, a mouse, and a joystick, which will not be repeated here. The memory 809 can be used to store software programs and various data, including but not limited to applications and operating systems. The processor 810 can integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, the user interface, and the application program, etc., and the modem processor mainly processes wireless communication. It is understandable that the above-mentioned modem processor may not be integrated into the processor 810.
[0137] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned application monitoring method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0138] The processor is a processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0139] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned application monitoring method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0140] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0141] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0142] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0143] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. An application monitoring method, applied to a virtual machine, characterized in that: The method comprises: Obtain metadata loaded when the target application is started and run, wherein the metadata includes: class name, method name and number of parameters; The metadata is uploaded to a server, and a monitoring item configuration instruction issued by the server is received, wherein the server displays a plurality of configurable items on a monitoring item configuration page based on the metadata after receiving the metadata, each of the configurable items includes a class name, a method name, and parameter number information that have a corresponding relationship in the metadata, the server receives a selection input triggered by a user for at least one of the configurable items on the monitoring item configuration page, and generates the monitoring item configuration instruction in response to the selection input, wherein the monitoring item configuration instruction is used to instruct the virtual machine to monitor a target item in the target application, and the target item is a configurable item selected by the user on the monitoring item configuration page; The target item in the target application is monitored according to the monitoring item configuration instruction.
2. The method according to claim 1, characterized in that The monitoring item configuration instruction carries the monitoring logic information of the target item; The monitoring of the target project in the target application according to the monitoring project configuration instruction includes: By using a dynamic attach technology, the monitoring logic information is woven into the bytecode of the target project of the target application program to obtain an edited bytecode; When the edited bytecode is executed, data during the execution is collected; Based on the data collected during the execution, monitoring data is generated, and the monitoring data is uploaded to the server, wherein the monitoring data carries an identifier of the target project in the target application.
3. The method according to claim 1, characterized in that The step of obtaining metadata loaded when the target application is started and running includes: When the startup of the target application is detected, the loading logic of the bytecode of the target application is intercepted, the field and method information in the code unit loaded by the bytecode loader is scanned, and the code unit loaded by the bytecode loader at runtime is monitored to obtain the metadata loaded at startup and runtime.
4. An application monitoring method, applied to a server, characterized in that: The method comprises: Receive metadata uploaded by the virtual machine end when the target application is started and loaded during operation, wherein the metadata includes: class name, method name and number of parameters; According to the metadata, display a monitoring project configuration page corresponding to the target application, wherein the monitoring project configuration page displays a plurality of configurable items, each of which includes a class name, a method name, and a number of parameter information that have a corresponding relationship in the metadata; Receiving a selection input triggered by a user on at least one configurable item on the monitoring item configuration page, and generating a monitoring item configuration instruction in response to the selection input; The monitoring project configuration instruction is issued to the virtual machine end, wherein the monitoring project configuration instruction is used to instruct the virtual machine end to monitor the target project in the target application, and the target project is a configurable project selected by the user on the monitoring project configuration page.
5. The method according to claim 4, characterized in that The generating of monitoring item configuration instructions comprises: Acquire monitoring logic information of the target project; Generate a monitoring item configuration instruction carrying the monitoring logic information.
6. An application monitoring device, applied to a virtual machine, characterized in that: The device comprises: An acquisition module, used to acquire metadata loaded when the target application is started and run, wherein the metadata includes: class name, method name and number of parameters; An upload module, used for uploading the metadata to a server; A first receiving module is used to receive a monitoring item configuration instruction issued by the server, wherein after receiving the metadata, the server displays a plurality of configurable items on a monitoring item configuration page based on the metadata, each of the configurable items includes a class name, a method name and parameter number information having a corresponding relationship in the metadata, the server receives a selection input triggered by a user for at least one of the configurable items on the monitoring item configuration page, and generates the monitoring item configuration instruction in response to the selection input, the monitoring item configuration instruction is used to instruct the virtual machine to monitor a target item in the target application, the target item is a configurable item selected by the user on the monitoring item configuration page, and the target item is a configurable item selected by the user on the monitoring item configuration page; A monitoring module is used to monitor the target project in the target application according to the monitoring project configuration instruction.
7. The device according to claim 6, characterized in that The monitoring item configuration instruction carries the monitoring logic information of the target item; The monitoring module comprises: An editing submodule, used for weaving the monitoring logic information into the bytecode of the target project of the target application program through a dynamic attach technology to obtain an edited bytecode; A collection submodule, used for collecting data during the execution process when the edited bytecode is executed; A first generating submodule, configured to generate monitoring data based on the collected data during the execution process; The uploading submodule is used to upload the monitoring data to the server, wherein the monitoring data carries the identifier of the target project in the target application.
8. The device according to claim 6, characterized in that The acquisition module comprises: The first acquisition submodule is used to intercept the loading logic of the bytecode of the target application when it is detected that the target application is started, scan the field and method information in the code unit loaded by the bytecode loader, and monitor the code unit loaded by the bytecode loader at runtime to obtain the metadata loaded at startup and runtime.
9. An application monitoring device, applied to a server, characterized in that: The device comprises: The second receiving module is used to receive metadata uploaded by the virtual machine when the target application is started and loaded during operation, wherein the metadata includes: class name, method name and number of parameters; A display module is used to display a monitoring project configuration page corresponding to the target application according to the metadata, wherein the monitoring project configuration page displays a plurality of configurable items, each of which includes a class name, a method name and a number of parameter information that have a corresponding relationship in the metadata; A third receiving module is used to receive a user's selection input for triggering at least one configurable item on the monitoring item configuration page; A generating module, for generating a monitoring item configuration instruction in response to the selection input; The sending module is used to send the monitoring project configuration instruction to the virtual machine end, wherein the monitoring project configuration instruction is used to instruct the virtual machine end to monitor the target project in the target application, and the target project is a configurable project selected by the user on the monitoring project configuration page.
10. The device according to claim 9, characterized in that The generation module comprises: A second acquisition submodule, configured to acquire monitoring logic information of the target item in response to the selection input; The second generating submodule is used to generate a monitoring item configuration instruction carrying the monitoring logic information.