An application data acquisition method, apparatus, computer equipment, and storage medium
Patent Information
- Application Number
- CN202210866756.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-22
- Publication Date
- 2026-09-01
- Estimated Expiration
- 2042-07-22
AI Technical Summary
[0004]现有的对应用程序源码进行改动的方式均为人工配置,在面对大量的应用程序时,人工配置方式的工作量增加,配置效率降低,同时,需要额外的开发与维护成本,增加了监控数据采集的成本
[0019]本发明实施例通过对应用程序进行检测,在检测到属于目标应用的初始进程启动时,加载探针模块,通过探针模块在初始进程的目标函数中注入回调函数,更新目标函数,而后通过目标应用调用更新后的目标函数,并基于回调函数,将目标函数的监控数据发送至探针模块中,使探针模块将监控数据上报至服务器,通过在检测到属于目标应用的初始进程启动时自动加载探针模块,对程序代码段进行改动,也就是更新目标函数,从而实现在目标函数中自动部署回调信息,进而基于回调信息获取监控数据,解决了现有技术中,通过人工部署回调信息时,工作量大,效率低,成本高的问题,可以降低部署回调信息的人工成本,提高部署回调信息的效率,从而提高目标应用的监控数据采集的效率。
Smart Images

Figure CN115237713B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of data acquisition, and in particular to an application data acquisition method, apparatus, computer equipment, and storage medium. Background Technology
[0002] A probe is a source code package written in a programming language, provided as an SDK (Software Development Kit), used to obtain application monitoring data.
[0003] Currently, introducing probe source code into an application requires modifying the application source code and re-parsening the modified application source code to adapt it to the probe source code and achieve monitoring data collection.
[0004] Existing methods for modifying application source code all involve manual configuration. When dealing with a large number of applications, manual configuration increases the workload and reduces the efficiency of configuration. At the same time, it requires additional development and maintenance costs, which increases the cost of monitoring data collection. Summary of the Invention
[0005] This invention provides an application data acquisition method, apparatus, computer device, and storage medium that can automatically load a probe module when the initial process of a target application is detected to be starting, thereby updating the target function, reducing the manual cost of updating the target function, improving the efficiency of updating the target function, and thus improving the efficiency of monitoring data acquisition for the target application.
[0006] In a first aspect, embodiments of the present invention provide an application data acquisition method, including:
[0007] The probe module is loaded when the initial process belonging to the target application is detected to be starting.
[0008] The probe module adds callback information to the target function of the initial process, thereby updating the target function.
[0009] The updated target function is invoked by the target application, and based on the callback information, the monitoring data of the target application is sent to the probe module.
[0010] The monitoring data is reported to the server through the probe module.
[0011] Secondly, embodiments of the present invention provide an application data acquisition device, comprising:
[0012] The probe loading module is used to load the probe module when the initial process belonging to the target application is detected to be starting.
[0013] The function update module is used to add callback information to the target function of the initial process through the probe module, and update the target function.
[0014] The data sending module is used to call the updated target function through the target application and send the monitoring data of the target application to the probe module based on the callback information;
[0015] The data reporting module is used to report the monitoring data to the server through the probe module.
[0016] Thirdly, embodiments of the present invention also provide an apparatus, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the application data acquisition method as described in any of the embodiments of the present invention.
[0017] Fourthly, embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the application data acquisition method as described in any of the embodiments of the present invention.
[0018] Fifthly, embodiments of the present invention also provide a computer program product, the computer program product including a computer program, which, when executed by a processor, implements the application data acquisition method described in any embodiment of the present invention.
[0019] This invention, through application detection, loads a probe module when the initial process of a target application is detected to be starting. The probe module injects a callback function into the target function of the initial process, updating the target function. The target application then calls the updated target function, and based on the callback function, sends monitoring data from the target function to the probe module, which then reports the monitoring data to the server. By automatically loading the probe module when the initial process of a target application is detected to be starting, and modifying the program code segment (i.e., updating the target function), callback information is automatically deployed in the target function. Monitoring data is then obtained based on this callback information. This solves the problems of high workload, low efficiency, and high cost associated with manual deployment of callback information in existing technologies. It reduces the manual cost of deploying callback information, improves the efficiency of deploying callback information, and thus improves the efficiency of monitoring data collection for the target application. Attached Figure Description
[0020] Figure 1 This is a flowchart of an application data acquisition method according to Embodiment 1 of the present invention;
[0021] Figure 2 This is a flowchart of an application data acquisition method according to Embodiment 2 of the present invention;
[0022] Figure 3a This is a flowchart of an application data acquisition method according to Embodiment 3 of the present invention;
[0023] Figure 3b This is a flowchart of an application data acquisition method according to Embodiment 3 of the present invention;
[0024] Figure 4 This is a flowchart of an application data acquisition method according to Embodiment 4 of the present invention;
[0025] Figure 5 This is a schematic diagram of the structure of an application data acquisition device according to Embodiment 5 of the present invention;
[0026] Figure 6 This is a schematic diagram of the structure of a computer device according to Embodiment Six of the present invention. Detailed Implementation
[0027] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present invention, and not all of the structures.
[0028] Example 1
[0029] Figure 1 This is a flowchart of an application data acquisition method according to Embodiment 1 of the present invention. This embodiment is applicable to situations where application data is acquired via probes. The method can be executed by the application data acquisition device provided in this embodiment of the invention. This device can be implemented in software and / or hardware, and is generally integrated into computer equipment, such as terminal devices or servers. Figure 1 As shown, the method in this embodiment specifically includes:
[0030] S110, when the initial process belonging to the target application is detected to be starting, the probe module is loaded.
[0031] The target application refers to the application that needs to collect monitoring data. For example, the target application could be a video application, news application, music application, or browser application. Optionally, the target application is an application written in the Go programming language. Specifically, Go is a statically typed, compiled, concurrent programming language with garbage collection.
[0032] The application can be a client program or a server program. In this embodiment of the invention, the application refers to a program deployed on a server, i.e., a server program. Multiple applications can be deployed on a single server, each deployed in a different container; or only one application can be deployed on a single server.
[0033] Typically, during application startup: the processor first loads the process loader, which loads all the modules the application depends on into memory. Then, the application can process received access requests, or call other applications to obtain responses and feedback.
[0034] The initial process refers to the process started by the target application. It's understood that the initial process is released after the target application finishes execution. The probe module is used to update the target function and obtain monitoring data for the updated target function, sending the monitoring data to the server so that the server can perform performance evaluation on the target application.
[0035] Specifically, when the application starts, the probe loading module detects the application's process. If the application's process is detected as belonging to the initial process of the target application, the probe module is loaded; if the application's process is detected as not belonging to the initial process of the target application, the probe module is not loaded.
[0036] S120, The probe module adds callback information to the target function of the initial process and updates the target function.
[0037] The target function refers to the function that needs to be monitored during the initial process of the target application. It can also be understood as the function that needs to collect data during the initial process of the target application. In this embodiment, calling the target function can be done by executing the executable file corresponding to the initial process. An executable file is a file that can be loaded and executed by the operating system. By executing the executable file corresponding to the initial process, the functionality of the target application can be achieved, that is, the target application can run. An executable file (Executable and Linkable Format, ELF) consists of four parts: ELF header, program header table, section, and section header table. Callback information refers to the code segment that instructs the target function to feed back monitoring data to the probe module. Callback information can be a callback function or jump code. A callback function is a code segment that instructs the target function to feed back monitoring data to the probe module. For example, a callback function can be a function that includes parameters for calling the target function and a return value. The callback function can monitor the application's operational behavior and obtain operational behavior data to send to the server so that the server can perform performance evaluation on the application. Jump code refers to a segment of executable memory allocated during the initial execution of a process. Specifically, the probe module allocates a segment of memory with execution permissions for the target function, writes a code segment into that memory to form jump code, and uses the jump code to call the target function and report monitoring data back to the probe module. Jump code can include: calling a pre-callback function containing the target function's parameters; calling the target function; and calling a post-callback function containing the target function's parameters and return value, i.e., the callback function.
[0038] Specifically, the probe module adds callback information to the target function of the initial process based on the callback information to form a new target function, thereby updating the target function.
[0039] Optionally, the target function includes a function that processes HTTP requests, the callback information includes pre-callback information and post-callback information, and the monitoring data includes response time.
[0040] HTTP (Hypertext Transfer Protocol) is a simple request-response protocol. It specifies what messages a client might send to a server and what kind of response it might receive. An HTTP request is an access request sent via HTTP. A function that handles an HTTP request is a function that instructs the initial process of the target application to process the HTTP request. Pre-callback information refers to the information called back before the target function executes; for example, pre-callback information could be a pre-callback function containing the target function's parameters. Post-callback information refers to the information called back after the target function executes; for example, post-callback information could be a post-callback function containing the target function's parameters and return value. Response time refers to the time required for the initial process to execute the function that handles the HTTP request. For example, pre-callback information could mark the start time of the target function's execution, post-callback information could mark the completion time of the target function's execution, and the response time is the difference between the completion time of the target function in the post-callback information and the start time of the target function in the pre-callback information.
[0041] By using the preceding and following callback information included in the callback information, the start and end times of the target function's execution can be accurately obtained, thus yielding the response time. This improves the accuracy of response time determination in monitoring data, thereby enhancing the overall accuracy of monitoring data acquisition.
[0042] S130, the updated target function is called through the target application, and the monitoring data of the target application is sent to the probe module based on the callback information.
[0043] Monitoring data is used to describe the operation of the target application. Specifically, monitoring data may include parameter data of the objective function, and data on the operational behavior of the application during operation. Monitoring data may also include statistical data obtained from statistical analysis of the operational behavior data.
[0044] Specifically, the target application in the processor calls the updated target function. During the execution of the updated target function, monitoring data is obtained based on the callback information and sent to the probe module. For example, when the callback information includes pre-callback information and post-callback information, when the target application calls the updated target function, it first sends monitoring data to the probe module based on the pre-callback information, then executes the original target function, and finally sends monitoring data to the probe module based on the post-callback information.
[0045] S140, the monitoring data is reported to the server through the probe module.
[0046] Specifically, the probe module sends the monitoring data obtained by executing the updated target function to the server.
[0047] This invention, through application detection, loads a probe module when the initial process of a target application is detected to be starting. The probe module adds callback information to the target function of the initial process, updating the target function. The target application then calls the updated target function, and based on the callback information, sends monitoring data of the target function to the probe module, which then reports the monitoring data to the server. By automatically loading the probe module when the initial process of a target application is detected to be starting, and modifying the program code segment (i.e., updating the target function), callback information is automatically deployed in the target function. Monitoring data is then obtained based on this callback information. This solves the problems of high workload, low efficiency, and high cost associated with manually deploying callback information in existing technologies. It reduces the manual cost of deploying callback information, improves the efficiency of deploying callback information, and thus improves the efficiency of monitoring data collection for the target application.
[0048] Example 2
[0049] Figure 2 This is a flowchart of an application data acquisition method according to Embodiment 2 of the present invention. Based on the above embodiment, this embodiment specifies the addition of callback information to the target function of the initial process via the probe module as follows: The probe module obtains candidate functions and function information associated with the initial process; the probe module determines the target function from each candidate function and determines the location information of the target function from the function information, the target function corresponding to the monitoring data; the probe module determines the addition position based on the location information of the target function, the addition position corresponding to the monitoring data; the probe module adds the callback information at the addition position. Figure 2 As shown, the method in this embodiment specifically includes:
[0050] S210, when the initial process belonging to the target application is detected to be starting, the probe module is loaded.
[0051] S220, the probe module obtains the candidate functions and function information associated with the initial process.
[0052] A candidate function refers to a function that can be executed in the initial process of the target application. At least one candidate function can be associated with the initial process of the target application. It is understood that the initial process can contain multiple candidate functions, and the target application can determine the function to be executed from among the candidate functions based on the received access request. Function information refers to information describing each candidate function in the initial process. This function information may include at least one of the following: name, location information, identifier, and type.
[0053] Specifically, the probe module can obtain the executable files corresponding to the candidate functions associated with the initial process, and obtain the information of the candidate functions based on the executable files corresponding to the candidate functions to form function information.
[0054] S230, the probe module determines the target function from the candidate functions and determines the location information of the target function from the function information, wherein the target function corresponds to the monitoring data.
[0055] Location information refers to the offset address of the target function within the executable file. For example, an application's executable file might contain a section named ".symtab" that includes the names and location information of all functions within the executable file.
[0056] Specifically, within the application's process, the executable file is parsed to obtain the names and location information of all functions within the executable file. From this, the location information corresponding to the target function is determined, which is the offset address of the target function. The target function corresponds to the monitoring data, meaning the monitoring data is the data sent by the target function to the probe module. For example, when the target function is "net / http.serverHandler.ServeHTTP", the monitoring data is the response time of the "net / http.serverHandler.ServeHTTP" function.
[0057] S240, the probe module determines the addition location based on the positioning information of the target function, and the addition location corresponds to the monitoring data.
[0058] The addition location refers to the position where callback information is added within the target function of the target process; it can also be understood as the memory address of the callback function within the target function. Here, the target process refers to the process in which the target function resides. Specifically, the probe module determines the addition location of the callback information within the target function based on its location information. For example, the target function's location information is its file offset address within the executable file. By adding the target function's offset address to the process's base address, the addition location is determined as the memory address of the target function during the actual execution of the target process.
[0059] Specifically, the probe module determines the location to add callback information within the target function based on its location information. This location corresponds to the monitoring data, meaning the probe module retrieves the monitoring data from this location. For example, the callback information might be a jump server code, the monitoring data might be the response time of the "net / http.serverHandler.ServeHTTP" function, and the addition location might be the first line of code in the "net / http.serverHandler.ServeHTTP" function. The probe module modifies this first line of code to redirect to the address of the jump server code. In other words, when the target program executes the first line of code in the "net / http.serverHandler.ServeHTTP" function, it jumps to the jump server code, thus sending monitoring data to the probe module based on the callback function.
[0060] S250, the callback information is added at the addition location by the probe module.
[0061] Specifically, the probe module adds callback information at the addition location in the target function to update the target function.
[0062] S260, the updated target function is called through the target application, and the monitoring data of the target application is sent to the probe module based on the callback information.
[0063] S270, the monitoring data is reported to the server through the probe module.
[0064] The technical solution of this invention obtains candidate functions and function information associated with the initial process through a probe module. It then determines the location information of the target function among the candidate functions based on the function information, determines the addition position of callback information based on the target function's location information, and adds the callback information. This eliminates the need for manual configuration to update the target function, enabling automatic addition of callback information. Determining the addition position of callback information based on the target function's location information improves the accuracy of callback information addition. The addition position corresponds to the monitoring data, meaning that the addition position is adaptively adjusted for different monitoring functions, enabling the acquisition of various monitoring data and improving the flexibility of the probe module, thereby enhancing the flexibility of application data collection.
[0065] Example 3
[0066] Figure 3aThis is a flowchart of an application data acquisition method according to Embodiment 3 of the present invention. Based on the above embodiments, this embodiment specifies the detection of the initial process startup belonging to the target application as follows: when a candidate process startup is detected, the executable file of the candidate process is obtained; the executable file is parsed to obtain parsed data; and if the header table of the parsed data includes specified information, the initial process startup belonging to the target application is determined. Figure 3a As shown, the method in this embodiment specifically includes:
[0067] S310, if the startup of the alternative process is detected, the executable file of the alternative process is obtained.
[0068] Alternate processes are processes contained within an application. An application can contain at least one alternate process, each corresponding to an executable file. When the application receives an access request, the alternate process calls the corresponding executable file to respond to the access request.
[0069] Specifically, when an application starts, the processor loads a backup process, and when the backup process is detected to be running, it obtains the executable file used to run the backup process.
[0070] S320, the executable file is parsed to obtain parsed data.
[0071] Parsed data refers to the data obtained after parsing an executable file. By parsing the data, the contents of the ELF header, program header table, sections, and section header table within the executable file can be obtained.
[0072] Specifically, when the processor detects that a candidate process has started, it parses the executable file of the started candidate process to obtain the parsed data.
[0073] S330, if the header table of the parsed data includes specified information, determine that the initial process of the target application is started.
[0074] Specified information refers to the information used to determine if a candidate process is the initial process of the target application. Specified information includes at least one item. If any item of the specified information is present in the section header table of the executable file in the parsed data, it is determined that the section header table of the executable file in the parsed data includes the specified information. The specified information is determined based on the target application; different target applications require different specified information.
[0075] Specifically, by traversing the data of the executable file's header table in the parsed data, if the data of the executable file's header table in the parsed data contains the specified information, it is determined that the initial process of the target application has started; if the data of the executable file's header table in the parsed data does not contain the specified information, it is determined that the initial process of the target application has not started.
[0076] For example, the initial process of the target application is the initial process of a Golang application, and the specified information is the section name ".gopclntab", ".note.go.buildid", and ".gosymtab". The data in the executable file's section header table is traversed and parsed. If any one of the section names ".gopclntab", ".note.go.buildid", or ".gosymtab" exists in the section header table, it is determined that the initial process of the target application has started; if the specified information does not exist in the section header table, it is determined that the initial process of the target application has not started.
[0077] S340 loads the probe module when it detects the initial process startup belonging to the target application.
[0078] S350, The probe module adds callback information to the target function of the initial process and updates the target function.
[0079] S360, the target application calls the updated target function, and based on the callback information, sends the monitoring data of the target application to the probe module.
[0080] S370, the monitoring data is reported to the server through the probe module.
[0081] This invention improves the accuracy of determining the initial process startup of a target application by obtaining the executable file of the candidate process when the startup of the candidate process is detected, and determining whether the data in the section header table of the executable file in the parsed data obtained after parsing the executable file contains specified information. If the specified information is contained, it is determined that the startup of the target application's initial process is the one that started.
[0082] Based on the above embodiments, the detection of the initial process startup belonging to the target application includes: loading a process loader module when a candidate process startup is detected; loading a pre-loading module through the process loader module; and detecting the initial process startup belonging to the target application through the pre-loading module.
[0083] The process loader module specifically refers to a general-purpose module in the operating system used to load programs and dynamic libraries. It is the first module loaded after an application starts, responsible for mapping application-related files from file format to memory, loading corresponding dependent modules, initializing executable modules, initializing the environment required by the application, and finally calling the program entry point (the main function) to perform the actual work. A preloaded module refers to an application that is loaded preferentially during the process loader module's application loading process. Preloaded modules can identify the initial process of the target application. Typically, preloaded modules run after the process loader module.
[0084] Specifically, preloaded modules can be specified through a configuration file before the application runs. When the process loader module loads the application, it first inserts the specified preloaded module into the module table, followed by other modules the application depends on. The preloaded module always appears after the process loader module in the module table. When the application runs, if a candidate process is detected, the process loader module loads it. The process loader module then loads the preloaded module, which detects the candidate processes and identifies the initial process belonging to the target application. For example, the preloaded module parses the executable file in the initial process, obtaining parsed data. If the executable file's header table contains specified information, it determines that the initial process belongs to the target application.
[0085] By loading the process loader module when a candidate process is detected to be starting, loading the preload module through the process loader module, and detecting the initial process startup of the target application through the preload module, the accuracy of the detection of the initial process startup of the target application can be guaranteed. The process loader is a general module used to load programs and dynamic libraries. Loading the preload module on the basis of the process loader can ensure the accuracy of the detection of the initial process startup of the target application.
[0086] In a specific example, such as Figure 3b As shown, application data acquisition methods may include:
[0087] S3001, when a candidate process is detected to be starting, the processor loads the process loader module.
[0088] S3002, the preload module is loaded through the process loader module.
[0089] The preloading module is used to detect applications written in Go. In this embodiment, the operating system is Linux, and the agentloader module can be set as a preloading module using Linux Preload technology. Typically, the preloading module runs after the process loader module.
[0090] S3003, the preloading module detects the initial process startup of the target application.
[0091] The target application is an application written in the Go language, and the initial process of the target application is the initial process of the application written in the Go language, which can also be called the Golang application process.
[0092] Specifically, the preloading module obtains the executable file of the candidate process, parses the executable file to obtain parsed data. If the data in the section header table of the executable file in the parsed data includes specified information, it determines that the initial process of the target application is being started. For example, the preloading module traverses the section header table data of the executable file in the parsed data. If the section header table contains any of the following names: ".gopclntab", ".note.go.buildid", or ".gosymtab", it indicates that the current process is a Golang application process, which is the initial process of the target application.
[0093] S3004: When the processor detects the initial startup of a process belonging to the target application, it loads the probe module.
[0094] The probe module is used to monitor the target function. For example, the probe module can be the agentgo module, and the target function to monitor is the net / http.serverHandler.ServeHTTP function.
[0095] S3005, The probe module adds callback information to the target function of the initial process and updates the target function.
[0096] Specifically, the probe module obtains the candidate functions and function information associated with the initial process, determines the target function from each candidate function, determines the location information of the target function from the function information of the candidate functions, determines the addition position based on the location information of the target function, and adds the callback information at the addition position.
[0097] For example, callback information includes both preceding and following callback information. The location to add is the target function.
[0098] S3006, when the initial process of the target application receives an HTTP access request, it calls the updated target function.
[0099] S3007, the initial process of the target application triggers the call to the pre-callback information in the probe module, which carries the parameters of the target function.
[0100] S3008 executes the target function after the callback information is executed.
[0101] S3009, after the target function is executed, triggers the callback information in the probe module, carrying the parameters and return value of the target function.
[0102] S3010, the probe module uses the data collected during the execution of the before and after callback information as monitoring data and reports it to the server.
[0103] This invention, through application detection, loads a probe module when the initial process of a target application is detected to be starting. The probe module adds callback information to the target function of the initial process, updating the target function. The target application then calls the updated target function, and based on the callback information, sends monitoring data of the target function to the probe module, which then reports the monitoring data to the server. By automatically loading the probe module when the initial process of a target application is detected to be starting, modifying the program code segment (i.e., updating the target function), and automatically adding callback information to the target function, this invention solves the problems of high workload, low efficiency, and high cost associated with manually deploying callback information in existing technologies. It reduces the manual cost of deploying callback information, improves the efficiency of deploying callback information, and thus improves the efficiency of monitoring data collection for the target application.
[0104] Example 4
[0105] Figure 4 This is a flowchart of an application data acquisition method according to Embodiment 4 of the present invention. Based on the above embodiments, this embodiment further includes: reporting to the server according to the device program identifier; receiving the probe identifier fed back by the server for the device program identifier; after loading the probe module, it further includes: receiving the probe identifier request sent by the probe module; if the probe identifier request includes the device identifier, feeding back the probe identifier to the probe module; the step of reporting the monitoring data to the server through the probe module includes: reporting the monitoring data and the probe identifier to the server through the probe module.
[0106] In this embodiment, the application can also be deployed in containers, with one application deployed per container. Different containers are separated and independent of each other. The application runs in a container environment. Therefore, a probe deployment module configured outside the container will not affect the container; that is, the probe deployment module is not configured within the container. Thus, a probe deployment module needs to be configured in the container where the application is deployed. A container system can refer to a container cluster. For example, a container system can refer to Docker. In the Linux operating system, Docker uses Linux namespaces to isolate the container's runtime environment.
[0107] like Figure 4 As shown, the method in this embodiment specifically includes:
[0108] S410 obtains the device program identifier and reports it to the server.
[0109] The device program identifier refers to the probe identifier and device identifier of the previously executed process, stored in the probe deployment module when the module starts. The device identifier specifically refers to the identifier of the computer device running the application.
[0110] When the probe deployment module detects that an application has started, it obtains the device program identifier and reports the device program identifier to the server.
[0111] S420, Receive the probe identifier fed back by the server for the device program identifier.
[0112] A probe identifier is used to identify the probe corresponding to an application. The probe identifier includes at least one of the following: process ID, container ID, and process identifier. The process ID is the identifier assigned to the application when it starts. The container ID is the identifier of the container when the application is deployed in a container. The process identifier is used to distinguish processes within the application. For example, the process identifier can be the name of the process.
[0113] Specifically, after receiving the device program identifier, the server generates a new probe identifier based on the device program identifier and sends the probe identifier back to the probe deployment module. Alternatively, after receiving the device program identifier, the server updates the device program identifier and uses the updated device program identifier as the probe identifier, sending it back to the probe deployment module.
[0114] S430 loads the probe module when it detects the initial process startup belonging to the target application.
[0115] S440, Receive probe identification request sent by the probe module.
[0116] A probe identifier request is a request that instructs the probe deployment module to send a probe identifier. Specifically, after the probe module finishes loading, it sends a probe identifier request to the probe deployment module, which then receives the request.
[0117] S450, if the probe identification request includes the device identification, the probe identification is fed back to the probe module.
[0118] Device identifiers are used to identify the computer device where an application resides. A server can receive applications from multiple computer devices; specifically, multiple applications can be deployed on a single computer device. Device identifiers are used to identify the target computer device among multiple computer devices, that is, the computer device where the target application is deployed. Here, "computer device" can refer to the hardware device on the server where the server-side program is deployed.
[0119] Specifically, the probe deployment module identifies the device identifier in the probe identifier request. Upon identifying a device identifier, the probe deployment module sends the probe identifier corresponding to the device identifier, stored in the probe deployment module, to the probe module. The probe identifier and device identifier have a correspondence, describing the relationship between the computer device corresponding to the device identifier and the application running on that computer device. Optionally, after feeding back the probe identifier to the probe module, the probe identifier and device identifier are stored as a device program identifier in the probe deployment module.
[0120] S460, The probe module adds callback information to the target function of the initial process and updates the target function.
[0121] S470, the updated target function is called through the target application, and the monitoring data of the target application is sent to the probe module based on the callback information.
[0122] S480, the monitoring data and the probe identifier are reported to the server through the probe module.
[0123] The target application calls the updated target function to generate monitoring data, which is then sent to the probe module. The probe module sends the received monitoring data, along with the probe identifier, to the server.
[0124] The technical solution of this invention achieves automatic generation of probe identifiers by acquiring device program identifiers and reporting them to the server, which then feeds back the device program identifiers to probe identifiers. This enables automatic configuration of probe modules and improves the efficiency of probe module configuration. After loading the probe module, the system receives probe identifier requests from the probe module. If the probe identifier request includes a device identifier, the system feeds back the probe identifier to the probe module. This ensures the accuracy of probe identifier feedback by first identifying the device identifier in the probe identifier request before feeding back the probe identifier, thereby improving the accuracy of the monitoring data acquired by the probe module. By having the probe module simultaneously report monitoring data and probe identifiers to the server, the server can establish a connection between the monitoring data and the probe identifiers, improving the server's management efficiency of monitoring data.
[0125] Optionally, when the application is deployed in a container, before the application is detected to start, it is first detected whether the container system is started. When the container system is detected to start, the processes associated with the container system are monitored. When the container creation process is detected, during the container creation process, the probe deployment module is configured and the directory of the access file associated with the callback information is mounted into the container.
[0126] Detecting whether a container system has started can specifically involve determining whether a process associated with the container system has appeared. If, before a certain point in time, none of the running processes included any processes associated with the container system, and after a certain point in time, there exists a running process associated with the container system, then the container system is determined to have started. The identification and detection of processes associated with the container system can be determined by the process name; for example, a process containing the container ID is considered an associated process. Alternatively, processes associated with the container system can be determined in other ways, and the appearance of a container system process can be determined in other ways as well, such as by identifying a process that starts the container system among all running processes. This starting process can refer to a process with a pre-specified name; however, this embodiment of the invention does not impose specific limitations on this.
[0127] The processes associated with a container system can refer to the processes that are running when the container system is working normally.
[0128] Specifically, an application can be pre-configured to monitor processes associated with the container system.
[0129] The processes associated with the container system are used to detect whether a new container has been created. Typically, the process of deploying and running an application in a container involves: starting the container system, creating the container, configuring the application's runtime parameters during container creation, and loading the application into the created container. Therefore, upon detecting the container creation operation, while configuring the existing runtime parameters for the application, the probe deployment module is configured as a pre-loaded module for the application process, enabling automatic loading of the probe deployment module within the container.
[0130] Optionally, detecting container system startup includes: traversing the process tree; if the process associated with the container engine container system appears for the first time in the process tree, it is determined that container system startup has been detected.
[0131] A process tree can refer to multiple running processes and the relationships between them.
[0132] The first appearance of a process associated with the container system indicates that, prior to the current moment, no process associated with the container system was among the running processes. The appearance of the container system at the current moment typically indicates that the container system has started and begun normal operation, at which point it can be confirmed that the container system has started. The first appearance of a process associated with the container system can also refer to the first appearance of a process associated with the container system within a defined time period.
[0133] By traversing the process tree and identifying the first process associated with the container system in the process tree, we can determine if the container system has started. This allows for accurate judgment of container system startup and timely monitoring of the existence of container creation processes. Consequently, when a container creation process is detected, callback information can be configured during the container creation process to ensure accurate deployment of callback information within the container.
[0134] By monitoring the processes associated with the container system when the application is running in a container, and configuring a probe deployment module during the container creation process when a container is being created, the probe deployment module is accurately deployed into the container. This allows the probe deployment module to run automatically within the container. At the same time, the directory of the access file associated with the callback information is mounted into the created container, so that the access file associated with the callback information can be accessed within the container. This achieves accurate deployment of callback information within the container.
[0135] Example 5
[0136] Figure 5 This is a schematic diagram of an application data acquisition device according to Embodiment 5 of the present invention. Embodiment 5 is a corresponding device for implementing the application data acquisition method provided in the above embodiments of the present invention. This device can be implemented in software and / or hardware, and can generally be integrated into electronic devices, such as computer devices.
[0137] Accordingly, the apparatus of this embodiment may include: a probe loading module 501, a function update module 502, a data sending module 503, and a data reporting module 504.
[0138] The probe loading module 501 is used to load the probe module when the initial process belonging to the target application is detected to be starting.
[0139] Function update module 502 is used to add callback information to the target function of the initial process through the probe module and update the target function;
[0140] The data sending module 503 is used to call the updated target function through the target application and send the monitoring data of the target application to the probe module based on the callback information;
[0141] The data reporting module 504 is used to report the monitoring data to the server through the probe module.
[0142] This invention, through application detection, loads a probe module when the initial process of a target application is detected to be starting. The probe module adds callback information to the target function of the initial process, updating the target function. The target application then calls the updated target function, and based on the callback information, sends monitoring data of the target function to the probe module, which then reports the monitoring data to the server. By automatically loading the probe module when the initial process of a target application is detected to be starting, modifying the program code segment (i.e., updating the target function), and automatically adding a callback function to the target function, monitoring data is obtained based on the callback function. This solves the problems of high workload, low efficiency, and high cost associated with manually deploying callback functions in existing technologies. It reduces the manual cost of deploying callback functions, improves the efficiency of deploying callback functions, and thus improves the efficiency of monitoring data collection for the target application.
[0143] Furthermore, the function update module 502 includes: a candidate function acquisition unit, used to acquire candidate functions and function information associated with the initial process through the probe module; a location information determination unit, used to determine a target function from each of the candidate functions through the probe module, and determine the location information of the target function from the function information, wherein the target function corresponds to the monitoring data; an addition position determination unit, used to determine an addition position based on the location information of the target function through the probe module, wherein the addition position corresponds to the monitoring data; and a callback information addition unit, used to add the callback information at the addition position through the probe module.
[0144] Furthermore, the probe loading module 501 includes: an executable file acquisition unit, used to acquire the executable file of the candidate process when the candidate process is detected to be running; a parsing unit, used to parse the executable file to obtain parsed data; and an initial process startup determination unit, used to determine the initial process startup of the target application when the header table of the parsed data includes specified information.
[0145] Furthermore, the executable file acquisition unit includes: a process loader loading subunit, used to load the process loader module when a candidate process is detected to be starting; a preload module loading subunit, used to load the preload module through the process loader module; and an initial process startup subunit, used to detect the startup of an initial process belonging to the target application through the preload module.
[0146] Furthermore, the application data acquisition device further includes: a device program identifier reporting module, used to acquire the device program identifier and report it to the server; a probe identifier receiving module, used to receive the probe identifier fed back by the server in response to the device program identifier; a probe identifier request receiving module, used to receive the probe identifier request sent by the probe module after the probe module is loaded; a probe identifier feedback module, used to feed back the probe identifier to the probe module when the probe identifier request includes the device identifier; and a data reporting module 504, specifically used to: report the monitoring data and the probe identifier to the server through the probe module.
[0147] Furthermore, the target function includes a function for processing HTTP requests, the callback information includes pre-callback information and post-callback information, and the monitoring data includes response time.
[0148] Furthermore, the target application is an application written in the Go language.
[0149] The above-mentioned application data acquisition device can execute the application data acquisition method provided in the embodiments of the present invention, and has the corresponding functional modules and beneficial effects of the executed application data acquisition method.
[0150] Example 6
[0151] Figure 6 This is a schematic diagram of the structure of a computer device provided in Embodiment Six of the present invention. Figure 6 A block diagram of an exemplary computer device 12 suitable for implementing embodiments of the present invention is shown. Figure 6 The computer device 12 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present invention.
[0152] like Figure 6As shown, the computer device 12 is represented in the form of a general-purpose computing device. Components of the computer device 12 may include, but are not limited to: one or more processors or processing units 16, system memory 28, and a bus 18 connecting different system components (including system memory 28 and processing units 16). The computer device 12 may be a device connected to a bus.
[0153] Bus 18 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. Examples of these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MCA) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.
[0154] Computer device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by computer device 12, including volatile and non-volatile media, removable and non-removable media.
[0155] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Computer device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be used to read and write non-removable, non-volatile magnetic media (…). Figure 6 Not shown; usually referred to as a "hard drive"). Although Figure 6Not shown, a disk drive for reading and writing to removable non-volatile disks (e.g., "floppy disks") and an optical disc drive for reading and writing to removable non-volatile optical discs (e.g., Compact Disc Read-Only Memory (CD-ROM), Digital Video Disc Read-Only Memory (DVD-ROM), or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. System memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of the present invention.
[0156] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28. Such program modules 42 include—but are not limited to—an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 42 typically perform the functions and / or methods described in the embodiments of the present invention.
[0157] Computer device 12 can also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), and with one or more devices that enable a user to interact with the computer device 12, and / or with any device that enables the computer device 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 22. Furthermore, computer device 12 can also communicate with one or more networks (e.g., local area network (LAN) or wide area network (WAN)) via network adapter 20. As shown, network adapter 20 communicates with other modules of computer device 12 via bus 18. It should be understood that although... Figure 6 As not shown, other hardware and / or software modules may be used in conjunction with computer device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, (Redundant Arrays of Inexpensive Disks, RAID) systems, tape drives, and data backup storage systems.
[0158] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, such as implementing an application data acquisition method provided in any embodiment of the present invention.
[0159] Example 7
[0160] Embodiment 7 of the present invention provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the application data acquisition method provided in all embodiments of the present application:
[0161] That is, when the program is executed by the processor, it performs the following: when the startup of the initial process belonging to the target application is detected, the probe module is loaded; the probe module adds callback information to the target function of the initial process and updates the target function; the target application calls the updated target function and sends the monitoring data of the target application to the probe module based on the callback information; and the probe module reports the monitoring data to the server.
[0162] The computer storage medium of this invention can be any combination of one or more computer-readable media. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection having one or more wires, a portable computer disk, a hard disk, RAM, read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable CD-ROM, optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0163] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including—but not limited to—electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of transmitting, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.
[0164] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including—but not limited to—wireless, wire, optical fiber, radio frequency (RF), etc., or any suitable combination thereof.
[0165] Computer program code for performing the operations of this invention can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as "C" or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including LANs or WANs—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0166] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.
Claims
1. A data acquisition method for applications, characterized in that, include: The probe module is loaded when the initial process belonging to the target application is detected to be starting. The probe module adds callback information to the target function of the initial process, thereby updating the target function. The updated target function is invoked by the target application, and based on the callback information, the monitoring data of the target application is sent to the probe module. The monitoring data is reported to the server through the probe module. The step of adding callback information to the target function of the initial process through the probe module includes: The probe module is used to obtain the candidate functions and function information associated with the initial process; The probe module determines the target function from the candidate functions and the location information of the target function from the function information. The target function corresponds to the monitoring data. The probe module determines the addition location based on the positioning information of the target function, and the addition location corresponds to the monitoring data. The callback information is added at the added location via the probe module. The target application is an application that needs to collect monitoring data; the location information of the target function is the file offset address of the target function in the executable file.
2. The method according to claim 1, characterized in that, The detection of the initial process startup belonging to the target application includes: If the startup of a candidate process is detected, the executable file of the candidate process is obtained; The executable file is parsed to obtain parsed data; If the header table of the parsed data includes specified information, the initial process startup belonging to the target application is determined.
3. The method according to claim 1, characterized in that, The detection of the initial process startup belonging to the target application includes: If a candidate process is detected to be running, load the process loader module; The preloaded module is loaded through the process loader module; The preloading module detects the initial process startup belonging to the target application.
4. The method according to claim 1, characterized in that, Also includes: Obtain the device program identifier and report it to the server; Receive the probe identifier fed back by the server in response to the device program identifier; After loading the probe module, the following is also included: Receive the probe identification request sent by the probe module; If the probe identification request includes a device identifier, the probe identifier is fed back to the probe module; The step of reporting the monitoring data to the server through the probe module includes: The monitoring data and the probe identifier are reported to the server through the probe module. The device identifier is the identifier of the computer device running the target application.
5. The method according to claim 1, characterized in that, The target function includes a function for processing HTTP requests, the callback information includes pre-callback information and post-callback information, and the monitoring data includes response time.
6. The method according to claim 1, characterized in that, The target application is an application written in the Go programming language.
7. An application data acquisition device, characterized in that, include: The probe loading module is used to load the probe module when the initial process belonging to the target application is detected to be starting. The function update module is used to add callback information to the target function of the initial process through the probe module, and update the target function. The data sending module is used to call the updated target function through the target application and send the monitoring data of the target application to the probe module based on the callback information; A data reporting module is used to report the monitoring data to the server through the probe module; The function update module includes: The alternative function acquisition unit is used to acquire the alternative functions and function information associated with the initial process through the probe module; The positioning information determination unit is used to determine the target function from each of the candidate functions through the probe module, and to determine the positioning information of the target function from the function information, wherein the target function corresponds to the monitoring data; An additional location determination unit is added, which is used to determine the addition location based on the positioning information of the target function through the probe module, wherein the addition location corresponds to the monitoring data; A callback information adding unit is used to add the callback information at the adding location via the probe module; The target application is an application that needs to collect monitoring data; the location information of the target function is the file offset address of the target function in the executable file.
8. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the application data acquisition method as described in any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the application data acquisition method as described in any one of claims 1-6.
Citation Information
Patent Citations
Routing data acquisition method and device, apparatus and storage medium
CN110888731A
Performance analysis method and device for storage server and electronic equipment
CN111756575A
Probe automatic deployment method, electronic equipment and storage medium
CN113157347A
Slow request monitoring method and device in Go application, equipment and medium
CN114116139A