Code fault early warning method and device, terminal equipment and storage medium
By analyzing and feature extraction of log entries and generating failure causes in combination with the big model, the problem of low accuracy of code failure warning caused by indirect dependencies caused by ignoring indirect dependencies is solved, and more efficient code is achieved Fault identification and early warning.
Patent Information
- Application Number
- CN202410977942.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-19
- Publication Date
- 2024-12-06
AI Technical Summary
The existing technology has low accuracy and high maintenance costs in code failure warning, which is mainly due to the ignorance of indirect dependencies by relying on management tools, resulting in low code execution efficiency and poor product quality.
By entering the log entries generated by the test tool into the preset log parser, generating log feature vectors, identifying exception logs, and entering them into the big model to generate the cause of the failure, matching the differential version dependency file to determine the fault code, and finally sending an early warning.
Improve the accuracy of code failure warning, reduce maintenance costs, and improve code execution efficiency and product quality.
Smart Images

Figure CN119088671A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer application technology, and in particular, relates to a code fault warning method, device, terminal equipment and computer-readable storage medium. Background Art
[0002] During product development, updated code needs to be tested in a timely manner. However, since testing tools usually rely on multiple third-party libraries, there may be complex dependencies between these libraries. When these libraries are updated, new application interface changes, functional defects, or compatibility issues with other libraries may be introduced, causing the execution of the testing tool to fail. At the same time, when third-party libraries are updated, their application interfaces may be changed or refactored. If the automated testing tool uses an old version of the API, these application interfaces may no longer be applicable in the new version of the library, resulting in the inability to test the code normally and the inability to issue code failure warnings in a timely manner.
[0003] In the related art, dependency management tools can be integrated through testing tools to manage library versions, or developers can use virtual environments to isolate dependencies of different projects. However, dependency management tools usually only focus on direct dependencies and ignore indirect dependencies. In addition, establishing a virtual environment for each project increases maintenance costs and complicates the process. Therefore, when problems occur in dependency files, using existing technologies to provide code fault warnings has the problems of low accuracy and high maintenance costs, which leads to low code execution efficiency and poor product quality. Summary of the invention
[0004] The purpose of the present application is to provide a code fault warning method, apparatus, terminal device and computer-readable storage medium, which can solve the problems in the related art of integrating dependency management tools to manage library versions through test tools, or isolating dependencies of different projects through developers using virtual environments. Since dependency management tools usually only focus on direct dependencies and ignore indirect dependencies, and establishing a virtual environment for each project will increase maintenance costs and complicate the process, when problems occur in dependency files, the code fault warning accuracy is low, the maintenance cost is high, and the code execution efficiency is low and the product quality is poor.
[0005] In the first aspect, an embodiment of the present application provides a code fault warning method, including: inputting the log entries generated by the testing tool into a preset log parser to generate a log feature vector; identifying the log feature vector to determine the abnormal log; inputting the log feature vector corresponding to the abnormal log into a preset large model to generate the fault cause corresponding to the abnormal log; matching the fault cause with the locally cached difference version dependency file to determine the fault code corresponding to the fault cause in the difference version dependency file, wherein the difference version dependency file is a version dependency file that has changed before and after the code is submitted; sending the abnormal log and the fault code corresponding to the abnormal log to the tester for fault warning.
[0006] In a possible implementation manner of the first aspect, the step of inputting the log entry generated by the test tool into a preset log parser to generate the log feature vector includes:
[0007] Input the log entry into a preset log parser to identify the log format of the log entry;
[0008] Extract individual components from log entries;
[0009] Convert each component into a feature vector;
[0010] The feature vectors corresponding to each component are concatenated to generate a log feature vector.
[0011] Optionally, in another possible implementation of the first aspect, the components include a log level component, a text component, and a time component, the feature vector includes a numerical feature vector, a text feature vector, and a time series feature vector, and the converting of each component into a feature vector includes:
[0012] When the component includes a log level component, converting the log level component into a numerical feature vector;
[0013] When the component includes a text component, the text component is converted into a text feature vector through a preset word embedding model;
[0014] When the components include a time component, the time component is converted into a time series feature vector.
[0015] Optionally, in another possible implementation manner of the first aspect, the step of inputting the log entry generated by the test tool into a preset log parser to generate a log feature vector further includes:
[0016] The log entries are input into the preset log parser, a log graph is constructed through the graph neural network, and features of the log entries are extracted based on the log graph to generate a log feature vector.
[0017] Optionally, in another possible implementation manner of the first aspect, before the log entry generated by the test tool is input into a preset log parser and the log feature vector is generated, the method further includes:
[0018] Filter and analyze the difference code files, generate difference version dependency files and cache them locally. The difference code files are files that have changed before and after the code is submitted.
[0019] Optionally, in another possible implementation of the first aspect, the filtering and analyzing of the difference code files, generating the difference version dependency files and caching them locally includes:
[0020] By constructing regular expressions to filter the difference code files and / or analyzing the file extensions of the difference code files, a difference version dependency file is generated and cached locally;
[0021] After filtering and analyzing the difference code files, generating the difference version dependency files and caching them locally, the following is also included:
[0022] Classify the difference version dependent files, determine the difference categories of the difference version dependent files, and cache the classification results locally, where the difference categories include addition, deletion, and modification.
[0023] Optionally, in another possible implementation of the first aspect, the method further includes:
[0024] Input the log feature vector corresponding to the abnormal log into the preset large model to generate a solution corresponding to the abnormal log;
[0025] After matching the fault cause with the locally cached difference version dependency file and determining the fault code corresponding to the fault cause in the difference version dependency file, the following steps are also included:
[0026] Save the exception log, the fault code corresponding to the exception log, and the solution to the local fault file;
[0027] The above sends the exception log and the fault code corresponding to the exception log to the tester for fault warning, including:
[0028] Create a scheduled warning task, read the text content in the local fault file, and send the text content to the tester for fault warning.
[0029] On the second aspect, the present application also provides a code fault warning device, including: a first generation module, used to input the log entries generated by the test tool into a preset log parser to generate a log feature vector; a first determination module, used to identify the log feature vector and determine the abnormal log; a second generation module, used to input the log feature vector corresponding to the abnormal log into a preset large model, and generate the fault cause corresponding to the abnormal log; a second determination module, used to match the fault cause with the locally cached difference version dependency file, and determine the fault code corresponding to the fault cause in the difference version dependency file, wherein the difference version dependency file is a version dependency file that has changed before and after the code is submitted; a warning module, used to send the abnormal log and the fault code corresponding to the abnormal log to the tester for fault warning.
[0030] In a possible implementation manner of the second aspect, the first generating module includes:
[0031] An identification unit, used for inputting the log entry into a preset log parser to identify the log format of the log entry;
[0032] An extraction unit, used to extract individual components in a log entry;
[0033] A conversion unit, used to convert each component into a feature vector;
[0034] The first generating unit is used to concatenate the feature vectors corresponding to the various components to generate a log feature vector.
[0035] Optionally, in another possible implementation of the second aspect, the components include a log level component, a text component, and a time component, and the feature vector includes a numerical feature vector, a text feature vector, and a time series feature vector; accordingly, the conversion unit is specifically used to:
[0036] When the component includes a log level component, converting the log level component into a numerical feature vector;
[0037] When the component includes a text component, the text component is converted into a text feature vector through a preset word embedding model;
[0038] When the components include a time component, the time component is converted into a time series feature vector.
[0039] Optionally, in another possible implementation manner of the second aspect, the first generating module further includes:
[0040] The second generating unit is used to input the log entry into a preset log parser, construct a log graph through a graph neural network, and extract features of the log entry according to the log graph to generate a log feature vector.
[0041] Optionally, in another possible implementation of the second aspect, the code failure warning device further includes:
[0042] The third generation module is used to filter and analyze the difference code files, generate difference version dependency files and cache them locally, wherein the difference code files are files that have changed before and after the code is submitted.
[0043] Optionally, in another possible implementation manner of the second aspect, the third generating module includes:
[0044] The third generating unit is used to filter the difference code files and / or analyze the file extensions of the difference code files by constructing regular expressions, generate difference version dependency files and cache them locally;
[0045] The above-mentioned code failure early warning device further includes:
[0046] The cache module is used to classify the difference version dependent files, determine the difference categories of the difference version dependent files, and cache the classification results locally, where the difference categories include addition, deletion and modification.
[0047] Optionally, in another possible implementation of the second aspect, the code failure warning device further includes:
[0048] A fourth generation module is used to input the log feature vector corresponding to the abnormal log into a preset large model to generate a solution corresponding to the abnormal log;
[0049] A saving module is used to save the exception log, the fault code corresponding to the exception log and the solution to a local fault file;
[0050] The above-mentioned early warning module includes:
[0051] The early warning unit is used to create a scheduled early warning task, read the text content in the local fault file, and send the text content to the tester for fault early warning.
[0052] In a third aspect, the present application further provides a terminal device. The terminal device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, a method for implementing any one of the implementation modes of the first aspect is implemented.
[0053] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method of any one of the implementation modes of the first aspect is implemented.
[0054] In a fifth aspect, the present application further provides a computer program product, which, when executed on an electronic device, enables the electronic device to execute any one of the methods of the first aspect.
[0055] Compared with the prior art, the embodiments of the present application have the following beneficial effects: by parsing and identifying log entries, determining abnormal logs, and inputting the abnormal logs into a large model, generating fault causes, and sending the fault causes and fault codes to testers for active warnings, the accuracy of code fault warnings when problems occur in dependent files is improved, and maintenance costs are reduced, thereby improving code execution efficiency and product quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0057] Figure 1 It is a flowchart of a code failure warning method provided by an embodiment of the present application;
[0058] Figure 2 is a schematic diagram of a code failure early warning method provided by another embodiment of the present application;
[0059] Figure 3 It is a structural diagram of a code failure warning device provided in an embodiment of the present application;
[0060] Figure 4 It is a schematic diagram of the structure of the terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0061] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0062] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0063] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0064] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0065] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0066] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0067] During product development, updated code needs to be tested in a timely manner. However, since testing tools usually rely on multiple third-party libraries, there may be complex dependencies between these libraries. When these libraries are updated, new application interface changes, functional defects, or compatibility issues with other libraries may be introduced, causing the execution of the testing tool to fail. At the same time, when third-party libraries are updated, their application interfaces may be changed or refactored. If the automated testing tool uses an old version of the API, these application interfaces may no longer be applicable in the new version of the library, resulting in the inability to test the code normally and the inability to issue code failure warnings in a timely manner.
[0068] In the related art, dependency management tools can be integrated through testing tools to manage library versions, or developers can use virtual environments to isolate dependencies of different projects. However, dependency management tools usually only focus on direct dependencies and ignore indirect dependencies. In addition, establishing a virtual environment for each project increases maintenance costs and complicates the process. Therefore, when problems occur with dependency files, using existing technologies for code fault warnings has the problems of low accuracy and high maintenance costs, which leads to low code execution efficiency and poor product quality.
[0069] Based on this, the present application provides a code fault warning method, apparatus, terminal device, storage medium and computer program.
[0070] The code fault warning method, apparatus, terminal device, storage medium and computer program provided by the present application are described in detail below with reference to the accompanying drawings.
[0071] Figure 1 A flow chart of a code fault warning method provided in an embodiment of the present application is shown.
[0072] Step 101: input the log entry generated by the test tool into a preset log parser to generate a log feature vector.
[0073] It should be noted that the code failure warning method of the embodiment of the present application can be executed by the code failure warning device of the embodiment of the present application. The code failure warning device of the embodiment of the present application can be configured in any terminal device to execute the code failure warning method of the embodiment of the present application.
[0074] Among them, the preset log parser is a deep learning model that is pre-trained with a large amount of log data in different formats, and can identify and parse log entries in different formats.
[0075] The log entries may be automatically generated by an automated testing tool during a test run of the code.
[0076] In a possible implementation, the log entries generated during the code test execution process may be input into a preset log parser, and the preset log parser extracts features from each log entry to generate a log feature vector.
[0077] Furthermore, the format of the log entry may be first identified, the components contained in the log entry may be extracted, and then the components may be converted into feature vectors respectively, thereby improving the accuracy of log feature vector extraction and further improving the accuracy of fault identification. That is, in a possible implementation of the embodiment of the present application, the above step 101 may include:
[0078] Step 1011, input the log entry into a preset log parser to identify the log format of the log entry;
[0079] Step 1012, extracting each component in the log entry;
[0080] Step 1013, converting each component into a feature vector;
[0081] Step 1014, concatenate the feature vectors corresponding to the various components to generate a log feature vector.
[0082] In one possible implementation, the log entry can be input into a preset log parser to identify the log format of the log entry, that is, the component category to which each part of the log entry belongs. After identifying the component category corresponding to each part, the content of each component can be extracted, and the content of each component can be converted into a corresponding feature vector respectively. The feature vectors are then concatenated in sequence to generate a log feature vector.
[0083] For example, assuming that the log entry input into the preset log parser is "2024-05-1010:30:45ERRORServer crashed:Could not connect to database", and the log format is identified as time component, log level component and text component, then the time component: "2024-05-1010:30:45", log level component: "ERROR" and text component: "ERROR Server crashed:Could not connect to database" can be extracted, converted into feature vectors respectively, and then spliced into a log feature vector.
[0084] Furthermore, the type of feature vector corresponding to each component category can be set to further improve the accuracy of log feature vector extraction and the accuracy of code fault identification. That is, in a possible implementation of the embodiment of the present application, the above components include a log level component, a text component and a time component, and the above feature vector includes a numerical feature vector, a text feature vector and a time series feature vector. The above step 1013 may include:
[0085] When the component includes a log level component, converting the log level component into a numerical feature vector;
[0086] When the component includes a text component, the text component is converted into a text feature vector through a preset word embedding model;
[0087] When the components include a time component, the time component is converted into a time series feature vector.
[0088] Among them, the log level component can be a component indicating the type of log entry; the text component can be a text component including log message content, etc.; the time component can be a component indicating time including a timestamp, etc.
[0089] In one possible implementation, when the component is a log-level component, the component can be converted into a numerical feature vector, that is, each content in the log-level component can be represented by a single numerical value. When the component is a text component, the words or phrases in the text component can be converted into a vector of fixed length through a pre-trained word embedding model (such as Word2Vec, GloVe or BERT, etc.), and the features can be further extracted through text processing technology (such as TF-IDF, n-grams, etc.) to generate a text feature vector. When the component is a time component, time series features such as time interval, frequency, etc. can be calculated to generate a time series feature vector.
[0090] As an example, the log level component may include words such as "DEBUG", "INFO", "WARN" and "ERROR" that represent the log entry type, and each log entry type can be represented by a single numerical value, such as "DEBUG=0", "INFO=1", "WARN=2" and "ERROR=3", that is, the numerical feature vector corresponding to "DEBUG" is 1, the numerical feature vector corresponding to "INFO" is 2, and so on.
[0091] Furthermore, log features may be extracted from log entries by using graph neural network technology. That is, in a possible implementation of the embodiment of the present application, the above step 101 may also include:
[0092] The log entries are input into the preset log parser, a log graph is constructed through the graph neural network, and features of the log entries are extracted based on the log graph to generate a log feature vector.
[0093] Among them, graph neural networks can include message passing, aggregation functions, update functions, and stacked multi-layer graph neural networks. Message passing refers to the transmission of information between nodes through edges. Each node updates its own feature vector according to the features of its neighbor nodes, which usually involves the aggregation and transformation of node features; the aggregation function is used to aggregate the features of neighbor nodes to the current node. Common aggregation functions include summation, average, maximum value, etc.; the update function refers to updating the feature vector of the node according to the aggregated neighbor features and the features of the current node, which usually involves linear transformation, nonlinear activation function (such as ReLU), etc.; by stacking multi-layer graph neural networks, more complex graph structure information can be captured. Each layer of graph neural network will update the feature vector of the node to a higher-level representation.
[0094] In a possible implementation, the log entries generated by the test tool can be input into a preset log parser, and a log graph including node definitions and edge definitions can be constructed through a graph neural network. Each log entry can be regarded as a node in the log graph. Specific log entries, such as errors, warnings, or entries of specific functions, can be defined as different types of nodes; the relationship between log entries can be represented by edges, for example, the function call relationship in the call stack can be constructed as a directed edge; the time order relationship between log entries can also be constructed as an edge. In addition, if some log entries logically belong to the same task or transaction, corresponding edges can also be constructed. The features of the log entries can be extracted based on the log graph. Specifically, for each node, its inherent features, such as log level, timestamp, message content, etc., can be extracted. These features can be directly used as the initial feature vector of the node; structural features can also be extracted based on the position of the node in the log graph or the relationship with other nodes. For example, the number of neighbors of the node and the log level distribution of the neighbors can be calculated. In the last layer of the graph neural network, each node has an updated feature vector, which is the log feature vector.
[0095] It should be noted that the log formats and component contents listed above are only exemplary. In actual use, the log format and component contents can be determined according to actual usage requirements and application scenarios, and the embodiments of the present application do not limit this.
[0096] Furthermore, before parsing the log entry, the difference version dependent file can be obtained and cached locally to facilitate subsequent fault analysis. That is, in a possible implementation of the embodiment of the present application, before the above step 101, it can also include:
[0097] Filter and analyze the difference code files, generate difference version dependency files and cache them locally.
[0098] The difference code file may be a file that has been changed before and after the code is submitted, and the difference version dependency file may be a file that has been changed before and after the code is submitted and contains version dependencies.
[0099] As a possible implementation method of the present application, you can first obtain the difference files before and after the code submission, that is, the difference code files, then filter and analyze the difference code files, extract the files containing version dependencies in the difference code files, that is, the difference version dependency files, and cache them locally.
[0100] For example, you can use command statements such as "git diff" to obtain the difference files before and after code submission.
[0101] Furthermore, for large projects, each submission will involve changes to many files. Directly analyzing these difference information is not only inefficient, but also easy to miss key information. Files can be extracted through regular expressions and other methods, and the extracted difference version dependency files can be classified, thereby improving the efficiency of subsequent code fault analysis. That is, in a possible implementation method of the embodiment of the present application, the above filtering and analyzing the difference code files, generating difference version dependency files and caching them locally can include:
[0102] By constructing regular expressions to filter the difference code files and / or analyzing the file extensions of the difference code files, a difference version dependency file is generated and cached locally;
[0103] After filtering and analyzing the difference code files, generating the difference version dependency files and caching them locally, the following can also be included:
[0104] Classify the difference version dependent files, determine the difference categories of the difference version dependent files, and cache the classification results locally, where the difference categories include addition, deletion, and modification.
[0105] In a possible implementation, a regular expression can be constructed to filter the difference code files through the regular expression to obtain the files containing version dependencies in the difference code files, or the file extensions of the difference code files can be analyzed to filter out the files containing version dependencies, generate the difference version dependency files and cache them locally. In this way, the efficiency of file screening can be improved.
[0106] As a possible implementation method, after filtering out the difference version dependent files, the difference version dependent files can also be classified to determine whether the file is a new file, a deleted file or a modified file, and its difference category can be judged. The difference categories include new, deleted and modified, and each difference version dependent file and the corresponding difference category can be cached locally.
[0107] Step 102: Identify the log feature vector and determine the abnormal log.
[0108] As a possible implementation method of the present application, the log feature vector can be input into an anomaly detection model. The anomaly detection model can be a pre-trained machine learning or deep learning model. A machine learning algorithm (such as a classifier algorithm, a clustering algorithm, or anomaly detection algorithm, etc.) can be used to identify abnormal log feature vectors and determine abnormal logs.
[0109] For example, if the log feature vector contains the log level "ERROR", and the message content contains feature vectors corresponding to keywords such as "Server crashed" and "Could not connect to database", the log entry corresponding to the log feature vector can be determined as an abnormal log.
[0110] Step 103: input the log feature vector corresponding to the abnormal log into the preset large model to generate the fault cause corresponding to the abnormal log.
[0111] As a possible implementation method, since the big model has powerful learning and reasoning capabilities, it can learn from massive historical data, dig out the hidden laws and patterns behind the data, and then make accurate predictions about future situations. Therefore, the big model can be trained in advance to generate a preset big model that meets the needs. The log feature vector corresponding to the abnormal log can be input into the preset big model to generate the fault cause corresponding to the abnormal log. In this way, not only the efficiency of problem handling can be improved, but also the accuracy of problem handling can be improved.
[0112] For example, the fault cause may include the associated code that caused the fault.
[0113] Step 104, matching the fault cause with the locally cached differential version dependency file, and determining the fault code in the differential version dependency file corresponding to the fault cause, wherein the differential version dependency file is a version dependency file that has been changed before and after the code is submitted.
[0114] In a possible implementation, the fault cause may be matched with a locally cached differential version dependency file. If the differential version dependency file contains a code corresponding to the fault cause, the code is determined as the fault code.
[0115] Step 105, sending the abnormal log and the fault code corresponding to the abnormal log to the tester for fault warning.
[0116] In a possible implementation, after determining that a fault code corresponding to an exception log exists in a differential version dependency file, the exception log and the fault code corresponding to the exception log may be sent to a designated tester through a test tool for code fault warning.
[0117] Furthermore, the fault code may be cached locally first, and then sent to the tester at a fixed time according to the requirements. That is, in a possible implementation of the embodiment of the present application, the above method further includes:
[0118] Input the log feature vector corresponding to the abnormal log into the preset large model to generate a solution corresponding to the abnormal log;
[0119] After the above step 104, the following steps may be included:
[0120] Save the exception log, the fault code corresponding to the exception log, and the solution to the local fault file;
[0121] The above step 105 may include:
[0122] Create a scheduled warning task, read the text content in the local fault file, and send the text content to the tester for fault warning.
[0123] As a possible implementation method, the log feature vector corresponding to the exception log can be input into the preset large model to generate the solution corresponding to the exception log, and all exception logs, fault codes corresponding to the exception logs and solutions can be saved in the local fault file to create a scheduled warning task. When the scheduled warning task is triggered, the exception logs, fault codes corresponding to the exception logs and solutions saved in the local fault file between the current time and the last time the scheduled warning task was triggered can be read and sent to the designated tester for fault warning.
[0124] For example, a solution might include updating the version of a third-party dependency.
[0125] As a possible implementation of the present application, the code fault warning method process provided by the present application can be as follows: Figure 2 As shown, first obtain the difference code file, determine whether there is a difference version dependent file in the difference code file, if not, end, if so, extract the log feature vector, determine the abnormal log according to the log feature vector, and input the log feature vector corresponding to the abnormal log into the preset large model, the preset large model generates the cause of the fault and the solution, caches the cause of the fault and the solution locally, sets the scheduled task, and issues a fault warning.
[0126] The code fault warning method provided in the embodiment of the present application parses and identifies the log entries, determines the abnormal logs, inputs the abnormal logs into the large model, generates the fault cause, matches the fault cause with the local cache file, determines the fault code, and sends the fault cause and fault code to the tester for active warning, thereby improving the accuracy of code fault warning and reducing maintenance costs, thereby improving code execution efficiency and product quality. In addition, each component contained in the log entry is extracted, the type of feature vector corresponding to each component category is set, and then each component is converted into a feature vector, thereby improving the accuracy of log feature vector extraction, further improving the accuracy of code fault identification, and then using the large model to generate a fault solution based on the abnormal log, improving the efficiency and correctness of fault handling, and determining the difference version dependent files through regular expressions, file extensions and other methods, thereby improving the efficiency of screening difference files.
[0127] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0128] Corresponding to the code failure early warning method in the above embodiment, Figure 3 A structural block diagram of a code fault warning device provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0129] Reference Figure 3 , the device 30 comprises:
[0130] A first generating module 31 is used to input the log entries generated by the test tool into a preset log parser to generate a log feature vector;
[0131] A first determination module 32 is used to identify the log feature vector and determine the abnormal log;
[0132] The second generating module 33 is used to input the log feature vector corresponding to the abnormal log into the preset large model to generate the fault cause corresponding to the abnormal log;
[0133] The second determination module 34 is used to match the fault cause with the locally cached difference version dependency file, and determine the fault code corresponding to the fault cause in the difference version dependency file, wherein the difference version dependency file is a version dependency file that has been changed before and after the code is submitted;
[0134] The early warning module 35 is used to send the abnormal log and the fault code corresponding to the abnormal log to the tester for fault early warning.
[0135] Specifically, in the first generation module 31, the preset log parser is a deep learning model pre-trained by a large amount of log data in different formats, which can identify and parse log entries in different formats. The log entries can be automatically generated by the automated testing tool during the test run of the code.
[0136] In actual use, the code fault warning device provided in the embodiment of the present application can be configured in any terminal device to execute the aforementioned code fault warning method.
[0137] The code fault warning device provided in the embodiment of the present application parses and identifies log entries, determines abnormal logs, inputs abnormal logs into a large model, generates fault causes, and sends the fault causes and fault codes to testers for active warnings, thereby improving the accuracy of code fault warnings and reducing maintenance costs, thereby improving code execution efficiency and product quality.
[0138] In a possible implementation form of the present application, the first generating module 31 includes:
[0139] An identification unit, used for inputting the log entry into a preset log parser to identify the log format of the log entry;
[0140] An extraction unit, used to extract individual components in a log entry;
[0141] A conversion unit, used to convert each component into a feature vector;
[0142] The first generating unit is used to concatenate the feature vectors corresponding to the various components to generate a log feature vector.
[0143] Specifically, the identification unit can input the log entry into a preset log parser to identify the log format of the log entry, that is, the component category to which each part of the log entry belongs. After identifying the component category corresponding to each part, the extraction unit can extract the content of each component, and the conversion unit converts the content of each component into a corresponding feature vector respectively. The first generation unit then splices the feature vectors in sequence to generate a log feature vector.
[0144] Further, in another possible implementation form of the present application, the above-mentioned components include a log level component, a text component and a time component, and the above-mentioned feature vector includes a numerical feature vector, a text feature vector and a time series feature vector; accordingly, the above-mentioned conversion unit is specifically used for:
[0145] When the component includes a log level component, converting the log level component into a numerical feature vector;
[0146] When the component includes a text component, the text component is converted into a text feature vector through a preset word embedding model;
[0147] When the components include a time component, the time component is converted into a time series feature vector.
[0148] It should be noted that the log level component may be a component indicating the type of log entry; the text component may be a text component including log message content, etc.; the time component may be a component indicating time including a timestamp, etc.
[0149] Furthermore, in another possible implementation form of the present application, the first generating module 31 further includes:
[0150] The second generating unit is used to input the log entry into a preset log parser, construct a log graph through a graph neural network, and extract features of the log entry according to the log graph to generate a log feature vector.
[0151] Specifically, in a possible implementation, the log entries generated by the test tool can be input into a preset log parser, and a log graph including node definitions and edge definitions can be constructed through a graph neural network. The features of the log entries can be extracted based on the log graph, and the inherent features of each node can be extracted; structural features can also be extracted based on the position of the node in the log graph or its relationship with other nodes to generate a log feature vector.
[0152] Furthermore, in another possible implementation form of the present application, the above-mentioned code failure warning device 30 further includes:
[0153] The third generation module is used to filter and analyze the difference code files, generate difference version dependency files and cache them locally, wherein the difference code files are files that have changed before and after the code is submitted.
[0154] Furthermore, in another possible implementation form of the present application, the third generating module includes:
[0155] The third generating unit is used to filter the difference code files and / or analyze the file extensions of the difference code files by constructing regular expressions, generate difference version dependency files and cache them locally;
[0156] The above-mentioned code failure warning device 30 further includes:
[0157] The cache module is used to classify the difference version dependent files, determine the difference categories of the difference version dependent files, and cache the classification results locally, where the difference categories include addition, deletion and modification.
[0158] Specifically, the third generation unit can construct a regular expression, filter the difference code files through the regular expression, and obtain the files containing version dependencies in the difference code files, or analyze the file extensions of the difference code files, filter out the files containing version dependencies, generate difference version dependency files and cache them locally.
[0159] In addition, in an embodiment of the present application, the cache module can classify the difference version dependent files, determine whether the file is a new file, a deleted file or a modified file, and judge its difference category, which includes new, deleted and modified, and cache each difference version dependent file and the corresponding difference category locally.
[0160] Furthermore, in another possible implementation form of the present application, the above-mentioned code failure warning device 30 further includes:
[0161] A fourth generation module is used to input the log feature vector corresponding to the abnormal log into a preset large model to generate a solution corresponding to the abnormal log;
[0162] A saving module is used to save the exception log, the fault code corresponding to the exception log and the solution to a local fault file;
[0163] The above-mentioned early warning module 35 includes:
[0164] The early warning unit is used to create a scheduled early warning task, read the text content in the local fault file, and send the text content to the tester for fault early warning.
[0165] Specifically, the saving module may save the abnormal log and its corresponding content to a local fault file first, and the warning unit may create a scheduled warning task and periodically read the local fault file for fault warning.
[0166] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0167] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0168] In order to implement the above embodiments, the present application also proposes a terminal device.
[0169] Figure 4 A schematic diagram of the structure of a terminal device according to an embodiment of the present application.
[0170] like Figure 4 As shown, the terminal device 200 includes:
[0171] A memory 210 and at least one processor 220, a bus 230 connecting different components (including the memory 210 and the processor 220), the memory 210 stores a computer program, and when the processor 220 executes the program, the code fault warning method described in the embodiment of the present application is implemented.
[0172] Bus 230 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnect (PCI) bus.
[0173] The terminal device 200 typically includes a variety of electronic device readable media, which can be any available media that can be accessed by the terminal device 200, including volatile and non-volatile media, removable and non-removable media.
[0174] The memory 210 may also include computer system readable media in the form of volatile memory, such as random access memory (RAM) 240 and / or cache memory 250. The terminal device 200 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 260 may be used to read and write non-removable, non-volatile magnetic media ( Figure 4 not shown, usually called a "hard drive"). Although Figure 4 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical medium) may be provided. In these cases, each drive may be connected to bus 230 via one or more data medium interfaces. Memory 210 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present application.
[0175] A program / utility 280 having a set (at least one) of program modules 270 may be stored, for example, in the memory 210, such program modules 270 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 270 generally perform the functions and / or methods of the embodiments described herein.
[0176] The terminal device 200 can also communicate with one or more external devices 290 (e.g., keyboard, pointing device, display 291, etc.), and can also communicate with one or more devices that enable users to interact with the terminal device 200, and / or communicate with any device that enables the terminal device 200 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be carried out through an input / output (I / O) interface 292. In addition, the terminal device 200 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN) and / or public network, such as the Internet) through a network adapter 293. As shown in the figure, the network adapter 293 communicates with other modules of the terminal device 200 through a bus 230. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the terminal device 200, including but not limited to: microcode, device driver, redundant processing unit, external disk drive array, RAID system, tape drive, and data backup storage system, etc.
[0177] The processor 220 executes various functional applications and data processing by running the programs stored in the memory 210 .
[0178] It should be noted that the implementation process and technical principles of the terminal device of this embodiment refer to the aforementioned explanation of the code fault warning method of the embodiment of the present application, and will not be repeated here.
[0179] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0180] An embodiment of the present application provides a computer program product. When the computer program product runs on a terminal device, the terminal device can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0181] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera / terminal device, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0182] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0183] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0184] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0185] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0186] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A code failure early warning method, characterized in that: include: Input the log entries generated by the test tool into the preset log parser to generate a log feature vector; Identify the log feature vector to determine abnormal logs; Inputting the log feature vector corresponding to the abnormal log into a preset large model to generate the fault cause corresponding to the abnormal log; Match the fault cause with the locally cached difference version dependency file, and determine the fault code corresponding to the fault cause in the difference version dependency file, wherein the difference version dependency file is a version dependency file that has been changed before and after the code is submitted; The abnormal log and the fault code corresponding to the abnormal log are sent to the tester for fault warning.
2. The method according to claim 1, characterized in that The step of inputting the log entry generated by the test tool into a preset log parser to generate a log feature vector includes: Inputting the log entry into the preset log parser to identify the log format of the log entry; Extracting components from the log entry; converting each of said components into a feature vector; The feature vectors corresponding to the various components are concatenated to generate the log feature vector.
3. The method according to claim 2, characterized in that The components include a log level component, a text component and a time component, the feature vector includes a numerical feature vector, a text feature vector and a time series feature vector, and converting each of the components into a feature vector includes: When the component includes the log level component, converting the log level component into the numerical feature vector; When the component includes the text component, converting the text component into the text feature vector by using a preset word embedding model; When the components include the time component, the time component is converted into the time series feature vector.
4. The method according to claim 1, characterized in that The step of inputting the log entries generated by the test tool into a preset log parser to generate a log feature vector also includes: The log entry is input into the preset log parser, a log graph is constructed through a graph neural network, and features of the log entry are extracted according to the log graph to generate the log feature vector.
5. The method according to claim 1, characterized in that The step of inputting the log entry generated by the test tool into a preset log parser and generating a log feature vector further includes: The difference code files are filtered and analyzed to generate the difference version dependency files and cache them locally, wherein the difference code files are files that have been changed before and after the code is submitted.
6. The method according to claim 5, characterized in that The filtering and analyzing of the difference code files, generating the difference version dependency files and caching them locally, includes: Filter the difference code file by constructing a regular expression and / or analyze the file extension of the difference code file, generate the difference version dependency file and cache it locally; After filtering and analyzing the difference code files, generating the difference version dependency files and caching them locally, the method further includes: The difference version dependent files are classified, the difference categories of the difference version dependent files are determined, and the classification results are cached locally, wherein the difference categories include addition, deletion and modification.
7. The method according to claim 1, characterized in that The method further comprises: Inputting the log feature vector corresponding to the abnormal log into a preset large model to generate a solution corresponding to the abnormal log; After matching the fault cause with the locally cached difference version dependency file and determining the fault code corresponding to the fault cause in the difference version dependency file, the method further includes: Saving the exception log, the fault code corresponding to the exception log, and the solution to a local fault file; The sending of the abnormal log and the fault code corresponding to the abnormal log to the tester for fault warning includes: Create a scheduled warning task, read the text content in the local fault file, and send the text content to the tester for fault warning.
8. A code failure warning device, characterized in that: include: A first generating module, used for inputting the log entries generated by the test tool into a preset log parser to generate a log feature vector; A first determination module, used to identify the log feature vector and determine abnormal logs; A second generating module, used for inputting the log feature vector corresponding to the abnormal log into a preset large model to generate a fault cause corresponding to the abnormal log; A second determination module is used to match the fault cause with a locally cached difference version dependency file, and determine a fault code corresponding to the fault cause in the difference version dependency file, wherein the difference version dependency file is a version dependency file that has changed before and after the code is submitted; The early warning module is used to send the abnormal log and the fault code corresponding to the abnormal log to the tester for fault early warning.
9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the terminal device implements the method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by an electronic device, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Abnormality processing method, electronic equipment and server
CN119473693A
