Network monitoring method, apparatus, device, storage medium, and computer program product

By replacing the metaclass method of the application's network request process with a preset network monitoring method, the problem of low efficiency in network monitoring of modular applications is solved, and efficient network monitoring is achieved.

CN114490244BActive Publication Date: 2026-03-31上海瑞家信息技术有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-28
Publication Date
2026-03-31

AI Technical Summary

Technical Problem

In existing technologies, due to the modularity and decoupling of applications, it is impossible to determine the classes involved when monitoring the network request process, resulting in low network monitoring efficiency.

Method used

By determining the metaclass of the methods used in the network request process, and replacing the methods of the metaclass with preset network monitoring methods, network monitoring of the network request process can be achieved.

Benefits of technology

Network monitoring of the application can be achieved without traversing all classes, thus improving the efficiency of network monitoring.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114490244B_ABST
    Figure CN114490244B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a network monitoring method, device, equipment, storage medium and computer program product. In the embodiments of the present application, the metaclass of the method used by the network request process can be determined, and the method of the metaclass is replaced by a preset network monitoring method. In this way, the application program can use the preset network monitoring method to monitor the network request process when the network request process is executed, and the network monitoring of the entire network request process is realized. Since the metaclass is the class of the class, it contains all classes corresponding to all methods used by the network request process. Therefore, the network monitoring method does not need to traverse all classes corresponding to the methods used by the network request process, which helps to improve the network monitoring efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of Internet, and particularly relates to a network monitoring method and device, equipment, storage medium and computer program product. BACKGROUND

[0002] With the development of Internet technology and the continuous popularity of terminal computing, more and more application programs (such as APP) are widely installed and used. The performance of the application program greatly affects the user experience. In order to understand the performance of the application program, the application program developers often use application performance monitoring (APM) technology to monitor the network request process of the application program; by analyzing the data generated in the network request process, the network performance is determined.

[0003] In order to listen to the entire network request process, the classes and methods involved in the network request process need to be monitored. However, since the application program is modularized and each module is decoupled, it is equivalent to a black box, so when monitoring the network request process, it cannot be determined which classes the methods involved in the network request process correspond to, and therefore all classes of the application program need to be traversed, resulting in low network monitoring efficiency. SUMMARY

[0004] Aspects of the present application provide a network monitoring method, device, equipment, storage medium and computer program product to improve network monitoring efficiency.

[0005] The present application provides a network monitoring method, comprising:

[0006] determining the method used by the application program in the network request process;

[0007] determining the class corresponding to the method used in the network request process;

[0008] determining the metaclass of the class corresponding to the method according to the class corresponding to the method;

[0009] replacing the method of the metaclass with a preset network monitoring method, so that the application program performs network request process using the preset network monitoring method for network monitoring;

[0010] wherein the preset network monitoring method performs network monitoring and calls back the method of the metaclass.

[0011] The present application also provides a network monitoring device, comprising:

[0012] a first determining module for determining the method used by the application program in the network request process;

[0013] a second determining module configured to determine a metaclass corresponding to a class of a method used in the network request process;

[0014] a third determining module configured to determine, according to the class corresponding to the method, a metaclass of the class corresponding to the method;

[0015] a replacing module configured to replace a method of the metaclass with a preset network monitoring method, so that the application program performs network monitoring using the preset network monitoring method in the network request execution process; and the method of the metaclass is called back after the network monitoring by the preset network monitoring method.

[0016] The embodiment of the present application also provides an electronic device, comprising a memory and a processor; wherein the memory is configured to store a computer program;

[0017] The processor is coupled to the memory and is configured to execute the computer program to perform the steps in the network monitoring method.

[0018] The embodiment of the present application also provides a computer readable storage medium storing computer instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps in the network monitoring method.

[0019] The embodiment of the present application also provides a computer program product, comprising a computer program; and when the computer program is executed by a processor, the processor is caused to perform the steps in the network monitoring method.

[0020] In the embodiment of the present application, the method of the metaclass of the class of the method used in the network request process is replaced with the preset network monitoring method, so that the application program can perform network monitoring on the network request process using the preset network monitoring method in the network request process, and the network monitoring of the entire network request process is realized. Since the metaclass is the class of the class and contains all classes corresponding to all methods used in the network request process, the network monitoring method can realize the network monitoring of the application program without traversing all classes corresponding to all methods used in the network request process, and helps to improve the network monitoring efficiency. BRIEF DESCRIPTION OF DRAWINGS

