Front-end performance monitoring method and device
By creating timers in the front-end performance monitoring and recording the key information of each execution stage, the problem of existing tools being unable to perform fine-grained monitoring is solved, enabling fine-grained monitoring of business processes and accurate location of performance bottlenecks, thus improving the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING JINGDONG YUANSHENG TECH CO LTD
- Filing Date
- 2026-02-02
- Publication Date
- 2026-05-08
AI Technical Summary
Existing front-end performance monitoring tools cannot meet the needs of granular monitoring. They cannot monitor the time consumption of each stage in the business execution process in a fine-grained manner, which makes it impossible to accurately locate performance bottlenecks and affects user experience.
By creating timers to monitor each execution stage of the business process, determining whether point tracking is needed, and performing point tracking when necessary, the point tracking information is recorded. Finally, the total duration of the timers and the point tracking information for each execution stage are reported to the monitoring system. This supports multiple timers operating in parallel and nested timers, enabling fine-grained monitoring of the business process.
It enables precise identification of performance bottlenecks in business processes, improves user experience, and meets the refined monitoring needs of front-end applications.
Smart Images

Figure CN121996512A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a front-end performance monitoring method and apparatus. Background Technology
[0002] In the field of front-end development, front-end performance monitoring is a key technology for improving the user experience of front-end applications. Related technologies mainly include browser global object interfaces, manual timestamp recording, and single timer tools. However, as the complexity of front-end applications continues to increase and business processes become increasingly intricate, the aforementioned performance monitoring tools can no longer meet the needs for granular monitoring. For example, they cannot monitor the time consumption of each stage in the business execution process with fine granularity, thus failing to accurately locate bottlenecks and hindering the improvement of user experience. Summary of the Invention
[0003] In view of this, embodiments of the present invention provide a front-end performance monitoring method and apparatus, which can realize fine-grained performance monitoring of business processes, accurately locate performance bottlenecks, and thus improve user experience.
[0004] To achieve the above objectives, according to one aspect of the present invention, a front-end performance monitoring method is provided, comprising: In response to the detection of a business process start event, a timer corresponding to the business process is created and the timer is triggered to start counting. The timer monitors each execution stage of the business process. For each execution stage, it is determined whether the execution stage needs to be marked. If it needs to be marked, the execution stage is marked to obtain the marking information of the execution stage. In response to the detected end event of the business process, the timer is triggered to stop counting, and the start and end times of the timer, as well as the tracking information for each execution stage, are reported to the monitoring system.
[0005] Optionally, the timer has a corresponding timer identifier, and determining whether the execution phase needs to be marked includes: Obtain the execution method corresponding to the execution phase and the input parameters corresponding to the execution method; Determine whether the input parameters include the timer identifier; If the timer identifier is included in the input parameters, it is determined that the execution phase needs to be marked.
[0006] Optionally, the marking information includes a first time interval and a second time interval. Marking the execution phase to obtain the marking information of the execution phase further includes: The point-marking method is invoked to mark the start node and end node of the execution phase respectively. The first time interval is calculated based on the point-marking time of the start node and the point-marking time of the previous point. The second time interval is calculated based on the point-marking time of the start node and the point-marking time of the end node.
[0007] Optionally, the marking information further includes a marking type and a stage identifier. Marking the execution stage to obtain the marking information of the execution stage further includes: obtaining the marking type corresponding to the execution stage according to the mapping relationship between the execution stage and the marking type, and obtaining the marking information according to the marking type and stage identifier of the execution stage.
[0008] Optionally, the start and end times of the timer, as well as the tracking information for each execution stage, are reported to the monitoring system, including: The total duration of the timer is obtained based on the start time and end time of the timer; For each point type, obtain the point information for each execution stage corresponding to the point type; the point information for each execution stage includes the execution duration of the execution stage; The execution time corresponding to the point type is obtained based on the execution time of each execution stage; The reporting data is created based on the total duration of the timer and the execution duration corresponding to each point type, and the reporting data is reported to the monitoring system.
[0009] Optionally, the method further includes: Obtain the sub-processes corresponding to the business process; For each sub-process, in response to the detection of the sub-process's start event, a sub-timer corresponding to the sub-process is created and triggered to start timing; the sub-timer monitors each sub-execution stage of the sub-process, and for each sub-execution stage, it is determined whether the sub-execution stage needs to be marked. If marking is required, the sub-execution stage is marked to obtain the marking information of the sub-execution stage; in response to the detection of the sub-process's end event, the sub-timer is triggered to end timing; the start and end times of the sub-timer and the marking information of each execution stage are sent to the timer so that the timer reports to the monitoring system.
[0010] Optionally, the reported data is created based on the total duration of the timer and the execution duration corresponding to each point type, including: Invoke the configured reporting function, which indicates custom parameters and reporting format; Get the parameter value corresponding to the custom parameter; The reported data is obtained by converting the total duration of the timer, the execution duration corresponding to each point type, and the parameter values according to the reporting format.
[0011] Optionally, the method further includes: The dot method is encapsulated into a decorator, and the decorator is attached to the target execution method of the business process as an annotation; In response to the start of execution of the target execution method, the decorator is used to call the dotted method and start the timer. When the target execution method ends execution, the decorator is used to call the dotted method and end the timer. The execution time of the target execution method is calculated by the start time and the end time of the timer. The execution time of the target execution method is reported to the monitoring system.
[0012] According to another aspect of the present invention, a front-end performance monitoring device is provided, comprising: Create a module that, in response to the detection of a business process start event, creates a timer corresponding to the business process and triggers the timer to start counting; The timing module monitors each execution stage of the business process through the timer. For each execution stage, it determines whether the execution stage needs to be timing. If timing is required, it timings the execution stage to obtain the timing information of the execution stage. The reporting module, in response to the listening for the end event of the business process, triggers the timer to stop counting, and reports the start and end times of the timer, as well as the point information of each execution stage, to the monitoring system.
[0013] According to another aspect of the present invention, an electronic device is provided, comprising: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the front-end performance monitoring method provided by the present invention.
[0014] According to another aspect of the present invention, a computer-readable medium is provided having a computer program stored thereon, which, when executed by a processor, implements the front-end performance monitoring method provided by the present invention.
[0015] According to another aspect of the present invention, a computer program product is provided, including a computer program that, when executed by a processor, implements the front-end performance monitoring method provided by the present invention.
[0016] One embodiment of the above invention has the following advantages or beneficial effects: The front-end performance monitoring method provided by this invention creates a timer and starts timing after monitoring the start time of a business process, listens to each execution stage in the business process, and marks the execution stages that need to be marked, obtaining the corresponding marking information. After the business process ends, the timer stops timing, and the total duration of the timer and the marking information of each execution stage are reported to the monitoring system. This method can create a corresponding timer based on the start of the business process, supports multiple timers to time in parallel, and marks the execution stages during the timer's timing process, recording the time consumed by each execution stage. This enables fine-grained monitoring of the business process, can be used for performance analysis of complex business processes, and can accurately locate performance bottlenecks in the business process, thereby improving the user experience.
[0017] The further effects of the aforementioned unconventional alternative methods will be explained below in conjunction with specific implementation methods. Attached Figure Description
[0018] The accompanying drawings are provided to better understand the invention and are not intended to unduly limit the scope of the invention. Wherein: Figure 1 This is a schematic diagram of the main process of a front-end performance monitoring method according to an embodiment of the present invention; Figure 2 This is a schematic diagram of the main process of a front-end performance monitoring method according to an embodiment of the present invention; Figure 3 This is a system architecture diagram of a front-end performance monitoring method according to an embodiment of the present invention; Figure 4 This is a schematic diagram of the main modules of the front-end performance monitoring device according to an embodiment of the present invention; Figure 5 This is an exemplary system architecture diagram in which embodiments of the present invention can be applied; Figure 6 This is a schematic diagram of the structure of a computer system suitable for implementing terminal devices or servers of the present invention. Detailed Implementation
[0019] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of the present invention, including various details to aid understanding. These details should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the invention. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0020] Existing front-end performance monitoring technologies mainly include: the browser's built-in Performance API, which provides basic metrics for page loading and rendering performance; third-party performance monitoring tools such as New Relic, which offer comprehensive performance monitoring capabilities; manual timestamp recording, where Date.now() (a Date object) is manually inserted into the code to record key time points; single timer tools such as console.time() (a timer function in JavaScript); and event tracking SDKs (Software Development Kits) that focus on user behavior statistics. However, the browser's built-in Performance API cannot monitor the time consumption of each stage in the execution of business logic with fine granularity; third-party performance monitoring tools are usually black boxes, making it difficult to customize monitoring for specific business scenarios; manual timestamp recording lacks systematicity and is difficult to manage and extend; single timer tools cannot handle parallel business scenarios; and event tracking SDKs have limited support for performance monitoring and need to be bound to specific analysis platforms.
[0021] To address the aforementioned issues, this invention provides a front-end performance monitoring method that can monitor the time consumption at each stage of the business process execution, meeting the refined monitoring needs of front-end applications, accurately locating performance bottlenecks, and thereby improving user experience.
[0022] Figure 1 This is a schematic diagram of the main flow of a front-end performance monitoring method according to an embodiment of the present invention, as shown below. Figure 1 As shown, the method includes the following steps: Step S101: In response to the detection of the business process start event, create a timer corresponding to the business process and trigger the timer to start counting; Step S102: Monitor each execution stage of the business process through a timer. For each execution stage, determine whether the execution stage needs to be marked. If it needs to be marked, mark the execution stage and obtain the mark information of the execution stage. Step S103: In response to the detected end event of the business process, trigger the timer to end the countdown, and report the start and end times of the timer, as well as the point information of each execution stage, to the monitoring system.
[0023] In this embodiment of the invention, the front-end performance monitoring method can be implemented using a timer tool. After detecting the start event of a business process, a timer corresponding to that business process is created and triggered to start counting. Each business process corresponds to one timer, and each timer has a corresponding timer identifier. The timer identifier can be automatically generated at the same time as the timer is created, and a timer data object corresponding to the timer is also created to store the timer data.
[0024] Each business process creates its corresponding timer upon startup. When multiple business processes are executed in parallel, multiple timers also work in parallel. While the timers are running, a list of active timers can be queried based on business needs.
[0025] Timer data can be stored using a map data structure (a data structure used to store data with mapping relationships). The key is the timer identifier, and the value is the timer data object. Multiple timers can be stored and managed through the map data structure, and different timers can be distinguished by the timer identifier, so that multiple timers can work in parallel to meet the needs of complex business scenarios.
[0026] After the timer starts counting down, it monitors each execution stage of the business logic in the business process. Each execution stage may include at least one of the following: API (Application Programming Interface) request processing, data logic processing, UI rendering operations, user interaction waiting, etc. For each execution stage, before execution begins, it determines whether the stage needs to be marked. If so, it calls the marking method to perform marking operations for that stage, marking the start and end of the stage to obtain marking information. Upon detecting the end event of the business process, it triggers the timer to stop counting down, storing the timer's start and end times, along with the marking information for each execution node, as timer data in a timer data object. Simultaneously, it reports the timer identifier and its data to the monitoring system. After the timer stops counting down, it can be cleared by calling the `clear()` method.
[0027] In this embodiment of the invention, the timer has a corresponding timer identifier. Determining whether the execution phase needs to be marked includes: obtaining the execution method corresponding to the execution phase and the input parameters corresponding to the execution method; determining whether the input parameters contain a timer identifier; and determining that the execution phase needs to be marked if the input parameters contain a timer identifier.
[0028] In this embodiment of the invention, for each execution stage, when determining whether it needs to be marked, the decision can be made by checking if the execution method of the execution stage contains a timer identifier. If it does, the execution stage needs to be marked; otherwise, it does not. For execution stages that need to be marked, the marking method is called according to the timer identifier to mark the start and end times of the execution stage, thereby obtaining the execution duration of the execution stage. Alternatively, the decision can be made by checking if the execution stage has a preset marking identifier. If a marking identifier is detected, the execution stage is determined to need to be marked, and the marking method is called according to the timer identifier to mark the execution stage. During the execution of the business process, each execution stage that needs to be marked is marked, and the marking information for each execution stage is obtained. This achieves flexibility in marking, allowing multiple time point identifiers to be added to the business process to record the time consumption of each execution stage, enabling fine-grained monitoring of the business process.
[0029] In this embodiment of the invention, the marking information includes a first time interval and a second time interval. Marking the execution phase to obtain the marking information of the execution phase further includes: calling a marking method to mark the start node and end node of the execution phase respectively, calculating the first time interval based on the marking time of the start node and the marking time of the previous marking, and calculating the second time interval based on the marking time of the start node and the marking time of the end node.
[0030] In this embodiment of the invention, a timer is used to identify the start and end nodes of the execution phase by calling a point-marking method. Points are marked when execution reaches the start and end nodes respectively. A second time interval is obtained based on the difference between the point-marking time of the start and end nodes. This second time interval represents the execution time of the current execution phase. The duration between the point-marking time of the start node of the execution phase and the start time of the business process can be obtained using this first time interval. By calling the point-marking method, the time interval between adjacent points can be automatically calculated. The point-marking information from each execution phase allows for quick and accurate identification of performance bottlenecks in the business process.
[0031] In this embodiment of the invention, the marking information also includes marking type and stage identifier. Marking the execution stage to obtain the marking information of the execution stage further includes: obtaining the marking type corresponding to the execution stage according to the mapping relationship between the execution stage and the marking type, and obtaining the marking information according to the marking type and stage identifier of the execution stage.
[0032] Each execution stage has a corresponding stage identifier, which can be the name of the execution stage. A pre-built mapping relationship between execution stages and event types is established. Based on the corresponding execution stage, the corresponding event type can be obtained according to the mapping relationship. Event types can include API type (API request execution type), JS type (JavaScript execution type), and user interaction wait type, and other custom types can also be defined. By marking different execution stages with event types, performance analysis becomes more accurate and targeted.
[0033] The tracking information can also include custom parameters, such as the name of the execution method and the URL (Uniform Resource Locator), which can be added according to business needs.
[0034] In this embodiment of the invention, the start and end times of the timer, as well as the tracking information for each execution stage, are reported to the monitoring system, including: The total duration of the timer is obtained based on the start and end times of the timer. For each event point type, obtain the event point information for each execution stage corresponding to the event point type; the event point information for each execution stage includes the execution duration of the execution stage; The execution time corresponding to the point type is obtained based on the execution time of each execution stage; The reporting data is created based on the total duration of the timer and the execution duration corresponding to each point type, and then reported to the monitoring system.
[0035] In this embodiment of the invention, after the timer corresponding to the business process ends, the start time and end time of the timer, as well as the point information of each execution stage, are stored as timer data in the timer data object corresponding to the timer identifier. The timer identifier and the timer data object are stored in map data format, which facilitates the management of multiple timers.
[0036] Simultaneously, reporting data is created based on timer data and reported to the front-end monitoring system. Specifically, the total duration of the timer can be calculated based on the start and end times of the timer. Each execution stage has a corresponding point type, and the execution stages corresponding to each point type are obtained. The execution durations of each execution stage are summed to obtain the execution time corresponding to each point type. The total duration of the timer and the execution duration of each point type can be processed according to a preset format to obtain the reporting data, which is then reported to the monitoring system.
[0037] In this embodiment of the invention, reporting data is created based on the total duration of the timer and the execution duration corresponding to each point type, including: Invoke the configured reporting function, which specifies the custom parameters and reporting format; Get the parameter value corresponding to the custom parameter; The data is converted according to the reporting format based on the total duration of the timer, the execution duration corresponding to each point type, and the parameter values to obtain the reported data.
[0038] Specifically, when creating and reporting data, the configured reporting function is called. The reporting function can be automatically called after the timer ends, passing the total duration of the timer and the execution duration corresponding to each point type to the reporting function. The reporting function can be an existing function or a custom function configured through a custom reporting function interface, enabling flexible configuration of the reporting function. By configuring the interface of the custom reporting function, integration with various monitoring systems can be achieved, such as integration with the enterprise's internal log system or third-party monitoring platforms, thereby enabling flexible reporting.
[0039] The reporting function only includes custom parameters and reporting format. Custom parameters allow developers to add parameters according to business needs, obtain parameter values, and then convert the total duration of the timer, the execution duration corresponding to each point type, and the parameter values according to the reporting format to achieve the reporting of data. Custom parameters can enrich the reported data and meet business needs.
[0040] In this embodiment of the invention, when creating reported data, the execution duration of one or more point types can be selected according to business needs to create the reported data. For example, the total time consumption of the timer can be calculated based on the difference between the total duration of the timer and the user interaction waiting time. Therefore, the user interaction waiting time does not need to be reported when reporting, so more accurate system processing time can be obtained and more accurate performance indicators can be obtained.
[0041] In this embodiment of the invention, the method further includes: acquiring each sub-process corresponding to the business process; for each sub-process, in response to listening to the start event of the sub-process, creating a sub-timer corresponding to the sub-process and triggering the sub-timer to start timing; listening to each sub-execution stage of the sub-process through the sub-timer, for each sub-execution stage, determining whether the sub-execution stage needs to be marked, and if it needs to be marked, marking the sub-execution stage to obtain the marking information of the sub-execution stage; in response to listening to the end event of the sub-process, triggering the sub-timer to end timing; sending the start time and end time of the sub-timer and the marking information of each execution stage to the timer so that the timer reports to the monitoring system.
[0042] In this embodiment of the invention, nested timers can be created within the timer, with each timer operating independently of the others. For example, a business process may include multiple sub-processes, and each sub-process may contain deeper sub-processes. This allows multiple sub-process timers to be embedded within the business process's timer, and further nested timers can be embedded within the sub-process timers, creating a hierarchical relationship between timers. For instance, the main process could be a page loading process, which may include multiple sub-processes such as data loading, business logic processing, and UI rendering. Specifically, each business process can include one or more sub-processes. For each sub-process, after listening for its start event, a corresponding sub-timer can be created and triggered to start timing. Creating a new timer is unaffected by other timers; the timers for the business process and the sub-processes do not interfere with each other. Then, for each sub-process, it is executed using the same timing and timing methods as the business process. That is, each sub-execution stage of each sub-process is timed, and the timing information for each sub-execution stage is obtained. After the sub-process ends, timing stops, and the sub-timer's timer data is sent to the timer for reporting to the monitoring system. Alternatively, the sub-timer can report its timer data to the monitoring system independently, or it can pass its timer data to its corresponding parent timer for reporting. Nested timers enable granular monitoring of complex business processes.
[0043] In this embodiment of the invention, the method further includes: encapsulating the marking method into a decorator, and attaching the decorator to the target execution method of the business process in the form of an annotation; in response to the detection that the target execution method has started execution, calling the marking method using the decorator and starting a timer; when the target execution method has finished execution, calling the marking method using the decorator and ending the timer; calculating the execution duration of the target execution method using the start time and the end time of the timer; and reporting the execution duration of the target execution method to the monitoring system.
[0044] Specifically, the timer can also be integrated with the JavaScript decorator pattern. For example, the timer of a business process or the timer of a subprocess can be encapsulated in the decorator, or the ticking method can be encapsulated in the decorator to achieve method-level performance monitoring and simplify code writing.
[0045] Specifically, the timing method is encapsulated in a decorator, which is then attached as an annotation to the target execution method in the business process. The target execution method can be a pre-defined method in the business process whose execution duration needs to be monitored, such as monitoring the time consumption of long tasks or API request times. When the target execution method starts executing, the decorator is used to mark the start and end times of execution. The time interval between these two marks gives the execution duration of the target execution method. The target execution method and its duration are then reported to the monitoring system for further analysis. The target execution method can be synchronous or asynchronous. Synchronous methods may include data processing, while asynchronous methods may include API requests or Promise operations. If the target execution method is synchronous, timing is performed when it starts executing and again after it finishes, ensuring synchronization between timing and method execution. If the target method is asynchronous, a timer is set at the start of execution. After the asynchronous method (e.g., sending an API request) is executed, the execution ends once the callback is executed or a response is received. A timer is then set again, and the execution time between the two timers is calculated. Decorator annotations enable complex method-level performance monitoring, improving front-end development efficiency and code readability.
[0046] Decorators can capture and report errors. For example, they can capture synchronous errors, asynchronous errors, long-running task execution errors, API request errors, etc., in the target execution method, and record and report the error identifier, error details, and their context information as log entries.
[0047] Figure 2This is a flowchart illustrating a front-end performance monitoring method according to an embodiment of the present invention. After detecting the start time of a business process, the `start(key)` method is called to create a timer corresponding to the business process. Simultaneously, a timer identifier `key` is generated for this timer, and timing begins. A timer data object is initialized, storing the timer identifier and the timer data object in a map data structure. Then, the execution of each stage in the business process is monitored. Each execution stage may include API requests, data processing, UI rendering, user interaction, etc. Based on whether the execution method of an execution stage contains `key`, it is determined whether the execution stage needs to be monitored. If not, a further determination is made. The system determines whether the business process should continue. If so, it calls the `mark()` method based on the key to mark the start and end of the execution phase and records the mark information. It also retrieves the mark type for the execution phase, which includes the time interval and mark type. This mark information is then inserted into the timer data object. Next, it checks whether the business process should continue. If yes, it executes the next execution phase. If not, it calls the `end()` method to end the timing and inserts the end time into the timer data object. Finally, it processes the timer data in the timer data object using a reporting function, creates reporting data, and reports the data to the monitoring system.
[0048] Figure 3 This is a schematic diagram of a system architecture for a timer according to an embodiment of the present invention. The timer includes a timer core module, a data storage module, a timer marking module, and a log reporting module. The timer core module includes a start timer method (start()), an end timer method (end()), an intermediate timer marking method (mark()), and a clear timer method (clear()). The data storage module stores a timer mapping table, which includes timer identifiers and their corresponding timer data objects stored in a map data structure. Each timer data object stores the timer's start time, end time, and a timer marking array. The timer marking module includes a timer type, name, duration, and time interval. The duration is the time between the start time of the execution phase and the time of the previous timer marking, and the time interval is the time interval between the start and end of the execution phase. The log reporting module includes a reporting function, which can customize reporting logic for integration with enterprise systems, facilitating performance data analysis. The timer core module sends timing data to the data storage module for storage. The timer core module creates a point recording module to record the execution stages of the business process that require point recording. The point recording module stores the point data in the data storage module. The timer core module triggers the log reporting module. The log reporting module retrieves complete timer data from the data storage module so that the log reporting module can report the data to an external monitoring system, such as an enterprise monitoring platform or a third-party analysis tool.
[0049] The front-end performance monitoring method provided in this invention creates a timer and starts timing after monitoring the start time of a business process. It listens to each execution stage in the business process, records the timing of stages that require tracking, and obtains the corresponding tracking information. The timer stops timing after the business process ends, and the total timer duration and the tracking information for each execution stage are reported to the monitoring system. This method can create a corresponding timer based on the start of the business process, supports multiple timers operating in parallel, and tracks the execution stages during the timer's timing process, recording the time consumed by each stage. This enables fine-grained monitoring of the business process, can be used for performance analysis of complex business processes, and can accurately locate performance bottlenecks in the business process, thereby improving user experience.
[0050] According to another aspect of the embodiments of the present invention, such as Figure 4 As shown, a front-end performance monitoring device 400 is provided, comprising: Create module 401, which responds to the business process start event by creating a timer corresponding to the business process and triggering the timer to start counting. The timing module 402 monitors each execution stage of the business process through a timer. For each execution stage, it determines whether timing is required. If timing is required, it performs timing on the execution stage and obtains the timing information for the execution stage. The reporting module 403, in response to the listening for the end event of the business process, triggers the timer to end the countdown and reports the start and end times of the timer, as well as the point information of each execution stage, to the monitoring system.
[0051] In this embodiment of the invention, the timer has a corresponding timer identifier, and the dotting module 402 is further used to: obtain the execution method corresponding to the execution phase and the input parameters corresponding to the execution method; determine whether the input parameters contain a timer identifier; and determine that the execution phase needs to be dotted if the input parameters contain a timer identifier.
[0052] In this embodiment of the invention, the marking information includes a first time interval and a second time interval. The marking module 402 is further configured to: call the marking method to mark the start node and end node of the execution phase respectively, calculate the first time interval based on the marking time of the start node and the marking time of the previous marking, and calculate the second time interval based on the marking time of the start node and the marking time of the end node.
[0053] In this embodiment of the invention, the point information also includes point type and stage identifier. The point module 402 is further used to: obtain the point type corresponding to the execution stage according to the mapping relationship between the execution stage and the point type, and obtain point information according to the point type and stage identifier of the execution stage.
[0054] In this embodiment of the invention, the reporting module 403 is further configured to: obtain the total duration of the timer based on the start and end times of the timer; for each point type, obtain the point information of each execution stage corresponding to the point type; the point information of each execution stage includes the execution duration of the execution stage; obtain the execution duration corresponding to the point type based on the execution duration of each execution stage; create reporting data based on the total duration of the timer and the execution duration corresponding to each point type, and report the reporting data to the monitoring system.
[0055] In this embodiment of the invention, the device further includes a nested module, configured to: acquire each sub-process corresponding to the business process; for each sub-process, in response to listening to the start event of the sub-process, create a sub-timer corresponding to the sub-process and trigger the sub-timer to start timing; listen to each sub-execution stage of the sub-process through the sub-timer, for each sub-execution stage, determine whether the sub-execution stage needs to be marked, and if it needs to be marked, mark the sub-execution stage to obtain the marking information of the sub-execution stage; in response to listening to the end event of the sub-process, trigger the sub-timer to end timing; and send the start and end timing of the sub-timer and the marking information of each execution stage to the timer so that the timer reports to the monitoring system.
[0056] In this embodiment of the invention, the reporting module 403 is further configured to: call a configured reporting function, which indicates custom parameters and a reporting format; obtain the parameter values corresponding to the custom parameters; and convert the data according to the reporting format based on the total duration of the timer, the execution duration corresponding to each point type, and the parameter values to obtain the reported data.
[0057] In this embodiment of the invention, the device further includes an integration module: The dot method is encapsulated into a decorator, and the decorator is attached to the target execution method of the business process as an annotation; In response to the start of execution of the target execution method, the marker method is called using the decorator and a timer is started. When the target execution method finishes execution, the marker method is called using the decorator to stop the timer. The execution duration of the target execution method is calculated by the start time and the end time of the timer. The execution time of the target execution method is reported to the monitoring system.
[0058] According to another aspect of the present invention, an electronic device is provided, comprising: one or more processors; and a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the front-end performance monitoring method provided by the present invention.
[0059] According to another aspect of the present invention, a computer-readable medium is provided having a computer program stored thereon, which, when executed by a processor, implements the front-end performance monitoring method provided by the present invention.
[0060] According to another aspect of the present invention, a computer program product is provided, including a computer program that, when executed by a processor, implements the front-end performance monitoring method provided by the present invention.
[0061] Figure 5 An exemplary system architecture 500 is shown that can be applied to the front-end performance monitoring method or front-end performance monitoring device of the present invention.
[0062] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, and 503, a network 504, and a server 505. Network 504 serves as the medium for providing communication links between terminal devices 501, 502, and 503 and server 505. Network 504 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0063] Users can use terminal devices 501, 502, and 503 to interact with server 505 via network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, and 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).
[0064] Terminal devices 501, 502, and 503 can be various electronic devices with displays that support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0065] Server 505 can be a server that provides various services, such as a backend management server that supports shopping websites browsed by users using terminal devices 501, 502, and 503 (for example only). The backend management server can analyze and process data such as received product information query requests, and feed back the processing results (such as target push information and product information - for example only) to the terminal devices.
[0066] It should be noted that the front-end performance monitoring method provided in this embodiment of the invention is generally executed by server 505, and correspondingly, the front-end performance monitoring device is generally set in server 505.
[0067] It should be understood that Figure 5 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0068] The following is for reference. Figure 6 It shows a schematic diagram of the structure of a computer system 600 suitable for implementing a terminal device of the present invention. Figure 6 The terminal device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.
[0069] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 602 or programs loaded from storage section 608 into random access memory (RAM) 603. The RAM 603 also stores various programs and data required for the operation of the system 600. The CPU 601, ROM 602, and RAM 603 are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0070] The following components are connected to I / O interface 605: an input section 606 including a keyboard, mouse, etc.; an output section 607 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to I / O interface 605 as needed. A removable medium 611, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 610 as needed so that computer programs read from it can be installed into storage section 608 as needed.
[0071] In particular, according to the embodiments disclosed in this invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 609, and / or installed from removable medium 611. When the computer program is executed by central processing unit (CPU) 601, it performs the functions defined above in the system of this invention.
[0072] It should be noted that the computer-readable medium shown in this invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. 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 of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0073] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0074] The modules described in the embodiments of the present invention can be implemented in software or hardware. The described modules can also be housed in a processor; for example, a processor can be described as including a creation module, a tracking module, and a reporting module. The names of these modules do not necessarily limit the module itself; for example, the creation module can also be described as "a module that, in response to a detected business process start event, creates a timer corresponding to the business process and triggers the timer to start counting."
[0075] In another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs, which, when executed by the device, cause the device to: in response to listening to a start event of a business process, create a timer corresponding to the business process and trigger the timer to start counting; monitor each execution stage of the business process through the timer, and for each execution stage, determine whether the execution stage needs to be marked, and if marking is required, mark the execution stage to obtain marking information for the execution stage; in response to listening to an end event of the business process, trigger the timer to end counting, and report the start and end times of the timer and the marking information for each execution stage to a monitoring system.
[0076] According to the technical solution of the embodiments of the present invention, the front-end performance monitoring method provided by the embodiments of the present invention creates a timer and starts timing after monitoring the start time of a business process, listens to each execution stage in the business process, and records the execution stages that need to be marked, obtaining the corresponding marking information. The timer ends timing after the business process ends, and the total duration of the timer and the marking information of each execution stage are reported to the monitoring system. This method can create a corresponding timer based on the start of the business process, supports multiple timers timing in parallel, and records the execution stages during the timer's timing process, thereby achieving fine-grained monitoring of the business process. It can be used for performance analysis of complex business processes, accurately locate performance bottlenecks in the business process, and thus improve user experience.
[0077] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A front-end performance monitoring method, characterized in that, include: In response to the detection of a business process start event, a timer corresponding to the business process is created and the timer is triggered to start counting. The timer monitors each execution stage of the business process. For each execution stage, it is determined whether the execution stage needs to be marked. If it needs to be marked, the execution stage is marked to obtain the marking information of the execution stage. In response to the detected end event of the business process, the timer is triggered to stop counting, and the start and end times of the timer, as well as the tracking information for each execution stage, are reported to the monitoring system.
2. The method according to claim 1, characterized in that, The timer has a corresponding timer identifier, and determining whether the execution phase needs to be marked includes: Obtain the execution method corresponding to the execution phase and the input parameters corresponding to the execution method; Determine whether the input parameters include the timer identifier; If the timer identifier is included in the input parameters, it is determined that the execution phase needs to be marked.
3. The method according to claim 1, characterized in that, The tracking information includes a first time interval and a second time interval. Tracking is performed on the execution phase to obtain the tracking information for the execution phase, and further includes: The point-marking method is invoked to mark the start node and end node of the execution phase respectively. The first time interval is calculated based on the point-marking time of the start node and the point-marking time of the previous point. The second time interval is calculated based on the point-marking time of the start node and the point-marking time of the end node.
4. The method according to claim 3, characterized in that, The point information also includes point type and stage identifier. Pointing the execution stage to obtain the point information of the execution stage further includes: obtaining the point type corresponding to the execution stage according to the mapping relationship between the execution stage and the point type, and obtaining the point information according to the point type and stage identifier of the execution stage.
5. The method according to claim 3, characterized in that, The start and end times of the timer, along with the tracking information for each execution stage, are reported to the monitoring system, including: The total duration of the timer is obtained based on the start time and end time of the timer; For each point type, obtain the point information for each execution stage corresponding to the point type; the point information for each execution stage includes the execution duration of the execution stage; The execution time corresponding to the point type is obtained based on the execution time of each execution stage; The reporting data is created based on the total duration of the timer and the execution duration corresponding to each point type, and the reporting data is reported to the monitoring system.
6. The method according to claim 1, characterized in that, The method further includes: Obtain the sub-processes corresponding to the business process; For each sub-process, in response to the detection of the sub-process's start event, a sub-timer corresponding to the sub-process is created and triggered to start timing; the sub-timer monitors each sub-execution stage of the sub-process, and for each sub-execution stage, it is determined whether the sub-execution stage needs to be marked. If marking is required, the sub-execution stage is marked to obtain the marking information of the sub-execution stage; in response to the detection of the sub-process's end event, the sub-timer is triggered to end timing; the start and end times of the sub-timer and the marking information of each execution stage are sent to the timer so that the timer reports to the monitoring system.
7. The method according to claim 5, characterized in that, The reported data is created based on the total duration of the timer and the execution duration corresponding to each point type, including: Invoke the configured reporting function, which indicates custom parameters and reporting format; Get the parameter value corresponding to the custom parameter; The reported data is obtained by converting the total duration of the timer, the execution duration corresponding to each point type, and the parameter values according to the reporting format.
8. The method according to claim 1, characterized in that, The method further includes: The dot method is encapsulated into a decorator, and the decorator is attached to the target execution method of the business process as an annotation; In response to the start of execution of the target execution method, the decorator is used to call the dotted method and start the timer. When the target execution method ends execution, the decorator is used to call the dotted method and end the timer. The execution time of the target execution method is calculated by the start time and the end time of the timer. The execution time of the target execution method is reported to the monitoring system.
9. A front-end performance monitoring device, characterized in that, include: Create a module that, in response to the detection of a business process start event, creates a timer corresponding to the business process and triggers the timer to start counting; The timing module monitors each execution stage of the business process through the timer. For each execution stage, it determines whether the execution stage needs to be timing. If timing is required, it timings the execution stage to obtain the timing information of the execution stage. The reporting module, in response to the listening for the end event of the business process, triggers the timer to stop counting, and reports the start and end times of the timer, as well as the point information of each execution stage, to the monitoring system.
10. An electronic device, characterized in that, include: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-8.
11. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-8.
12. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-8.