Abnormal link tracking method, system, gateway and storage medium
By obtaining service identification and link information when receiving exception responses from the first microservice in the microservice architecture, building exception responses and sending them to the gateway, the problem of insufficient link tracing in the front-end is solved, and efficient exception tracking and summary display are achieved.
Patent Information
- Application Number
- CN202210632907.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-07
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2042-06-07
AI Technical Summary
Under the existing microservice architecture, the front-end-initiated exception link tracking method cannot effectively support the tracking of exception requests, resulting in poor tracking results.
When the first microservice receives the exception response of the second microservice, the service identification and exception process link information associated with the second microservice are obtained, the exception response is constructed and sent to the gateway, and the exception information of different microservices is connected through the link, and the exception is tracked from the root.
It improves the effect of exception tracking, can track exceptions from the bottom layer, saves the computing resources required for link aggregation, and generates exception summary information through the gateway to display it to the front-end device.
Smart Images

Figure CN115033410B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of microservice technology, and in particular to a method, system, gateway, and storage medium for tracking abnormal links. Background Art
[0002] With the development of microservices architecture, services are being split along different dimensions, and requests must sequentially traverse multiple services. While microservices architectures offer benefits for software development, they also introduce challenges not present in monolithic architectures. One of these challenges is clearly identifying which microservice instances support an external request and in what order, helping developers understand runtime timing within a microservices architecture. This has led to the emergence of link tracing within a microservices architecture. Currently, link tracing is primarily initiated by the frontend. A tracing marker is generated at the first microservice that captures an external request, and this marker is propagated and recorded between and within processes to facilitate later link aggregation. This effectively supports normal requests. However, for abnormal requests, using the frontend to initiate link tracing is difficult due to the unpredictable nature of the exceptions, making it difficult to effectively trace these abnormal requests. Summary of the Invention
[0003] The embodiments of the present application provide a method, system, gateway, and storage medium for tracking abnormal links, aiming to solve the problem of insufficient support for abnormal requests caused by the front-end initiating abnormal link tracking.
[0004] The present application provides a method for tracing abnormal links applied to microservices, the method comprising:
[0005] When the first microservice receives the first exception response sent by the second microservice, obtaining the first service identifier and first exception process link information associated with the second microservice based on the first exception response;
[0006] Constructing a second exception response according to the first service identifier and the first abnormal process link information;
[0007] The second exception response is sent to the gateway.
[0008] Optionally, when the first microservice receives the first exception response sent by the second microservice, before the step of obtaining the first service identifier and first exception process link information associated with the second microservice based on the first exception response, the method further includes:
[0009] Obtain the computer status of each time point from the start time of the abnormal process to the time when the abnormal process runs abnormally;
[0010] generating the first abnormal process link information according to the computer status at each time point;
[0011] Generate a first service identifier corresponding to the first abnormal process link information;
[0012] Constructing the first exception response according to the first abnormal process link information and the first service identifier;
[0013] Send the first exception response to the first microservice.
[0014] Optionally, the step of constructing a second exception response according to the first service identifier and the first abnormal process link information includes:
[0015] generating second abnormal process link information according to the first service identifier and the first abnormal process link information;
[0016] Generate a second service identifier corresponding to the second abnormal process link information;
[0017] The second exception response is constructed according to the first service identifier, the first abnormal process link information, the second service identifier and the second abnormal process link information.
[0018] In addition, to achieve the above-mentioned purpose, the present application also provides a method for tracking abnormal links applied to a gateway, the method for tracking abnormal links comprising:
[0019] Upon receiving the second exception response sent by the microservice, generating exception summary information corresponding to the second exception response;
[0020] The exception summary information is sent to a front-end device so that the exception summary information is displayed on the front-end device.
[0021] Optionally, upon receiving the second exception response sent by the microservice, generating a universally unique identification code and an exception description corresponding to the second exception response;
[0022] Optionally, the universal unique identifier and the exception description are sent to a front-end device, so that the exception summary information is displayed on the front-end device.
[0023] In one embodiment, the method further comprises:
[0024] Upon receiving the second exception response sent by the microservice, parsing the second exception response to obtain the first service identifier, the first abnormal process link information, the second service identifier, and the second abnormal process link information;
[0025] Generate abnormal link information based on the first service identifier, the first abnormal process link information, the second service identifier, the second abnormal process link information, the request context and the universal unique identification code corresponding to the second abnormal response.
[0026] In one embodiment, after the step of generating abnormal link information based on the first service identifier, the first abnormal process link information, the second service identifier, the second abnormal process link information, the request context, and the universally unique identifier corresponding to the second abnormal response in the second abnormal response, the step further includes:
[0027] The abnormal link information is written into a persistent component, so as to store the abnormal link information through the persistent component.
[0028] In addition, to achieve the above-mentioned purpose, the present invention further provides a tracking system for abnormal links, the tracking system for abnormal links comprising:
[0029] A first generating module is configured to generate exception summary information and exception link information upon receiving an exception response of a first service sent by a microservice end, wherein the exception response of the first service is generated based on the exception response of the second service, and the exception response of the second service is generated based on the exception information of the second service and the second service information;
[0030] A first sending module is configured to send the exception summary information to a front-end device, so that the front-end device performs exception processing based on the exception summary information;
[0031] A second generating module is configured to generate exception summary information corresponding to a second exception response when receiving the second exception response sent by the microservice;
[0032] The second sending module is configured to send the exception summary information to a front-end device so as to display the exception summary information on the front-end device.
[0033] In addition, to achieve the above-mentioned purpose, the present invention also provides a gateway comprising: a memory, a processor, and an abnormal link tracking program stored on the memory and runnable on the processor, wherein the abnormal link tracking program implements the steps of the above-mentioned abnormal link tracking method when executed by the processor.
[0034] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, which stores a tracking program for abnormal links. When the tracking program for abnormal links is executed by a processor, it implements the steps of the abnormal link tracking method described in the above claims.
[0035] A technical solution for tracking an abnormal link, a system, a gateway, and a storage medium provided in an embodiment of the present application is adopted. When a first microservice receives a first abnormal response sent by a second microservice, the first service identifier and the first abnormal process link information associated with the second microservice are obtained according to the first abnormal response, a second abnormal response is constructed according to the first service identifier and the first abnormal process link information, and then the second abnormal response is sent to the gateway. Since the second abnormal response includes not only the identifier and link information of the second microservice at the bottom layer, but also the identifier and link information of the first microservice at the middle layer, bubbling starts from the bottom layer, and by connecting the abnormal information of different microservices through links, the trace is started from the root of the abnormality. The problem of insufficient support for abnormal requests caused by the front-end initiating abnormal link tracking is solved, thereby improving the abnormal tracking effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 A schematic diagram of the structure of a gateway involved in an embodiment of the present invention;
[0037] Figure 2 1 is a flow chart of a first embodiment of a method for tracking abnormal links according to the present invention;
[0038] Figure 3 1. A flow chart of a second embodiment of a method for tracking abnormal links according to the present invention;
[0039] Figure 4 Schematic diagram of the process of abnormal request in the abnormal link tracking method of the present invention;
[0040] Figure 5 This is a functional module diagram of the abnormal link tracking system of the present invention.
[0041] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. The above-mentioned drawings are only an embodiment diagram, not the entire invention. DETAILED DESCRIPTION
[0042] In order to solve the problem of insufficient support for abnormal requests caused by link tracking initiated by the front end, the present application proposes a method for tracking abnormal links. When a first microservice receives a first abnormal response sent by a second microservice, the first service identifier and the first abnormal process link information associated with the second microservice are obtained according to the first abnormal response, and a second abnormal response is constructed according to the first service identifier and the first abnormal process link information, and then the second abnormal response is sent to the gateway. Since the second abnormal response includes not only the identifier and link information of the second microservice at the bottom layer, but also the identifier and link information of the first microservice at the middle layer, bubbling starts from the bottom layer, by connecting the abnormal information of different microservices through links, tracing is started from the root of the abnormality, thereby improving the abnormal tracking effect.
[0043] To better understand the above technical solutions, exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments described herein. Instead, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0044] like Figure 1 As shown, Figure 1 This is a schematic diagram of the structure of the hardware operating environment involved in the embodiment of the present invention.
[0045] It should be noted that Figure 1 This is a structural diagram of the gateway's hardware operating environment.
[0046] like Figure 1 As shown, the gateway may include: a processor 1001, such as a CPU, a memory 1005, a user interface 1003, a network interface 1004, and a communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the user interface 1003 may optionally include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may optionally be a storage device independent of the aforementioned processor 1001.
[0047] Those skilled in the art will understand that Figure 1The gateway structure shown in the figure does not constitute a limitation to the gateway, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0048] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating system, a network communication module, a user interface module, and an abnormal link tracking program. The operating system is a program that manages and controls the hardware and software resources of the gateway, and the abnormal link tracking program and other software or programs are executed.
[0049] exist Figure 1 In the gateway shown, the user interface 1003 is mainly used to connect to the terminal and communicate data with the terminal; the network interface 1004 is mainly used to communicate data with the background server; the processor 1001 can be used to call the abnormal link tracking program stored in the memory 1005.
[0050] In this embodiment, the gateway includes: a memory 1005, a processor 1001, and an abnormal link tracking program stored in the memory and executable on the processor, wherein:
[0051] When the processor 1001 calls the abnormal link tracking program stored in the memory 1005, it performs the following operations:
[0052] Upon receiving the second exception response sent by the microservice, generating exception summary information corresponding to the second exception response;
[0053] The exception summary information is sent to a front-end device so that the exception summary information is displayed on the front-end device.
[0054] When the processor 1001 calls the abnormal link tracking program stored in the memory 1005, it further performs the following operations:
[0055] Upon receiving the second exception response sent by the microservice, generating a universally unique identification code and an exception description corresponding to the second exception response;
[0056] The universal unique identifier and the exception description are sent to a front-end device, so that the exception summary information is displayed on the front-end device.
[0057] When the processor 1001 calls the abnormal link tracking program stored in the memory 1005, it further performs the following operations:
[0058] Upon receiving the second exception response sent by the microservice, parsing the second exception response to obtain the first service identifier, the first abnormal process link information, the second service identifier, and the second abnormal process link information;
[0059] Generate abnormal link information based on the first service identifier, the first abnormal process link information, the second service identifier, the second abnormal process link information, the request context and the universal unique identification code corresponding to the second abnormal response.
[0060] When the processor 1001 calls the abnormal link tracking program stored in the memory 1005, it further performs the following operations:
[0061] The abnormal link information is written into a persistent component, so as to store the abnormal link information through the persistent component.
[0062] The technical solution of this application will be described in detail below by way of embodiments.
[0063] like Figure 2 As shown, in the first embodiment of the present application, the abnormal link tracking method of the present application, when applied to the microservice end, includes the following steps:
[0064] Step S110: When the first microservice receives the first exception response sent by the second microservice, the first service identifier and first exception process link information associated with the second microservice are obtained based on the first exception response.
[0065] In this embodiment, the components involved in this application include a first microservice, a second microservice, a gateway, a persistence component, and a front-end device.
[0066] Microservices are a cloud-native architectural approach in which a single application is composed of many loosely coupled, independently deployable smaller components or services. These microservices typically have their own processes and stacks, including databases and data models. Microservices communicate with each other using HTTP-based RESTful APIs. Microservices are organized by business capabilities, and the lines separating microservices are often called bounded contexts.
[0067] The second microservice of the present application can be called by the first microservice, and the number of second microservices can be one or more. The second microservice is the lowest-level service. The first microservice is an intermediate-level service. The first microservice can be connected to a gateway, and the number of first microservices can be one or more. The corresponding number of second microservices or first microservices can be selected based on the processing power of the microservice end or according to actual development needs.
[0068] In this embodiment, calls are nested between the various microservices of the present application. In order to quickly track the exception link when an exception occurs, the present application captures the exception and constructs a first exception response when an exception occurs in the second microservice; and sends the first exception response to the first microservice. When the first microservice receives the first exception response, it parses the first exception response and obtains the first service identifier and first exception process link information related to the second microservice. Among them, the first exception response is generated by the second microservice. The first exception response includes the first service identifier of the second microservice and the first exception process link information of the second microservice. The first exception process link information is the computer status information corresponding to each time point in the exception process. The first exception process link information is also the stack information of the second microservice.
[0069] Optionally, when the first microservice receives the first exception response sent by the second microservice, before obtaining the first service identifier and first exception process link information associated with the second microservice based on the first exception response, the following steps are further included, that is, the following steps are steps for generating the first exception response corresponding to the second microservice:
[0070] Step S210: obtaining the computer status at each time point from the start time point of the abnormal process to the time point of the abnormal process.
[0071] In this embodiment, when the request initiator corresponding to the front-end device initiates any request, the request is forwarded by the gateway to the first microservice, which then processes the request. When processing the request, the first microservice calls the second microservice. If an exception occurs in the second microservice, the request is considered an abnormal request. The second microservice captures the exception information, which becomes the first abnormal link information. It constructs the first abnormal response based on the exception information and the second service name of the second microservice itself.
[0072] In this embodiment, whether a request is an abnormal request can be determined based on the computer status. For example, the computer status can be represented by a status code, with different status codes representing different meanings. When the status code is greater than a preset threshold, the request is considered abnormal. When the status code is less than a preset threshold, the request is considered normal. For example, the preset threshold can be set to 400. If the request is determined to be normal, link tracing is performed starting from the front-end device. If the request is determined to be abnormal, abnormal link tracing is performed starting from the lowest level.
[0073] Specifically, the computer status of the abnormal process corresponding to the abnormal request is obtained at each time point from the start of operation to the abnormal operation time point. The start of operation time point is the time point corresponding to when the abnormal process starts to run, and the abnormal operation time point is the time point corresponding to when the abnormal process becomes abnormal. During the operation of the process, the computer status corresponding to each time point will be recorded in real time. The recorded computer status can be cached in a local database or stored in the database corresponding to the microserver. When the process is an abnormal process, the computer status of the abnormal process at each time point from the start of operation to the abnormal operation time point will be obtained from the corresponding database.
[0074] Step S220: Generate the first abnormal process link information according to the computer status at each time point.
[0075] In this embodiment, after obtaining the computer status at each time point from the start of operation to the time point of the abnormal operation, the computer status is concatenated based on the chronological order of the corresponding time points to generate the first abnormal process link information. Specifically, each time point corresponds to a function, and the functions at each time point are nested during operation, ultimately forming a process stack. This process stack is the first abnormal process link information.
[0076] Step S230: Generate a first service identifier corresponding to the first abnormal process link information.
[0077] In this embodiment, after generating the first abnormal process link information, a corresponding first service identifier is generated for the first abnormal process link information. The first service identifier can be established based on the name of the second microservice corresponding to the first abnormal process link information, that is, the first service identifier is the first service name, that is, the name of the second microservice. After generating the first service identifier, the first abnormal process link information is associated with the first service identifier.
[0078] Step S240: Construct the first abnormal response according to the first abnormal process link information and the first service identifier.
[0079] In this embodiment, after the first abnormal process link information and the first service identifier are generated, a first abnormal response is constructed according to the first abnormal process link information and the first service identifier.
[0080] Step S250: Send the first exception response to the first microservice.
[0081] In this embodiment, after constructing the first exception response, the first exception response is sent to the first microservice. Specifically, the microservices communicate with each other using a RESTful API communication mechanism based on HTTP, and the first exception response is sent to the first microservice based on this method.
[0082] According to the above technical solution, this application can bubble up the request from the lowest end when an exception occurs, locate the exception at the root, and encapsulate the exception into a first exception response and send it to the second microservice, thereby improving the exception tracking effect. In addition, the first exception process link information is integrated into the first exception response, and link aggregation can be completed without the need for third-party storage, saving a large amount of computing resources required for link aggregation.
[0083] Step S120: Construct a second abnormal response according to the first service identifier and the first abnormal process link information.
[0084] In this embodiment, after parsing the first exception response, the first microservice parses and rethrows the exception. The rethrown exception includes the exception response of the called microservice, namely, the first exception response of the second microservice, so that a complete exception chain can be formed at the gateway. Specifically, after obtaining the first service identifier and the first exception process chain information, the first microservice constructs the second exception response based on the first service identifier and the first exception process chain information. The second exception response is constructed in the same manner as the first exception response.
[0085] Optionally, constructing a second abnormal response according to the first service identifier and the first abnormal process link information may specifically include the following steps:
[0086] Step S121: Generate second abnormal process link information according to the first service identifier and the first abnormal process link information.
[0087] In this embodiment, the second abnormal process link information is the link information of the second microservice itself; the second microservice can generate the second abnormal process link information based on the first service identifier and the first abnormal process link information. Because the first microservice can call multiple second microservices, each second microservice corresponds to a different identifier. Therefore, the corresponding first abnormal process link information can be obtained based on the first service identifier. The second abnormal process link information corresponding to the first microservice can be generated based on the first abnormal process link information of the second microservice and combined with its own abnormal process link information.
[0088] Step S122: Generate a second service identifier corresponding to the second abnormal process link information.
[0089] In this embodiment, after generating the second abnormal process link information, a corresponding second service identifier is generated for the second abnormal process link information. The second service identifier can be established based on the name of the first microservice corresponding to the second abnormal process link information, that is, the second service identifier is the second service name, that is, the name of the first microservice. After generating the second service identifier, the second abnormal process link information is associated with the second service identifier.
[0090] Step S123: construct the second abnormal response according to the first service identifier, the first abnormal process link information, the second service identifier, and the second abnormal process link information.
[0091] In this embodiment, after generating the second abnormal process link information and the second service identifier, the second abnormal response is generated based on the first service identifier, the first abnormal process link information, the second service identifier, and the second abnormal process link information. When a request encounters an exception, the abnormal information is responded to layer by layer across processes until it reaches the original caller, thereby forming a complete call link in reverse. In addition, the link information is integrated into the abnormal response, and link aggregation can be completed without the need for third-party storage, saving a large amount of computing resources required for link aggregation.
[0092] Step S130: Send the second exception response to the gateway.
[0093] In this embodiment, after the second exception response is generated, the second exception response is sent to the gateway. The second exception response can be sent to the gateway in the form of a data packet. When the gateway receives the data packet, it parses the data packet to obtain the second exception response and related information in the second exception response. Among them, the sending rules for the first microservice to send the second exception response to the gateway can be set, for example, the time to send the response, the number of times the exception response is sent, etc. can be set. Information such as the sender address and the receiver address can also be configured at the gateway so that the gateway can smoothly receive the second exception response sent by the first microservice.
[0094] According to the above technical solution, this embodiment adopts the method of obtaining the first service identifier and the first abnormal process link information associated with the second microservice according to the first abnormal response when the first microservice receives the first abnormal response sent by the second microservice, constructing the second abnormal response according to the first service identifier and the first abnormal process link information, and then sending the second abnormal response to the gateway. Since the second abnormal response includes not only the identifier and link information of the second microservice at the bottom layer, but also the identifier and link information of the first microservice at the middle layer, bubbling starts from the bottom layer, and by connecting the abnormal information of different microservices through links, tracing is started from the root of the abnormality. This solves the problem of insufficient support for abnormal requests caused by the front-end initiating link tracking, thereby improving the abnormality tracking effect.
[0095] like Figure 3 As shown, in the second embodiment of the present application, based on the first embodiment, the abnormal link tracking method of the present application, when applied to the gateway, includes the following steps:
[0096] Step S310: When receiving the second exception response sent by the microservice, generate exception summary information corresponding to the second exception response.
[0097] In this embodiment, when the gateway receives the second exception response sent by the microservice (specifically the first microservice), the second exception response is rewritten to generate exception summary information corresponding to the second exception response. In order to avoid sending the abnormal link information to the front-end device, which leads to information security issues. Therefore, the gateway needs to rewrite the abnormal link information in the second exception response. The rewriting mainly hides the main information in the second exception response, that is, the abnormal link information, so that only the abnormal summary information corresponding to the exception is sent to the front-end device.
[0098] Optionally, the exception summary information includes a universally unique identifier and an exception description. The exception description is mainly used to remind users or R&D personnel on the front end that an exception has occurred, but it will not specifically describe which link the exception occurred in or what the specific exception is. For example, the exception description can be prompts such as "the system crashed" or "the webpage ran away". The universally unique identifier is referred to as UUID (Universally Unique Identifier). It is a software construction standard. Its purpose is to allow all elements in a distributed system to have unique identification information without the need for a central control terminal to specify the identification information. The universally unique identifier can be calculated and generated based on data such as the current time, counter, and hardware identification (usually the MAC address of the wireless network card). Optionally, when receiving the second exception response sent by the microservice, the exception summary information corresponding to the second exception response is generated, including:
[0099] Step S311: upon receiving the second exception response sent by the microservice, a universally unique identifier and an exception description corresponding to the second exception response are generated.
[0100] In this embodiment, upon receiving the second exception response from the first microservice, the gateway generates a universally unique identifier (UUID) for the exception. Simultaneously, the gateway rewrites the exception response to obtain an exception description. The UUID and exception description are then returned to the front-end device.
[0101] Step S320: Send the exception summary information to a front-end device so that the exception summary information is displayed on the front-end device.
[0102] In this embodiment, the gateway can send the exception summary information to the front-end device in the form of a data packet. The gateway can pre-set the receiving address of the front-end device and the source address of the gateway. The data packet is sent based on the receiving address and the source address. After receiving the data packet, the front-end device parses the data packet to obtain the exception summary information. The content of the exception summary information can be displayed on the display interface of the front-end device. Users or R&D personnel can determine the corresponding exception handling action based on the exception summary information. The front-end device can be a device with a display, such as a desktop computer, a smartphone, or a laptop.
[0103] Optionally, sending the exception summary information to a front-end device so as to display the exception summary information on the front-end device specifically includes:
[0104] Step S321 : Send the universal unique identifier and the exception description to a front-end device, so that the exception summary information is displayed on the front-end device.
[0105] In this embodiment, after receiving the exception summary information sent by the gateway, the front-end device can determine the corresponding exception description based on the universal unique identifier in the exception summary information, as there may be multiple exception summaries. The exception description is displayed on the display interface of the front-end device.
[0106] According to the above technical solution, this embodiment adopts a technical means of generating exception summary information corresponding to the second exception response when receiving the second exception response sent by the microservice, sending the exception summary information to the front-end device and displaying the exception summary information. When a request encounters an exception, the exception information is responded to layer by layer across processes until the original caller, forming a complete call chain in reverse, thereby improving the exception tracking effect.
[0107] In one embodiment, after generating the abnormal summary information, the gateway also generates abnormal link information. Specifically, generating the abnormal link information includes the following steps:
[0108] Step S410: When receiving the second exception response sent by the microservice, parse the second exception response to obtain the first service identifier, the first exception process link information, the second service identifier, and the second exception process link information.
[0109] In this embodiment, when the second abnormal response sent by the first microservice is received, the second abnormal response is parsed to obtain the first service identifier, the first abnormal process link information, the second service identifier, and the second abnormal process link information.
[0110] Step S420: Generate abnormal link information based on the first service identifier, the first abnormal process link information, the second service identifier, the second abnormal process link information, the request context and the universal unique identifier corresponding to the second abnormal response in the second abnormal response.
[0111] In this embodiment, the gateway constructs abnormal link details, including a universal unique identifier, a second abnormal response, and a request context. Specifically, after obtaining the first service identifier, the first abnormal process link information, the second service identifier, and the second abnormal process link information, the abnormal link information is generated based on the request context and the universal unique identifier. The abnormal link information includes the first abnormal process link information and the second abnormal process link information, that is, the complete information of the entire abnormal link. R&D personnel can view the abnormal link information and locate the specific abnormality based on the abnormal link information.
[0112] In one embodiment, after the step of generating abnormal link information according to the first service identifier, the first abnormal process link information, the second service identifier, the second abnormal process link information, the request context, and the universally unique identifier corresponding to the second abnormal response in the second abnormal response, the method further includes:
[0113] Step S510: writing the abnormal link information into a persistent component, so as to store the abnormal link information through the persistent component.
[0114] In this embodiment, after the abnormal link information is generated, it is written to a persistent component. The gateway captures the abnormal response and, for security reasons, rewrites the response to return only a summary of the front-end device exception, but fully records the abnormal link details to the persistent component for review. The persistent component is a general session component that implements basic database read and write access. It can implement basic operations such as reading or writing data in any database through a large number of method overloads. By writing the abnormal link information to the persistent component, data backup and storage are achieved, allowing subsequent R&D personnel to locate the anomaly.
[0115] In one embodiment, referring to Figure 4 , Figure 4 This is a flow chart of abnormal request in the abnormal link tracking method of this application.
[0116] The second microservice mainly performs the following operations: 1. An in-process exception occurs; 2. The exception is captured; 3. A first exception response is constructed, including the first in-process exception process link information and the first service identifier; 4. The first exception response is made.
[0117] The first microservice mainly performs the following operations: 1. Capture the first exception response of the second microservice, parse it and re-throw it as an exception; 2. Capture the exception; 3. Construct a second exception response, including the second exception process link information and the second service identifier within the process; 4. Make a second exception response.
[0118] The gateway mainly performs the following operations: intercepts the second exception response, generates a universal unique identifier, returns the exception summary information to the front-end device, and persists the exception link information.
[0119] The front-end device mainly performs the following operations: If the request status is greater than or equal to 400, it is handled as an exception.
[0120] from Figure 4 As you can see, the tracing chain goes from the second microservice to the first microservice, then to the gateway, and finally to the front-end device. When a request encounters an exception, the exception information is relayed layer by layer across processes until it reaches the original caller, completing the call chain in reverse.
[0121] The embodiment of the present invention provides an embodiment of a method for tracking abnormal links. It should be noted that although a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in an order different from that shown here.
[0122] like Figure 5 As shown, the present application provides a tracking system for abnormal links, and the tracking system for abnormal links includes:
[0123] The first generation module 10 is configured to generate exception summary information and exception link information upon receiving an exception response from the first service sent by the microservice end, wherein the exception response from the first service is generated based on the exception response from the second service, and the exception response from the second service is generated based on the exception information from the second service and the second service information. Optionally, the first generation module 10 is further configured to generate second exception process link information based on the first service identifier and the first exception process link information; generate a second service identifier corresponding to the second exception process link information; and construct the second exception response based on the first service identifier, the first exception process link information, the second service identifier, and the second exception process link information.
[0124] Optionally, after the first generation module 10, a first exception response generation module is also connected, and the first exception response generation module is used to obtain the computer status of the abnormal process at each time point from the start running time point to the running abnormal time point; generate the first abnormal process link information according to the computer status at each time point; generate the first service identifier corresponding to the first abnormal process link information; construct the first exception response according to the first abnormal process link information and the first service identifier; and send the first exception response to the first microservice.
[0125] The first sending module 20 is configured to send the exception summary information to a front-end device, so that the front-end device performs exception processing based on the exception summary information.
[0126] The second generation module 30 is configured to generate exception summary information corresponding to the second exception response upon receiving the second exception response sent by the microservice. The second generation module 30 is further configured to generate a universally unique identifier and an exception description corresponding to the second exception response upon receiving the second exception response sent by the microservice.
[0127] The second sending module 40 is configured to send the exception summary information to the front-end device so that the exception summary information is displayed on the front-end device. The second sending module 40 is also configured to send the universal unique identifier and the exception description to the front-end device so that the exception summary information is displayed on the front-end device.
[0128] In one embodiment, the abnormal link tracking system also includes an abnormal link information generation module, which is used to parse the second abnormal response sent by the microservice when receiving the second abnormal response, and obtain the first service identifier, the first abnormal process link information, the second service identifier and the second abnormal process link information; generate the abnormal link information according to the first service identifier, the first abnormal process link information, the second service identifier, the second abnormal process link information, the request context and the universal unique identification code corresponding to the second abnormal response in the second abnormal response.
[0129] In one embodiment, the abnormal link tracking system further includes a writing module, which is used to write the abnormal link information into a persistent component, so as to store the abnormal link information through the persistent component.
[0130] The specific implementation of the abnormal link tracking system of the present invention is basically the same as the various embodiments of the abnormal link tracking method described above, and will not be repeated here.
[0131] Based on the same inventive concept, an embodiment of the present application also provides a computer-readable storage medium, which stores a tracking program for abnormal links. When the tracking program for abnormal links is executed by a processor, it implements the various steps of the abnormal link tracking method described above and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0132] Since the storage medium provided in the embodiments of this application is the storage medium used to implement the method of the embodiments of this application, those skilled in the art will be able to understand the specific structure and variations of the storage medium based on the method described in the embodiments of this application, and therefore will not be described in detail here. All storage media used in the method of the embodiments of this application fall within the scope of protection to be provided by this application.
[0133] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0134] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0135] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0136] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0137] It should be noted that in the claims, any reference signs placed between parentheses shall not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claim. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The invention can be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by one and the same item of hardware. The use of the words first, second, third etc. does not indicate any order. These words may be interpreted as names.
[0138] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0139] Obviously, those skilled in the art may make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if such changes and modifications fall within the scope of the claims and their equivalents, the present invention is intended to include such changes and modifications.
Claims
1. A method for tracking abnormal links, characterized in that: Applied to microservices, the method includes: When the first microservice receives the first exception response sent by the second microservice, obtaining the first service identifier and first exception process link information associated with the second microservice based on the first exception response; generating second abnormal process link information according to the first service identifier and the first abnormal process link information, wherein the second abnormal process link information is generated according to the first abnormal process link information of the second microservice and in combination with the abnormal process link information of the first microservice itself; Generate a second service identifier corresponding to the second abnormal process link information; Constructing a second abnormal response according to the first service identifier, the first abnormal process link information, the second service identifier, and the second abnormal process link information; The second exception response is sent to the gateway.
2. The abnormal link tracking method according to claim 1, characterized in that: Before the step of obtaining the first service identifier and first abnormal process link information associated with the second microservice based on the first abnormal response when the first microservice receives the first abnormal response sent by the second microservice, the method further includes: Obtain the computer status of each time point from the start time of the abnormal process to the time when the abnormal process runs abnormally; generating the first abnormal process link information according to the computer status at each time point; Generate a first service identifier corresponding to the first abnormal process link information; Constructing the first exception response according to the first abnormal process link information and the first service identifier; Send the first exception response to the first microservice.
3. A method for tracking abnormal links, characterized in that: The method according to claim 1 or 2, applied to a gateway, the method comprising: Upon receiving the second exception response sent by the microservice, generating exception summary information corresponding to the second exception response; The exception summary information is sent to a front-end device so that the exception summary information is displayed on the front-end device.
4. The abnormal link tracking method according to claim 3, characterized in that: The exception summary information includes a universal unique identifier and an exception description. When receiving the second exception response sent by the microservice, the exception summary information corresponding to the second exception response is generated, including: Upon receiving the second exception response sent by the microservice, generating a universally unique identification code and an exception description corresponding to the second exception response; The step of sending the exception summary information to the front-end device so as to display the exception summary information on the front-end device includes: The universal unique identifier and the exception description are sent to a front-end device, so that the exception summary information is displayed on the front-end device.
5. The abnormal link tracking method according to claim 4, characterized in that: The method further comprises: Upon receiving the second exception response sent by the microservice, parsing the second exception response to obtain the first service identifier, the first abnormal process link information, the second service identifier, and the second abnormal process link information; After obtaining the first service identifier, the first abnormal process link information, the second service identifier, and the second abnormal process link information in the second abnormal response, abnormal link information is generated according to the request context and the universal unique identification code corresponding to the second abnormal response.
6. The abnormal link tracking method according to claim 5, characterized in that: After obtaining the first service identifier, the first abnormal process link information, the second service identifier, and the second abnormal process link information in the second abnormal response, and generating abnormal link information according to the request context and the universally unique identifier corresponding to the second abnormal response, the method further includes: The abnormal link information is written into a persistent component, so as to store the abnormal link information through the persistent component.
7. A tracking system for abnormal links, characterized in that: The abnormal link tracking system includes: A first generating module is configured to, when a first microservice receives a first exception response sent by a second microservice, obtain a first service identifier and first abnormal process link information associated with the second microservice based on the first exception response; generate second abnormal process link information based on the first service identifier and the first abnormal process link information, wherein the second abnormal process link information is generated based on the first abnormal process link information of the second microservice and in combination with the abnormal process link information of the first microservice itself; generate a second service identifier corresponding to the second abnormal process link information; and construct a second exception response based on the first service identifier, the first abnormal process link information, the second service identifier, and the second abnormal process link information; A first sending module, configured to send the second exception response to a gateway; A second generating module is configured to generate exception summary information corresponding to a second exception response when receiving the second exception response sent by the microservice; The second sending module is configured to send the exception summary information to a front-end device so as to display the exception summary information on the front-end device.
8. A gateway, characterized in that: The gateway includes: a memory, a processor, and an abnormal link tracking program stored in the memory and executable on the processor. When the abnormal link tracking program is executed by the processor, the steps of the abnormal link tracking method according to any one of claims 3 to 6 are implemented.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a tracking program for an abnormal link, which, when executed by a processor, implements the steps of the tracking method for an abnormal link described in any one of claims 1-2, or implements the steps of the tracking method for an abnormal link described in any one of claims 3-6.
Citation Information
Patent Citations
Business exception positioning method and device, electronic equipment, medium and product
CN112506799A
Hardware state detection method and device, computer equipment and storage medium
CN112652351A