[0021] The accompanying drawings, which are included to provide a further understanding of the present application, constitute a part of the present application and illustrate the illustrative embodiments of the present application and their descriptions serve to explain the present application, but do not constitute improper limitations on the present application. In the drawings:

[0022] Figure 1 a flowchart of the network monitoring method provided by the embodiment of the present application;

[0023] Figure 2A network request process schematic diagram provided by an embodiment of the present application is shown in FIG. 1.

[0024] Figure 3 A flow schematic diagram of another network monitoring method provided by an embodiment of the present application is shown in FIG. 2.

[0025] Figure 4 A structure schematic diagram of a network monitoring device provided by an embodiment of the present application is shown in FIG. 3.

[0026] Figure 5 A structure schematic diagram of an electronic device provided by an embodiment of the present application is shown in FIG. 4. DETAILED DESCRIPTION

[0027] In order to make the objectives, technical solutions and advantages of the present application clearer, the technical solutions of the present application will be described below in detail with reference to the embodiments of the present application and corresponding drawings. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present application.

[0028] In order to solve the technical problem of low network monitoring efficiency, an embodiment of the present application provides a solution, and the basic idea is as follows: by determining the metaclass of the method used in the network request process, the method of the metaclass is replaced by the preset network monitoring method, so that the application program can use the preset network monitoring method to monitor the network request process when executing the network request process, and the network monitoring of the entire network request process is realized. Since the metaclass is the class of the class, it contains all the classes corresponding to all the methods used in the network request process, so the network monitoring method can realize the network monitoring of the application program without traversing all the classes corresponding to all the methods used in the network request process, which helps to improve the network monitoring efficiency.

[0029] The technical solutions provided by the embodiments of the present application will be described in detail below with reference to the drawings.

[0030] It should be noted that: the same reference numerals in the following drawings and embodiments represent the same objects, so once an object is defined in one drawing or embodiment, it does not need to be further discussed in the subsequent drawings and embodiments.

[0031] Figure 1 A flow schematic diagram of a network monitoring method provided by an embodiment of the present application is shown in FIG. 1. Figure 1 As shown in FIG. 1, the network monitoring method comprises:

[0032] 101, determining the method used by the application program in the network request process.

[0033] 102, determining the class corresponding to the method used in the network request process.

[0034] 103. Determine the metaclass of the class corresponding to the method.

[0035] 104. Replace the metaclass methods with preset network monitoring methods so that the application uses the preset network monitoring methods to perform network monitoring during the network request process. The preset network monitoring method then calls back the metaclass method after performing network monitoring.

[0036] In this embodiment, an application refers to a computer program designed to perform one or more specific tasks. It runs in user mode, can interact with the user, and has a visual user interface. This embodiment does not limit the specific implementation form of the application. For example, an application can be an app, a webpage, a mini-program, etc., but is not limited to these.

[0037] Since applications are mostly modular and the modules are decoupled, essentially acting as black boxes, it is impossible to determine which classes correspond to the methods involved in the network request process during network request monitoring. Therefore, it is necessary to traverse all classes in the application, resulting in low efficiency of network monitoring.

[0038] In this embodiment, network monitoring refers to monitoring the network request process. This monitoring can be of the entire network request process or of a specific stage of the network request. In this embodiment, the specific process of the network request is not limited. In some embodiments, such as... Figure 2 As shown, the network request process may include: retrieving the network request from the request queue, the Domain Name Server (DNS) resolution phase, the connection establishment phase, the phase of sending the network request after the connection is established, and the phase of receiving the response message of the network request. The connection establishment phase includes: the secure connection phase, which establishes the connection after security verification is successful.

[0039] The network request process requires calling the corresponding method to execute the network procedures involved in the current network request phase. For example, calling the method corresponding to retrieving a network request from the request queue, or executing the process of retrieving a network request from the request queue. Therefore, to monitor the network request process, in step 101, it can be determined that the application needs to call at least one method (for executing the network procedures involved in that phase) during at least one phase of the network request process.

[0040] In this application, the specific implementation of the method used by the application in the network request process is not limited. In some embodiments, a technician may analyze the application to determine the method used by the application in the network request process. Further, a technician may manually input the method used by the application in the network request process. For a computing device, the method input by the technician can be determined as the method used by the application in the network request process.

[0041] Specifically, a human-computer interaction interface can be provided. This interface has method configuration items, which provide an input interface for technicians to set the methods used in the network request process. Technicians can set the methods used in the network request process through this method configuration item interface. Correspondingly, for computing devices, in response to the setting operation of the method configuration item corresponding to the network request process, the method associated with the setting operation can be determined as the method used by the application in the network request process.

