Disclosure of Invention
The present application mainly aims to provide a method, an apparatus, a device and a storage medium for reporting information, and aims to solve the problem of display delay occurring when information is reported in the prior art.
In order to achieve the above object, the present application provides an information reporting method, where the method includes:
acquiring log information to be reported in a target browser, respectively packaging each piece of log information into an execution unit, and storing the log information into a cache library;
combining each execution unit in the cache library according to a preset arrangement sequence to form single linked list information;
calling a preset monitoring interface, reading frame information of the target browser, judging whether the frame information meets a preset idle condition, taking the moment when the frame information meets the idle condition as a starting time, taking the moment when the frame information does not meet the idle condition as an ending time, and taking coherent time between the starting time and the ending time as idle time;
and after the idle time is entered, calling a reporting function to select the log information from the single linked list information for reporting, and stopping calling the reporting function after the idle time is ended.
Further, the determining whether the frame information meets a preset idle condition, and taking a time when the frame information meets the idle condition as an initial time includes:
acquiring the execution time of each frame according to the frame information;
if the execution time is smaller than a preset time threshold value, judging that the current frame information meets the idle condition;
and taking the appearance moment corresponding to the frame with the execution time smaller than the preset time threshold value as the starting time.
Further, the combining forms singly linked list information, including:
setting an execution node for each execution unit respectively, wherein each execution node comprises a pointer and at least one data element;
and combining the execution nodes according to the arrangement sequence and then storing the combination into the cache library again.
Further, the encapsulating each piece of the log information into an execution unit respectively includes:
and identifying a data structure of the log information, and packaging the log information according to the data structure.
Further, the determining whether the frame information meets a preset idle condition includes:
and identifying a frame rate carried in the frame information, and judging that the frame information meets the idle condition when the frame rate is greater than a preset frame threshold.
Further, the storing into the cache library includes:
sending a cache request to a cloud server, and sending the execution unit to the cache library of the cloud server after receiving cache confirmation information returned by the cloud server;
and acquiring the storage address of each execution unit, and storing the storage address in a leaf node of a hash tree in the cache bank.
The present application further provides an apparatus for reporting information, including:
the execution unit generation module is used for acquiring the log information to be reported in the target browser, respectively packaging each piece of the log information into an execution unit and storing the execution unit into the cache library;
the single linked list generating module is used for combining each execution unit in the cache library according to a preset arrangement sequence to form single linked list information;
the idle calculation module is used for calling a preset monitoring interface, reading frame information of the target browser, judging whether the frame information meets a preset idle condition or not, taking the moment when the frame information meets the idle condition as a starting time, taking the moment when the frame information does not meet the idle condition as an ending time, and taking the continuous time between the starting time and the ending time as idle time;
and the log reporting module is used for calling a reporting function to select the log information from the single linked list information for reporting after the idle time is entered, and stopping calling the reporting function after the idle time is finished.
The present application further proposes a computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the steps of any of the above methods when executing the computer program.
The present application also proposes a computer-readable storage medium having stored thereon a computer program which, when being executed by a processor, carries out the steps of the method of any of the above.
According to the information reporting method, the device, the equipment and the storage medium, log information is collected and packaged uniformly, each log information is packaged into an execution unit so as to be reported conveniently, and the execution units are stored in the cache, so that the problem that the log information interrupts the execution process of other tasks is solved; the execution units formed by the log information are subjected to data arrangement processing through a single linked list mode, so that the adjustability of the log reporting sequence is improved, and the log information which needs to be reported more can be reported preferentially; by acquiring the frame information of the target browser and accurately identifying the idle time of the target browser according to the frame information, the accuracy of judging the working state of the target browser is improved; after the idle time is reached, the reporting function is called to select the log information from the single linked list information for reporting, and the reporting function is stopped to be called after the idle time is finished, so that the target browser can preferentially process user interaction and page rendering, the quick response of the page on the sense of the user is realized, and the reporting is stopped after the idle time is finished, so that the timeliness of the execution of the subsequent user interaction and page rendering functions is improved, and the problem of display delay or blockage of the target browser is avoided.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
Referring to fig. 1, in order to achieve the purpose of the foregoing embodiments, the present application provides an information reporting method, where the method includes:
s1: acquiring log information to be reported in a target browser, respectively packaging each piece of log information into an execution unit, and storing the log information into a cache library;
s2: combining each execution unit in the cache library according to a preset arrangement sequence to form single linked list information;
s3: calling a preset monitoring interface, reading frame information of the target browser, judging whether the frame information meets a preset idle condition, taking the moment when the frame information meets the idle condition as a starting time, taking the moment when the frame information does not meet the idle condition as an ending time, and taking coherent time between the starting time and the ending time as idle time;
s4: and after the idle time is entered, calling a reporting function to select the log information from the single linked list information for reporting, and stopping calling the reporting function after the idle time is ended.
In the embodiment, the log information is uniformly collected and packaged, each piece of log information is packaged into one execution unit for reporting, and the execution units are stored in the cache, so that the problem that the log information interrupts the execution process of other tasks is solved; the execution units formed by the log information are subjected to data arrangement processing through a single linked list mode, so that the adjustability of the log reporting sequence is improved, and the log information which needs to be reported more can be reported preferentially; by acquiring the frame information of the target browser and accurately identifying the idle time of the target browser according to the frame information, the accuracy of judging the working state of the target browser is improved; after the idle time is reached, the reporting function is called to select the log information from the single linked list information for reporting, and the reporting function is stopped to be called after the idle time is finished, so that the target browser can preferentially process user interaction and page rendering, the quick response of the page on the sense of the user is realized, and the reporting is stopped after the idle time is finished, so that the timeliness of the execution of the subsequent user interaction and page rendering functions is improved, and the problem of display delay or blockage of the target browser is avoided.
As for step S1, the present embodiment is applied to the application of computer data processing, particularly processing of log information. With the development of the field of the front end of the Web, the browser is used as a front end page, more and more functions are needed to be executed, log information needing to be reported to a monitoring system is increased, if the log information is directly reported after being generated, the browser cannot preferentially execute other tasks triggered by a user, and therefore the problems that the display screen of the browser is discontinuous and the like are caused, and the use experience of the user is influenced are caused. In the embodiment, by uniformly collecting and packaging the log information, each piece of log information is packaged into one execution unit for reporting, and the execution units are stored in the cache, so that the problem that the log information interrupts the execution process of other tasks is solved.
For step S2, before reporting is completed, the execution units corresponding to each piece of log information to be reported are arranged according to a preset arrangement order, where the arrangement order may be a priority order, or a generation time order, and the like; the single linked list information is a chained access data structure, and a group of addresses are used in a cache to linearly store execution units in the single linked list information, so that chained data storage and reading can be supported; in the embodiment, the execution units formed by the log information are subjected to data arrangement processing through the single linked list mode, so that the adjustability of the log reporting sequence is improved, and the log information which needs to be reported more can be preferentially reported.
For step S3, in order to not interrupt the response of the target browser to the normal instruction of the user instruction, a mode of detecting frame information of the target browser is adopted, where the frame information may be a frame rate or a frame task completion time; taking the frame rate as an example, when the target browser plays a video or processes other functions, the frame rate is usually changed along with the change of the display screen, so that when the frame rate is higher, it often means that the target browser is in a working state of rendering animation or jumping to a screen, and when the frame rate is lower, it often means that the target browser is in an idle state; therefore, the moment when the frame information meets the idle condition is used as the starting time, the moment when the frame information does not meet the idle condition is used as the ending time, and the time interval is used as the idle time of the target browser. In the embodiment, the frame information of the target browser is obtained, and the idle time of the target browser is accurately identified according to the frame information, so that the accuracy of judging the working state of the target browser is improved.
For step S4, after entering the idle time, the browser can execute background and low-priority work on the main event loop by calling the reporting function requestIdleCallback without affecting the delay of key events, such as animation and input response, and in a specific implementation manner, when a user input event occurs or animation occurs, the browser can preferentially process user interaction and page rendering, wait until the next idle time occurs, and then perform task reporting of the next execution unit, thereby implementing fast response of the page on the user sense, and when the idle time ends, stop calling the requestIdleCallback function, thereby avoiding affecting the target browser to execute new rendering or display instructions. In the embodiment, after the idle time is reached, the reporting function is called to select the log information from the single linked list information for reporting, and the reporting function is stopped to be called after the idle time is finished, so that the target browser can preferentially process user interaction and page rendering, the quick response of the page on the user sense is realized, and the reporting is stopped after the idle time is finished, so that the timeliness of the execution of the subsequent user interaction and page rendering functions is improved.
In one embodiment, the determining whether the frame information meets a preset idle condition, and taking a time when the frame information meets the idle condition as a start time includes:
s31: acquiring the execution time of each frame according to the frame information;
s32: if the execution time is smaller than a preset time threshold value, judging that the current frame information meets the idle condition;
s33: and taking the appearance moment corresponding to the frame with the execution time smaller than the preset time threshold value as the starting time.
According to the method and the device, whether the target browser is in the idle time currently is judged according to the frame information, so that the problem that the normal display function of the target browser is interrupted due to log reporting in non-idle time is avoided, and the problem of display delay or blockage of the target browser is avoided.
For step S31, the screen refresh rate of most current devices is 60 times/second, and the rate at which the browser renders each frame of animation or page also needs to be consistent with the refresh rate of the device screen. When the number of frames drawn per second reaches 60, the page is fluent, and below this value, the user feels stuck. The beginning of each frame includes style computation, layout, and rendering. The Javascript engine and the page rendering engine are in the same rendering thread, and the GUI rendering and the Javascript execution are mutually exclusive. In practice, however, developers often want browsers to respond quickly to users, feel fast enough, and cannot block user interaction. Reporting the idle time of each frame of the browser through the requestIdleCallback, and delivering the controller to the browser when the starting time of the idle time is reached.
For step S32, since requestIdleCallback enables the browser to perform background and low priority work on the main event loop without affecting delay critical events such as animation and input response. After the normal frame task is completed, the preset time threshold is not exceeded, which indicates that there is a time margin, and the task registered in requestIdleCallback is executed at this time, wherein the preset time threshold may be 16 ms.
In one embodiment, the combining forms singly linked list information, including:
s21: setting an execution node for each execution unit respectively, wherein each execution node comprises a pointer and at least one data element;
s22: and combining the execution nodes according to the arrangement sequence and then storing the combination into the cache library again.
In the embodiment, the execution unit is formed by setting the execution nodes comprising the pointers and the data elements, so that different data elements are positioned through the pointers, and the single linked list sorting is performed, thereby improving the ordering of data.
For step S21, the data in the linked list is represented by nodes, each node consisting of: an element (a map of data elements) + a pointer (indicating the storage location of the successor element), an element being the storage location where the data is stored, and a pointer being the address data connecting each node. Expressing a linear table as a "sequence of nodes" is called a linear linked list (singly linked list), which is a structure for storing and reading data in a chain. The linear table stored in the link mode is referred to as a linked list (linkedlst) for short. The specific storage of the linked list is represented as: firstly, a group of arbitrary storage units is used for storing the nodes of the linear table (the group of storage units can be continuous or discontinuous), and secondly, the logical order and the physical order of the nodes in the linked list are not necessarily the same. In order to correctly represent the logical relationship between nodes, it is necessary to store address (or location) information (called pointer (pointer) or chain (link)) indicating the node following each node while storing each node value, and the chain storage is one of the most common storage methods, and it can be used to represent not only linear tables but also various non-linear data structures. The linked list links n nodes of the linear table together in their logical order through the chain domain of each node, and the linked list in which each node has only one chain domain is called a single chain (singlelinkedlst). The head pointer head and the storage address of each node in the terminal node single-chain list are stored in the next field of the predecessor node, and the starting node has no predecessor, so the head pointer head should be set to point to the starting node. The linked list is uniquely defined by a head pointer and the singly linked list may be named by the name of the head pointer. The terminal node has no successor, so the pointer field of the terminal node is NULL, i.e. NULL.
In one embodiment, the encapsulating each piece of the log information into one execution unit respectively includes:
s11: and identifying a data structure of the log information, and packaging the log information according to the data structure.
According to the embodiment, the log information is packaged according to the data structure by identifying the data structure of the log information, so that the monitoring system can directly identify the type of the log information according to the execution unit, and the identification efficiency is improved.
For step S11, the log information generally corresponds to logs of different functions, for example, the Redo log is a Redo log, the Redo log belongs to a log of the InnoDB engine, and the Undo log is a logical log and a rollback log.
In one embodiment, the determining whether the frame information satisfies a preset idle condition includes:
s34: and identifying a frame rate carried in the frame information, and judging that the frame information meets the idle condition when the frame rate is greater than a preset frame threshold.
In the embodiment, the frame rate threshold is used as an idle condition, and whether the target browser is in an idle state at present is judged through the frame rate carried in the frame information, so that the idle time can be accurate to a frame, and the accuracy of idle time judgment is improved.
For step S41, when the front-end page is loaded for the first time, the browser needs to request various static file resources, initiate a first-screen data interface request, render a page animation, and the like, and at this time, for the front-end monitoring system, it also needs to acquire, through the browser, abnormal information such as performance indexes such as FMP \ LCP \ FP \ FCP \ FLD, white screen, stuck, and code errors, resource loading errors, interface errors, and the like. When projects become more and more complex and reported information becomes more and more huge, page performance is influenced, such as delay of first screen display, blockage and the like, user experience is influenced, the frame rate of a target browser is often higher at the moment, and when the target browser is in an idle state, the frame rate is lower, so that timing can be started at the moment when the frame rate is lower than a threshold value, and the moment is used as the starting moment of idle time.
In one embodiment, the storing into a cache library comprises:
s12: sending a cache request to a cloud server, and sending the execution unit to the cache library of the cloud server after receiving cache confirmation information returned by the cloud server;
s13: and acquiring the storage address of each execution unit, and storing the storage address in a leaf node of a hash tree in the cache bank.
In the embodiment, the execution unit is stored in the cache library of the cloud server, and the execution unit is synchronized to other cloud cache clusters through the cloud server, so that the problem that log information is lost due to the fact that a local server fails is solved, and the data security is improved.
For step S12, the execution unit data is cached in the cloud server, so that the storage resource of the local server can be released, thereby improving the data analysis performance of the local server. In addition, the data are synchronized to other server caches through the cloud server, the consistency of the data is ensured, and the problem that the data at a certain end is tampered by viruses or malicious programs to cause data abnormity is solved.
For step S13, in this embodiment, the hash tree leaf node records a storage location of the execution unit in the redis cache service, so as to serve as a data index to facilitate data lookup, thereby improving traceability of data.
In an embodiment, the obtaining log information to be reported in the target browser S1 includes:
s14: monitoring the target browser according to a preset time interval, and extracting the reported information of the target browser according to an event identifier;
s15: identifying the generation time of each piece of reported information, and acquiring the reported content corresponding to the reported information with the same generation time;
s16: and judging whether the report information with the same generation time and the same report content exists, and if so, combining the report information with the same generation time and the same report content to form the log information.
In the embodiment, the target browser is monitored according to a certain time interval, so that the problem that communication resources are occupied due to frequent visiting is avoided, and the repeated data is eliminated by combining the report information with the same generation time and report content.
For step S14, the time interval may be 1S, 2S, 5S, and the like, and the specific data may be set according to the running state of the actual target browser, so as to improve the effectiveness of monitoring and avoid the problem of resource waste caused by invalid occupation of communication resources.
For step S15, in a specific application, if a network anomaly or a virus attack occurs in the target browser, the problem of repeated submission of log information may occur, and the abnormally repeated log information can be accurately identified by the generation time and the reported content, so that the removal of the repeated content is realized, and the accuracy of the reported log information is improved.
Referring to fig. 3, the present application further provides an information reporting apparatus, including:
the execution unit generation module 100 is configured to obtain log information to be reported in a target browser, package each piece of the log information into one execution unit, and store the execution unit in a cache library;
a single linked list generating module 200, configured to combine each execution unit in the cache library according to a preset arrangement order to form single linked list information;
an idle calculation module 300, configured to invoke a preset monitoring interface, read frame information of the target browser, determine whether the frame information meets a preset idle condition, use a time when the frame information meets the idle condition as a start time, use a time when the frame information does not meet the idle condition as an end time, and use a consecutive time between the start time and the end time as an idle time;
and a log reporting module 400, configured to call a reporting function to select the log information from the single-linked list information for reporting after the idle time is entered, and stop calling the reporting function after the idle time is finished.
In the embodiment, the log information is uniformly collected and packaged, each piece of log information is packaged into one execution unit for reporting, and the execution units are stored in the cache, so that the problem that the log information interrupts the execution process of other tasks is solved; the execution units formed by the log information are subjected to data arrangement processing through a single linked list mode, so that the adjustability of the log reporting sequence is improved, and the log information which needs to be reported more can be reported preferentially; by acquiring the frame information of the target browser and accurately identifying the idle time of the target browser according to the frame information, the accuracy of judging the working state of the target browser is improved; after the idle time is reached, the reporting function is called to select the log information from the single linked list information for reporting, and the reporting function is stopped to be called after the idle time is finished, so that the target browser can preferentially process user interaction and page rendering, the quick response of the page on the sense of the user is realized, and the reporting is stopped after the idle time is finished, so that the timeliness of the execution of the subsequent user interaction and page rendering functions is improved, and the problem of display delay or blockage of the target browser is avoided.
In one embodiment, the idle calculation module 300 is further configured to:
acquiring the execution time of each frame according to the frame information;
if the execution time is smaller than a preset time threshold value, judging that the current frame information meets the idle condition;
and taking the appearance moment corresponding to the frame with the execution time smaller than the preset time threshold value as the starting time.
In one embodiment, the singly linked list generating module 200 is further configured to:
setting an execution node for each execution unit respectively, wherein each execution node comprises a pointer and at least one data element;
and combining the execution nodes according to the arrangement sequence and then storing the combination into the cache library again.
In one embodiment, the execution unit generation module 100 is further configured to:
and identifying a data structure of the log information, and packaging the log information according to the data structure.
In one embodiment, the idle calculation module 300 is further configured to:
and identifying a frame rate carried in the frame information, and judging that the frame information meets the idle condition when the frame rate is greater than a preset frame threshold.
In one embodiment, the execution unit generation module 100 is further configured to:
sending a cache request to a cloud server, and sending the execution unit to the cache library of the cloud server after receiving cache confirmation information returned by the cloud server;
and acquiring the storage address of each execution unit, and storing the storage address in a leaf node of a hash tree in the cache bank.
In an embodiment, the log reporting module 400 is further configured to:
monitoring the target browser according to a preset time interval, and extracting the reported information of the target browser according to an event identifier;
identifying the generation time of each piece of reported information, and acquiring the reported content corresponding to the reported information with the same generation time;
and judging whether the report information with the same generation time and the same report content exists, and if so, combining the report information with the same generation time and the same report content to form the log information.
Referring to fig. 4, a computer device, which may be a server and whose internal structure may be as shown in fig. 4, is also provided in the embodiment of the present application. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the computer designed processor is used to provide computational and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer equipment is used for storing data such as information reporting methods and the like. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a method for reporting information. The information reporting method comprises the following steps: acquiring log information to be reported in a target browser, respectively packaging each piece of log information into an execution unit, and storing the log information into a cache library; combining each execution unit in the cache library according to a preset arrangement sequence to form single linked list information; calling a preset monitoring interface, reading frame information of the target browser, judging whether the frame information meets a preset idle condition, taking the moment when the frame information meets the idle condition as a starting time, taking the moment when the frame information does not meet the idle condition as an ending time, and taking coherent time between the starting time and the ending time as idle time; and after the idle time is entered, calling a reporting function to select the log information from the single linked list information for reporting, and stopping calling the reporting function after the idle time is ended.
An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements a method for reporting information, and the method includes: acquiring log information to be reported in a target browser, respectively packaging each piece of log information into an execution unit, and storing the log information into a cache library; combining each execution unit in the cache library according to a preset arrangement sequence to form single linked list information; calling a preset monitoring interface, reading frame information of the target browser, judging whether the frame information meets a preset idle condition, taking the moment when the frame information meets the idle condition as a starting time, taking the moment when the frame information does not meet the idle condition as an ending time, and taking coherent time between the starting time and the ending time as idle time; and after the idle time is entered, calling a reporting function to select the log information from the single linked list information for reporting, and stopping calling the reporting function after the idle time is ended.
In the method for reporting executed information, each piece of log information is packaged into one execution unit for reporting conveniently by uniformly collecting and packaging the log information, and the execution units are stored in the cache, so that the problem that the log information interrupts the execution process of other tasks is solved; the execution units formed by the log information are subjected to data arrangement processing through a single linked list mode, so that the adjustability of the log reporting sequence is improved, and the log information which needs to be reported more can be reported preferentially; by acquiring the frame information of the target browser and accurately identifying the idle time of the target browser according to the frame information, the accuracy of judging the working state of the target browser is improved; after the idle time is reached, the reporting function is called to select the log information from the single linked list information for reporting, and the reporting function is stopped to be called after the idle time is finished, so that the target browser can preferentially process user interaction and page rendering, the quick response of the page on the sense of the user is realized, and the reporting is stopped after the idle time is finished, so that the timeliness of the execution of the subsequent user interaction and page rendering functions is improved, and the problem of display delay or blockage of the target browser is avoided.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium provided herein and used in the examples may include non-volatile and/or volatile memory. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), double-rate SDRAM (SSRSDRAM), Enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and bus dynamic RAM (RDRAM).
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, apparatus, article, or method. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, apparatus, article, or method that includes the element.
The above description is only a preferred embodiment of the present application, and not intended to limit the scope of the present application, and all modifications of equivalent structures and equivalent processes, which are made by the contents of the specification and the drawings of the present application, or which are directly or indirectly applied to other related technical fields, are also included in the scope of the present application.