[0042] In other embodiments, each method of the application corresponds to an Application Programming Interface (API), and the application uses the corresponding method by calling the API. For the API, the application developers can pre-define the API's description information. The description information for each API describes its purpose, such as at which stage it is used. Accordingly, based on the pre-defined API description information, the method used by the application during the network request process can be determined.

[0043] Optionally, semantic analysis can be performed on the description information of the API to determine the purpose of the corresponding method of the API; and to determine the method used in the network request process as the method used by the application in the network request process.

[0044] Since a class is a construct in object-oriented programming languages ​​that describes the common attributes and methods of created objects, step 102 can also determine the class corresponding to the method used in the network request process in order to monitor the network request process. Specifically, the class corresponding to the method used in the network request process can be determined according to a preset correspondence between methods and classes. For example, the method used in the network request process can be matched against the preset correspondence between methods and classes, and the class that matches the method used in the network request process is the class corresponding to the method used in the network request process.

[0045] Considering that a meta class is a class of classes, while a regular class defines the behavior of a specific object, a meta class defines the behavior of a specific class and its objects. Therefore, in this embodiment of the application, in order to improve the network monitoring efficiency of the application, in step 103, the meta class of the class corresponding to the method used in the network request process can be determined according to the class corresponding to the method used in the network request process.

[0046] Since class methods are stored in metaclasses, a class can find its metaclass through an Isa pointer. Therefore, the metaclass can be found by obtaining the Isa pointer of the class corresponding to the method used in the network request process. For applications written in Objective-C, because Objective-C is a dynamic language based on C with added object-oriented features and message forwarding mechanisms—meaning function calls become message sending—the compiler cannot know which function to call at compile time. Therefore, Objective-C requires not only a compiler but also a runtime system to dynamically create classes and objects, and perform message sending and forwarding. The runtime mechanism solves the problem of finding the method to call at runtime.

[0047] Based on this, one implementation of step 103 is as follows: the class corresponding to the method used in the network request process can be run using the runtime mechanism to obtain the class pointed to by the Isa pointer in the class corresponding to the method used in the network request process; and the class pointed to by the Isa pointer is determined to be the metaclass of the class corresponding to the method used in the network request process.

[0048] After determining the metaclass of the class corresponding to the method used in the network request process, in step 104, the method of the metaclass can be replaced with a preset network monitoring method, so that the application can use the preset network monitoring method to perform network monitoring during the network request process. The preset network monitoring method can call back the method of the metaclass after performing network monitoring, ensuring the closed loop of the original network request process.

[0049] In this embodiment, by determining the metaclass of the class of the method used in the network request process, and replacing the method of the metaclass with a preset network monitoring method, the application can use the preset network monitoring method to monitor the network request process during execution, thus achieving network monitoring of the entire network request process. Since the metaclass is a class of classes, containing all classes corresponding to all methods used in the network request process, this network monitoring method does not require traversing all classes corresponding to the methods used in the network request process to perform network monitoring on the application, which helps improve network monitoring efficiency.

[0050] The network monitoring method provided in this embodiment can dynamically insert code into a specified method (i.e., a preset network monitoring method) at runtime, thereby realizing Aspect-Oriented Programming (AOP).

[0051] In this application embodiment, the specific implementation of replacing the metaclass method with a preset network monitoring method is not limited. In some embodiments, such as Figure 3 As shown in step 304, a preset network monitoring method can be added to the application using hook technology. Among these, Figure 3 For a description of steps 301-303 above, please refer to the above. Figure 1 The relevant content will not be repeated here.

[0052] Furthermore, in step 305, a preset network monitoring method can be registered to the metaclass; and in step 306, the function bodies of the metaclass method and the preset network monitoring method are exchanged through method swizzling, thereby allowing the preset network monitoring method to replace the metaclass method. The preset network monitoring method can call back the metaclass method after completing network monitoring, thus closing the loop of the original network request process and ensuring its normal operation.

[0053] In some embodiments, the IMP pointers corresponding to the function bodies of the metaclass method and the preset network monitoring method can be swapped using the method swizzling method, thereby swapping the function bodies of the metaclass method and the preset network monitoring method.

[0054] After replacing the metaclass method with a preset network monitoring method, the application can perform network monitoring during the network request process using the preset network request method. In this embodiment, the specific implementation of the preset network monitoring method is not limited. In some embodiments, the preset network monitoring method can be implemented to obtain the execution time of each network request stage during the network request process; that is, the preset network monitoring method can be implemented to obtain the start time and end time of each network request stage, etc. In other embodiments, the network monitoring method for the network request response stage can be implemented to obtain the response data of the network request and perform security verification on the response data, etc.

[0055] It should be noted that the execution subject of each step of the method provided in the above embodiments can be the same device, or the method can be executed by different devices. For example, the execution subject of steps 101 and 102 can be device A; or the execution subject of step 101 can be device A, and the execution subject of step 102 can be device B; and so on.

[0056] Furthermore, some processes described in the above embodiments and accompanying drawings include multiple operations that appear in a specific order. However, it should be clearly understood that these operations may not be executed in the order they appear herein, or they may be executed in parallel. The operation numbers, such as 101, 102, etc., are merely used to distinguish different operations and do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel.

[0057] Accordingly, embodiments of this application also provide a computer-readable storage medium storing computer instructions, which, when executed by one or more processors, cause one or more processors to perform the steps in the network monitoring method described above.

[0058] This application also provides a computer program product, including: a computer program; when the computer program is executed by a processor, it causes the processor to perform the steps in the above-described network monitoring method. In this application, the specific implementation of the computer program product is not limited. In some embodiments, the computer program product may be implemented as a software functional module or plug-in, etc., and the computer program product may be integrated into an application to perform network monitoring on the application. Regarding the implementation of the application, please refer to the relevant content of the above embodiments, which will not be repeated here.

[0059] Figure 4 This is a schematic diagram of the network monitoring device provided in an embodiment of this application. Figure 4 As shown, the network monitoring device may include: a first determining module 40a, a second determining module 40b, a third determining module 40c, and a replacement module 40d.

[0060] The first determining module 40a is used to determine the method used by the application in the network request process.

[0061] The second determining module 40b is used to determine the class corresponding to the method used in the network request process.

[0062] The third determination module 40c is used to determine the metaclass of the class corresponding to the method based on the class corresponding to the method.

[0063] Replacement module 40d is used to replace the metaclass method with a preset network monitoring method, so that the application can use the preset network monitoring method to perform network monitoring during the network request execution process; wherein, after the preset network monitoring method performs network monitoring, it calls back the metaclass method.

[0064] In some embodiments, the first determining module 40a, when determining the method used by the application in the network request process, is specifically configured to: determine the method used by the network request process based on the description information of the pre-set application interface; or, in response to a setting operation for a method configuration item corresponding to the network request process, determine that the method associated with the setting operation is the method used by the network request process.

[0065] In other embodiments, when determining the class corresponding to the method used in the network request process, the second determining module 40b is specifically used to: determine the class corresponding to the method used in the network request process according to the preset correspondence between methods and classes.

[0066] In some other embodiments, when determining the metaclass of the class corresponding to the method, the third determining module 40c is specifically used to: run the class corresponding to the method using the runtime mechanism to obtain the class pointed to by the Isa pointer in the class corresponding to the method; and determine the class pointed to by the Isa pointer as the metaclass of the class corresponding to the method.

[0067] Optionally, when replacing the metaclass method with a preset network monitoring method, the replacement module 40d is specifically used to: add the preset network monitoring method to the application using hook technology; register the preset network monitoring method to the metaclass; and exchange the function bodies of the metaclass method and the preset network monitoring method through method interaction methods, so that the preset network monitoring method replaces the metaclass method.

[0068] Furthermore, when the replacement module 40d exchanges the function bodies of the metaclass method and the preset network monitoring method through the method interaction method, it is specifically used to: exchange the IMP pointers corresponding to the function bodies of the metaclass method and the preset network monitoring method through the method interaction method, so as to exchange the function bodies of the metaclass method and the preset network monitoring method.

[0069] The network monitoring device provided in this application embodiment can determine the metaclass of the class of the method used in the network request process, and replace the method of the metaclass with a preset network monitoring method. In this way, the application can use the preset network monitoring method to monitor the network request process during execution, thus achieving network monitoring of the entire network request process. Since the metaclass is a class of classes, containing all classes corresponding to all methods used in the network request process, this network monitoring method does not need to traverse all classes corresponding to the methods used in the network request process to perform network monitoring on the application, which helps improve network monitoring efficiency.

[0070] Figure 5This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The specific implementation of the electronic device is not limited in this embodiment. In some embodiments, the electronic device may be a terminal device such as a computer, mobile phone, or wearable device; it may also be a single server, or a cloud-based server array, etc.

[0071] like Figure 5 As shown, the electronic device may include a memory 50a and a processor 50b. The memory 50a is used to store computer programs.

[0072] The processor 50b is coupled to the memory 50a and is used to execute a computer program for: determining the method used by the application in the network request process; determining the class corresponding to the method used in the network request process; determining the metaclass of the class corresponding to the method based on the class corresponding to the method; and replacing the method of the metaclass with a preset network monitoring method so that the application performs network monitoring by using the preset network monitoring method when performing the network request process; wherein the preset network monitoring method calls back the method of the metaclass after performing network monitoring.

[0073] In some embodiments, when determining the method used by the application in the network request process, the processor 50b is specifically configured to: determine the method used by the network request process based on the description information of the pre-set application interface; or, in response to a setting operation for a method configuration item corresponding to the network request process, determine that the method associated with the setting operation is the method used by the network request process.

[0074] In other embodiments, when determining the class corresponding to the method used in the network request process, the processor 50b is specifically configured to: determine the class corresponding to the method used in the network request process based on a preset correspondence between methods and classes.

[0075] In some other embodiments, when determining the metaclass of the class corresponding to the method, the processor 50b is specifically configured to: run the class corresponding to the method using a runtime mechanism to obtain the class pointed to by the Isa pointer in the class corresponding to the method; and determine that the class pointed to by the Isa pointer is the metaclass of the class corresponding to the method.

[0076] Optionally, when replacing the metaclass method with a preset network monitoring method, the processor 50b specifically performs the following: adding the preset network monitoring method to the application using hook technology; registering the preset network monitoring method to the metaclass; and exchanging the function bodies of the metaclass method and the preset network monitoring method through method interaction methods, so that the preset network monitoring method replaces the metaclass method.

[0077] Furthermore, when the processor 50b exchanges the function bodies of the metaclass method and the preset network monitoring method through the method interaction method, it specifically uses the method interaction method to exchange the IMP pointers corresponding to the function bodies of the metaclass method and the preset network monitoring method, so as to exchange the function bodies of the metaclass method and the preset network monitoring method.

[0078] In some alternative implementations, such as Figure 5 As shown, the electronic device may also include components such as a communication component 50c, a power supply component 50d, a display component 50e, and an audio component 50f. Figure 5 The diagram only shows some components and does not mean that the electronic device must contain them. Figure 5 The fact that all components are shown does not mean that an electronic device can only include... Figure 5 The components shown.

[0079] The electronic device provided in this application embodiment can determine the metaclass of the class of the method used in the network request process, and replace the method of the metaclass with a preset network monitoring method. In this way, the application can use the preset network monitoring method to monitor the network request process during execution, thus achieving network monitoring of the entire network request process. Since the metaclass is a class of classes, containing all classes corresponding to all methods used in the network request process, this network monitoring method does not need to traverse all classes corresponding to the methods used in the network request process, which helps to improve network monitoring efficiency.

[0080] In this embodiment, the memory is used to store computer programs and can be configured to store various other data to support operation on its host device. The processor can execute the computer programs stored in the memory to implement corresponding control logic. The memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.

[0081] In the embodiments of this application, the processor can be any hardware processing device capable of executing the above-described method logic. Optionally, the processor can be a central processing unit (CPU), a graphics processing unit (GPU), or a microcontroller unit (MCU); it can also be a field-programmable gate array (FPGA), a programmable array logic (PAL), a general array logic (GAL), a complex programmable logic device (CPLD), or other programmable devices; or it can be an advanced reduced instruction set (RISC) processor (ARM) or a system on chip (SOC), etc., but is not limited thereto.

[0082] In this embodiment, the communication component is configured to facilitate wired or wireless communication between its host device and other devices. The device housing the communication component can access wireless networks based on communication standards, such as WiFi, 2G or 3G, 4G, 5G, or combinations thereof. In one exemplary embodiment, the communication component receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In another exemplary embodiment, the communication component may also be implemented based on Near Field Communication (NFC), Radio Frequency Identification (RFID), Infrared Data Association (IrDA), Ultra Wideband (UWB), Bluetooth (BT), or other technologies.

[0083] In embodiments of this application, the display component may include a liquid crystal display (LCD) and a touch panel (TP). If the display component includes a touch panel, the display component may be implemented as a touchscreen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may not only sense the boundaries of touch or swipe actions but also detect the duration and pressure associated with the touch or swipe operation.

[0084] In this embodiment, a power supply component is configured to provide power to various components of the device in which it resides. The power supply component may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device in which the power supply component resides.

[0085] In embodiments of this application, the audio component can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC), which is configured to receive external audio signals when the device containing the audio component is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals can be further stored in memory or transmitted via a communication component. In some embodiments, the audio component also includes a speaker for outputting audio signals. For example, in devices with voice interaction capabilities, voice interaction with the user can be achieved through the audio component.

[0086] It should be noted that the terms "first" and "second" in this article are used to distinguish different messages, devices, modules, etc., and do not represent a chronological order, nor do they limit "first" and "second" to different types.

[0087] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0088] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0089] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0090] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0091] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0092] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0093] Computer storage media are readable storage media, also known as removable media. Removable and non-removable media can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media do not include transient media, such as modulated data signals and carrier waves.

[0094] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0095] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A network monitoring method characterized by, The method comprises the following steps: determining the method used by the application in the network request process; determining the class corresponding to the method used by the network request process; determining the metaclass of the class corresponding to the method according to the class corresponding to the method; replacing the method of the metaclass with a preset network monitoring method, so that the application performs network monitoring using the preset network monitoring method during the network request process; wherein the method of the metaclass is called after the network monitoring method is performed; wherein the method used by the application in the network request process comprises: performing semantic analysis on the description information of the pre-set API to determine the purpose of the API corresponding method; and determining the method used by the application in the network request process as the method used for the network request process; determining the metaclass of the class corresponding to the method according to the class corresponding to the method, comprising: running the class corresponding to the method using the runtime mechanism to obtain the class pointed to by the Isa pointer in the class corresponding to the method; determining the class pointed to by the Isa pointer as the metaclass of the class corresponding to the method; the method of replacing the method of the metaclass with a preset network monitoring method, comprising: adding a preset network monitoring method to the application using hook technology; registering the preset network monitoring method in the metaclass; exchanging the function body of the method of the metaclass and the preset network monitoring method through method interaction method, so as to replace the method of the metaclass with the preset network monitoring method.

2. The method of claim 1, wherein, The method used by the application in the network request process comprises: determining the class corresponding to the method used by the network request process according to the correspondence between the preset method and the class.

3. The method of claim 1, wherein, The method of exchanging the function body of the method of the metaclass and the preset network monitoring method through method interaction method comprises: exchanging the IMP pointer corresponding to the function body of the method of the metaclass and the preset network monitoring method through method interaction method, so as to exchange the function body of the method of the metaclass and the preset network monitoring method.

4. The method according to any one of claims 1 to 3, characterized in that, The method used by the application in the network request process further comprises: in response to the setting operation of the method configuration item corresponding to the network request process, determining the method associated with the setting operation as the method used by the network request process.

5. A network monitoring device, characterized by The method comprises: a first determining module for determining the method used by the application in the network request process; a second determining module for determining the class corresponding to the method used by the network request process; a third determining module for determining the metaclass of the class corresponding to the method according to the class corresponding to the method; a replacement module for replacing the method of the metaclass with a preset network monitoring method, so that the application performs network monitoring using the preset network monitoring method during the network request process; wherein the method of the metaclass is called after the network monitoring method is performed; the first determining module is specifically used for: performing semantic analysis on the description information of the pre-set API to determine the purpose of the API corresponding method; and determining the method used by the application in the network request process as the method used for the network request process. The third determining module is specifically configured to: run a class corresponding to a method by using a runtime mechanism, to obtain a class pointed to by an Isa pointer in the class corresponding to the method; and determine that the class pointed to by the Isa pointer is a meta-class of the class corresponding to the method. The replacing module is specifically configured to: add a preset network monitoring method in the application program by using a hook technology; register the preset network monitoring method to a meta-class; and exchange a function body of the preset network monitoring method and a method of the meta-class by a method interaction method, to replace the method of the meta-class with the preset network monitoring method.

6. An electronic device, comprising: The computer program product comprises: a memory and a processor; wherein the memory is configured to store a computer program; the processor is coupled to the memory and is configured to execute the computer program to perform the steps in the method of any one of claims 1-4.

7. A computer readable storage medium having stored thereon computer instructions, wherein, The computer program product comprises:

8. A computer program product, characterised in that, a computer program; when the computer program is executed by a processor, the processor is caused to perform the steps in the method of any one of claims 1-4. ​

Citation Information

Patent Citations

  • Monitoring method, monitoring device, monitoring device and storage medium

    CN107291598A

  • Network performance parameter collection method, terminal device and memory medium

    CN108809763A