Micro-service processing system supporting business traceability
By introducing business identification database, log database and traceability end in the microservice processing system, reverse traceability of the business chain is achieved, and the problems of difficult business traceability and low debugging efficiency in the microservice processing system are solved, and traceability efficiency is improved.
Patent Information
- Application Number
- CN202311556435.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-20
- Publication Date
- 2024-12-17
AI Technical Summary
Microservice processing systems are difficult to trace the source of errors and have low debugging efficiency. The existing technology requires a large amount of human resources for log analysis and screening.
Introduce the first service identification database, the first service log database and the first service traceability end in the microservice processing system, trace all node information on the business chain through global service identification, and add the parent node and its own node identification to the node log , trace the error log step by step, form a business chain log sequence, and send it to the debug notification interface.
It reduces the difficulty of business traceability of microservice processing systems, reduces human resource consumption, and improves the debugging efficiency of error services.
Smart Images

Figure CN119149274A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a microservice processing system supporting business tracing. Background Art
[0002] From the principle of microservice architecture, we know that the processing system based on microservice architecture has advantages such as good scalability and fast iteration, but it also has the problem of difficulty in reverse tracing the faulty business. Once a business error occurs during the flow process, it takes a lot of human resources to analyze and filter the local logs of each node, and only after obtaining all relevant logs can the subsequent debugging work be started. The more complex the structure of the microservice processing system, the more difficult it is to trace the business source and the lower the debugging efficiency of the faulty business. Summary of the invention
[0003] The purpose of the present invention is to provide a microservice processing system that supports business tracing in response to the defects of the prior art. The system includes: multiple first clients, a first business access terminal, a first business identification library, multiple first business flow networks, a first business log library and a first business tracing terminal; the system of the present invention adds a first business identification library, a first business log library and a first business tracing terminal to the traditional microservice processing system; and allocates a unique global business identification to each first business request initiated by each first client through the first business identification library; and in the business node flow process of the first business flow network, the first node first uses the global business identification as the corresponding parent node business identification, and adds the current node identification item to the current parent node business identification to form the corresponding self-node business identification, and then the next-level calling node uses the node business identification of the upper-level node as the corresponding parent node business identification, and adds the current node identification item to the current parent node business identification to form The corresponding own node business identifier can be recursively deduced from any flow node on each business chain to infer all node information through which the business has flowed; and in the process of business node flow in the first business flow network, the parent node business identifier and the own node business identifier corresponding to the current node are added to the node business log generated on each flow node, and each node business log is stored in the first business log library; the first business log library identifies the log status of each node business log, and after identifying the node business log in the error state, the current error log is sent to the first business tracing end; the first business tracing end starts from the current error log and traces the node business log sequence of all flow nodes through which the business chain has flowed step by step until the log sequence of the first node is obtained, and stops, and the corresponding business chain log sequence is composed of the obtained node business log sequences at all levels in the sorting direction from the first node to the error node, and the business chain log sequence is sent to the preset debugging notification interface. The system of the present invention can reversely trace the business flow that has errors on any flow node. The system of the present invention can reduce the difficulty of business tracing of the microservice processing system and improve the debugging efficiency of the erroneous business.
[0004] To achieve the above-mentioned purpose, an embodiment of the present invention provides a microservice processing system supporting business tracing, the system comprising: a plurality of first clients, a first business access terminal, a first business identification library, a plurality of first business flow networks, a first business log library and a first business tracing terminal;
[0005] Each of the first client and the first service access terminal; the first client is used to send a first service request to the first service access terminal; and receive a first service feedback sent back by the first service access terminal; the first service request includes a first service interface;
[0006] The first service access terminal is connected to the first service identification library and each of the first service transfer networks respectively; the first service access terminal is used to, when receiving the first service request, use the request time of the current first service request as the corresponding first request time; extract the corresponding first service interface from the first service request; and send the first global identification application carrying the first request time and the first service interface to the first service identification library; and receive the first service global identification sent back by the first service identification library; and form a corresponding first service internal request composed of the first service global identification and the first service request to the first service transfer network corresponding to the first service interface; and send the first service feedback sent back by the first service transfer network back to the first client;
[0007] The first service identification library is used to store multiple first service identification records using a Redis database; the first service identification record includes a first service interface field and a first service global identification field;
[0008] The first service identification library is further used to create a corresponding first global identification processing thread for each first global identification application received at the time when one or more first global identification applications are received at the same time; and each first global identification processing thread performs global identification generation and service identification record setting processing according to the first global identification application to obtain the corresponding first service global identification and send it back to the first service access terminal;
[0009] Each of the first business flow networks is connected to the first business log library respectively; the first business flow network includes a plurality of first flow nodes; the first flow nodes in the first business flow network are connected according to a preset business flow microservice call rule; the first business flow network is used to process the business process according to the first business internal request to obtain the corresponding first business feedback and send it back to the first business access terminal; the first business flow network is also used to collect the process log during each business process processing to obtain the corresponding first node business log and store it in the first business log library;
[0010] The first business log library is connected to the first business tracing end; the first business log library is used to store the first node business log; the first business log library is also used to identify the log state of the received first node business log to obtain the corresponding first log state; and when the first log state is an error state, the first business tracing application carrying the current first node business log is sent to the first business tracing end; the first log state includes a success state and an error state;
[0011] The first business tracing end is used to extract the corresponding first node business log from the received first business tracing application; and trace the business chain log of the first business log library according to the business identifier of the first node business log to obtain the corresponding first business chain log sequence; and send the first business chain log sequence to a preset debugging notification interface.
[0012] Preferably, the first service identification library is specifically used for extracting the corresponding first request time and the first service interface from the first global identification application by the first global identification processing thread when each of the first global identification processing threads performs global identification generation and service identification record setting processing according to the first global identification application to obtain the corresponding first service global identification and sends it back to the first service access terminal;
[0013] And based on the preset distributed lock processing mechanism, the first business identification record whose first business interface field in the Redis database matches the first business interface is subjected to record locking processing to obtain a corresponding first locking result; and when the first locking result is a locking failure, after waiting for a specified period of time, the first business identification record whose first business interface field in the Redis database matches the first business interface is continued to be subjected to record locking processing based on the distributed lock processing mechanism until the first locking result is a locking success; and when the first locking result is a locking success, the currently locked first business identification record is used as the corresponding current locking record; the first locking result includes a locking success and a locking failure;
[0014] And convert the first request time into a timestamp format to obtain a corresponding first request timestamp; and use the difference between the first request timestamp and the preset first start timestamp as the corresponding first timestamp; and extract the first business additional identification field of the first correspondence record in which the second business interface field matches the first business interface in the preset first correspondence list as the corresponding first business additional identification; the first correspondence list includes multiple first correspondence records; the first correspondence record includes the second business interface field and the first business additional identification field;
[0015] And identify whether the current time is the preset single-day sequence number clearing time; if so, set a new first business sequence number as the preset single-day starting sequence number; if not, extract the first business sequence number of the first business global identification field of the currently locked record as the corresponding previous business sequence number, and add 1 to the previous business sequence number as the new first business sequence number;
[0016] and forming a new first business global identifier by using the first timestamp, the first business additional identifier and the new first business sequence number; and resetting the first business global identifier field of the currently locked record based on the new first business global identifier;
[0017] After the reset is successful, the current locking record is unlocked based on a preset locking record unlocking mechanism; and the new first service global identifier is sent back to the first service access terminal.
[0018] Preferably, the first service transfer network is specifically used for recording the first first transfer node in the network as the corresponding head node, and recording any other first transfer node except the head node as the corresponding process node when the first service feedback corresponding to the first service is obtained by performing service process processing according to the first service internal request and sent back to the first service access terminal;
[0019] The first node receives the first service internal request; extracts the first service global identifier of the first service internal request as the corresponding first parent node service identifier; creates a corresponding first session instance for the current first service internal request; allocates a corresponding first session identifier to the first session instance; and uses the locally preset node identifier as the corresponding first node identifier; and performs identification information addition processing on the first parent node service identifier based on the first node identifier, the first session identifier and the preset node service identifier addition rule to obtain the corresponding current node service identifier; and the first session instance performs the service processing of the current node according to the first service internal request based on the local node service processing code to obtain the corresponding first service feedback and sends it back to the first service access terminal; and in the process of the service processing of the current node of the first session instance, if it is necessary to call the service of other process nodes, the process node called at that time is recorded as the corresponding current child node, and the transmission parameters required for the current call are used as the corresponding first call parameters, and the current node service identifier is used as the corresponding first node service identifier, and the first node service identifier and the first call parameter are used to form a corresponding first service node request and send it to the current child node, and subsequent service processing is performed based on the first node feedback returned by the current child node;
[0020] When any of the process nodes is called by the first node or another process node, the first node or another process node that calls itself at that time is recorded as the corresponding current parent node; and the first node service identifier of the first service node request sent by the current parent node is extracted as the corresponding first parent node service identifier; and a corresponding first session instance is created for the current first service node request; and a corresponding first session identifier is allocated to the first session instance; and based on the first node identifier, the first session identifier and the preset node service identifier addition rule, the first parent node service identifier is processed for identification information addition to obtain the corresponding current node service identifier; and the first session instance is used to generate a corresponding first session identifier based on the local The node business processing code performs the business processing of this node according to the first business node request, obtains the corresponding first node feedback and sends it back to the current parent node; and during the processing of the business processing of this node in the first session instance, if it is necessary to make a service call to other process nodes, the other process nodes called at that time are recorded as the corresponding current child nodes, and the transfer parameters required for the current call are used as the corresponding first call parameters, and the current node business identifier is used as the corresponding first node business identifier, and the corresponding first business node request composed of the obtained first node business identifier and the first call parameter is sent to the current child node, and subsequent business processing is performed based on the first node feedback returned by the current child node.
[0021] Further, any of the first flow transfer nodes of the first service flow transfer network is specifically used to identify whether the current time is the preset single-day counter clearing time when the first parent node service identifier is processed for identification information addition based on the first node identifier, the first session identifier and the preset node service identifier addition rule to obtain the corresponding current node service identifier; if so, the count value of the locally preset first counter is cleared, and the count value of the first counter after clearing is used as the corresponding first count value; if not, the count value of the first counter is added by 1, and the count value of the first counter after adding 1 is used as the corresponding first count value; and the current time is converted into a timestamp format to obtain a corresponding second timestamp; and a corresponding first identification addition is composed of a preset information delimiter, the first node identifier, the first count value, the first session identifier and the second timestamp; and a corresponding current node service identifier is composed of the first parent node service identifier and the first identification addition.
[0022] Preferably, the first business flow network is specifically used for collecting the process log to obtain the corresponding first node business log and storing it in the first business log library. In the process of the corresponding business processing of the node, each first session instance of each first flow node in the network collects information on the step function description, step execution time and step execution status of each pre-specified business processing step to obtain a group of corresponding first processing step description, first step execution time and first step execution status; and the first parent node business identifier and the first node business identifier corresponding to the current first session instance and each group of the first processing step description, the first step execution time and the first step execution status form a corresponding first node business log and store it in the first business log library; the first node business log includes the first parent node business identifier, the first node business identifier, the first processing step description, the first step execution time and the first step execution status; the first step execution status includes a success status and an error status.
[0023] Preferably, the first business log library is specifically used to identify the first step execution status of the first node business log when the log status of each first node business log is identified to obtain the corresponding first log status; if the first step execution status is a success status, the corresponding first log status is set to a success status; if the first step execution status is an error status, the corresponding first log status is set to an error status.
[0024] Preferably, the first service tracing end is specifically used for, when tracing the service chain log of the first service log library according to the service identifier of the first node service log to obtain the corresponding first service chain log sequence:
[0025] Step 71: extract the corresponding first parent node service identifier and the first node service identifier from the first node service log as the corresponding current parent node service identifier and the current node service identifier; and initialize a first service chain log sequence with empty content;
[0026] Step 72, extract all the first node business logs in the first business log library that match the first parent node business identifier and the first node business identifier with the corresponding current parent node business identifier and the current node business identifier, and sort them in chronological order to form a corresponding first node business log sequence; and add the first node business log sequence obtained this time to the sequence head of the first business chain log sequence;
[0027] Step 73, and identify whether the first transfer node corresponding to the current node service identifier is the first node; if not, go to step 74; if yes, go to step 75;
[0028] Step 74, taking any first node business log in the first business log library that matches the current parent node business identifier as the corresponding first log; and extracting the first parent node business identifier and the first node business identifier of the first log as the new current parent node business identifier and the current node business identifier; and returning to step 72;
[0029] Step 75: output the latest first service chain log sequence as the tracing result of this service chain log tracing.
[0030] An embodiment of the present invention provides a microservice processing system that supports business tracing, the system comprising: multiple first clients, a first business access terminal, a first business identification library, multiple first business flow networks, a first business log library and a first business tracing terminal; the system of the present invention adds a first business identification library, a first business log library and a first business tracing terminal to the traditional microservice processing system; and allocates a unique global business identification to each first business request initiated by each first client through the first business identification library; and in the business node flow process of the first business flow network, the first node first uses the global business identification as the corresponding parent node business identification, and adds the current node's identification item to the current parent node business identification to form the corresponding self-node business identification, and then the next-level calling node uses the node business identification of the upper-level node as the corresponding parent node business identification, and adds the current node's identification item to the current parent node business identification to form the corresponding self-node business identification Point business identification, recursively from any flow node on each business chain, you can reversely deduce all the node information that the business has circulated at that time; and in the process of business node circulation in the first business circulation network, add the parent node business identification and the own node business identification corresponding to the current node to the node business log generated on each flow node, and store each node business log in the first business log library; the first business log library identifies the log status of each node business log, and after identifying the node business log in the error state, sends the current error log to the first business tracing end; the first business tracing end starts from the current error log and traces the node business log sequence of all flow nodes that have circulated the business chain level by level until the log sequence of the first node is obtained, and stops, and composes the corresponding business chain log sequence from the obtained node business log sequences at all levels in the sorting direction from the first node to the error node, and sends the business chain log sequence to the preset debugging notification interface. The system of the present invention can reversely trace the business flow that has errors on any flow node. The system of the present invention not only reduces a large amount of human resource consumption, but also reduces the difficulty of business tracing of the microservice processing system, and improves the debugging efficiency of erroneous business. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 A schematic diagram of a module of a microservice processing system supporting business tracing provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0032] In order to make the purpose, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0033] The embodiment of the present invention provides a microservice processing system that supports business tracing. Figure 1 As shown in the module schematic diagram of a microservice processing system supporting business tracing provided in an embodiment of the present invention, the system includes: multiple first clients 1, a first business access terminal 2, a first business identification library 3, multiple first business flow networks 4, a first business log library 5 and a first business tracing terminal 6.
[0034] (I) First Client 1:
[0035] Each first client 1 and a first service access terminal 2.
[0036] The first client 1 is used to send a first service request to the first service access terminal 2; and receive a first service feedback sent back by the first service access terminal 2.
[0037] The first service request includes a first service interface.
[0038] Here, the first client 1 of the embodiment of the present invention is a software program, software interface, service interface, server, hardware module, hardware device, hardware equipment, server, system or platform that can send a service request to the first service access terminal 2. The first client 1 can provide a variety of service applications to the user, and each service application corresponds to a service interface, that is, the first service interface.
[0039] (II) First service access terminal 2:
[0040] The first service access terminal 2 is connected to the first service identification library 3 and each first service flow network 4 respectively.
[0041] Here, the first service access terminal 2 of the embodiment of the present invention can be an access gateway for connecting to all first clients 1 under the microservice architecture, or it can be a load balancing server for connecting to all first clients 1 under the microservice architecture. Its characteristic is that it can receive the first service requests of all first clients 1, so that a unique global identifier can be assigned to each first service request through the subsequent first service identification library 3.
[0042] The first service access terminal 2 is used to, upon receiving the first service request, use the request time of the current first service request as the corresponding first request time; extract the corresponding first service interface from the first service request; and send the first global identification application carrying the first request time and the first service interface to the first service identification library 3; and receive the first service global identification sent back by the first service identification library 3; and send the corresponding first service internal request composed of the first service global identification and the first service request to the first service flow network 4 corresponding to the first service interface; and send the first service feedback sent back by the first service flow network 4 back to the first client 1.
[0043] (III) First business identification library 3:
[0044] The first service identification library 3 is used to store multiple first service identification records using the Redis database; wherein the first service identification record includes a first service interface field and a first service global identification field.
[0045] The first service identification library 3 is also used to create a corresponding first global identification processing thread for each first global identification application received at the time when one or more first global identification applications are received at the same time; and each first global identification processing thread generates a global identification and sets a service identification record according to the first global identification application to obtain the corresponding first service global identification and sends it back to the first service access terminal 2.
[0046] In a specific implementation of the embodiment of the present invention, the first service identification library 3 is specifically used when each first global identification processing thread performs global identification generation and service identification record setting processing according to the first global identification application to obtain the corresponding first service global identification and sends it back to the first service access terminal 2:
[0047] Step A1, the first global identifier processing thread extracts the corresponding first request time and the first service interface from the first global identifier application;
[0048] Step A2, based on a preset distributed lock processing mechanism, a first business identification record whose first business interface field in the Redis database matches the first business interface is subjected to record locking processing to obtain a corresponding first locking result; and when the first locking result is a locking failure, after waiting for a specified period of time, the first business identification record whose first business interface field in the Redis database matches the first business interface is subjected to record locking processing based on the distributed lock processing mechanism until the first locking result is a locking success; and when the first locking result is a locking success, the currently locked first business identification record is used as the corresponding current locking record;
[0049] The first locking result includes locking success and locking failure;
[0050] Here, the preset distributed lock processing mechanism is the distributed lock processing mechanism of the Redis database, which is usually implemented by the Redis database SETNX command. This is a conventional technology, which can be found in the public Redis database distributed lock implementation scheme, and will not be further repeated here. It should be noted that the purpose of using record locking here is to avoid database setting errors caused by multi-thread concurrency, and thus ensure the uniqueness of the final global identifier.
[0051] Step A3, converting the first request time into a timestamp format to obtain a corresponding first request timestamp; and subtracting the difference between the first request timestamp and the preset first start timestamp as the corresponding first timestamp;
[0052] Here, the first starting timestamp is a timestamp of a preset time;
[0053] Step A4, extracting the first service additional identifier field of the first correspondence record in which the second service interface field matches the first service interface in the preset first correspondence list as the corresponding first service additional identifier;
[0054] The first correspondence list includes a plurality of first correspondence records; the first correspondence record includes a second service interface field and a first service additional identification field;
[0055] Here, the first correspondence list is a data list used to reflect the correspondence between the business interface and the business additional identifier; the business additional identifier is a custom identification information, which can be composed of one or more identification information and can be set according to the application implementation requirements; for example, in the case of multiple centers and multiple workflows, the business additional identifier can be set to additional identification information composed of a data center identifier + a workflow identifier;
[0056] Step A5, and identify whether the current time is the preset single-day sequence number clearing time; if so, set a new first business sequence number as the preset single-day starting sequence number; if not, extract the first business sequence number of the first business global identification field of the currently locked record as the corresponding previous business sequence number, and add 1 to the previous business sequence number as the new first business sequence number;
[0057] Here, the single-day serial number reset time is a preset single-day time point; the single-day starting serial number is a preset serial number value, which is set to 0 by default;
[0058] Step A6: a new first business global identifier is formed by the first timestamp, the first business additional identifier and the new first business sequence number; and the first business global identifier field of the currently locked record is reset based on the new first business global identifier;
[0059] Step A7: after the reset is successful, the current locked record is unlocked based on the preset locked record unlocking mechanism; and the new first service global identifier is sent back to the first service access terminal 2.
[0060] Here, the locking record unlocking mechanism is the unlocking mechanism of the Redis database. For details, please refer to the public Redis database solution for understanding, and no further repetition is given here.
[0061] (IV) First business circulation network 4:
[0062] Each first service flow network 4 is connected to the first service log repository 5 respectively.
[0063] The first business flow network 4 includes multiple first flow nodes 41; the first flow nodes 41 in the first business flow network 4 are connected according to preset business flow microservice calling rules.
[0064] Here, in the microservice processing system, the processing flow of each business is clear, and the node calling relationship of each business node when processing each business flow is also clear. This clear calling relationship is the business flow microservice calling rule.
[0065] The first service flow network 4 is used to process the service flow according to the first service internal request, obtain the corresponding first service feedback and send it back to the first service access terminal 2.
[0066] The first business flow network 4 is also used to collect process logs during each business process processing to obtain corresponding first node business logs and store them in the first business log library 5 .
[0067] In another specific implementation of the embodiment of the present invention, the first service flow network 4 is specifically configured to, when performing service flow processing according to the first service internal request to obtain the corresponding first service feedback and sending it back to the first service access terminal 2:
[0068] Step B1, record the first first flow node 41 in the network as the corresponding head node, and record any other first flow node 41 except the head node as the corresponding process node;
[0069] Step B2, the first node receives the first service internal request; extracts the first service global identifier of the first service internal request as the corresponding first parent node service identifier; creates a corresponding first session instance for the current first service internal request; allocates a corresponding first session identifier to the first session instance; and uses the locally preset node identifier as the corresponding first node identifier; and performs identification information addition processing on the first parent node service identifier based on the first node identifier, the first session identifier and the preset node service identifier addition rule to obtain the corresponding current node service identifier; and the first session instance performs the service processing of the node based on the local node service processing code according to the first service internal request to obtain the corresponding first service feedback and sends it back to the first service access terminal 2; and during the processing of the service processing of the node of the first session instance, if it is necessary to call other process nodes for services, the process node called at that time is recorded as the corresponding current child node, and the transmission parameters required for the current call are used as the corresponding first call parameters, and the current node service identifier is used as the corresponding first node service identifier, and the corresponding first service node request is composed of the obtained first node service identifier and the first call parameter and sent to the current child node, and subsequent service processing is performed based on the first node feedback returned by the current child node;
[0070] Step B3, when any process node is called by the first node or another process node, the first node or another process node that calls itself at that time is recorded as the corresponding current parent node; and the first node business identifier of the first business node request sent by the current parent node is extracted as the corresponding first parent node business identifier; and a corresponding first session instance is created for the current first business node request; and a corresponding first session identifier is assigned to the first session instance; and based on the first node identifier, the first session identifier and the preset node business identifier addition rule, the first parent node business identifier is processed for identification information addition to obtain the corresponding current node business identifier; and the first session instance is based on The local node business processing code performs the business processing of this node according to the first business node request, obtains the corresponding first node feedback and sends it back to the current parent node; and if it is necessary to make service calls to other process nodes during the processing of the business processing of this node in the first session instance, the other process nodes called at that time are recorded as the corresponding current child nodes, and the transfer parameters required for the current call are used as the corresponding first call parameters, and the current node business identifier is used as the corresponding first node business identifier, and the corresponding first business node request composed of the obtained first node business identifier and the first call parameter is sent to the current child node, and subsequent business processing is performed based on the first node feedback returned by the current child node.
[0071] In another specific implementation of the embodiment of the present invention, any first flow node 41 of the first service flow network 4 is specifically used to perform identification information addition processing on the first parent node service identifier based on the first node identifier, the first session identifier and the preset node service identifier addition rule to obtain the corresponding current node service identifier:
[0072] Step C1, identifying whether the current time is the preset single-day counter clearing time; if so, clearing the count value of the locally preset first counter, and using the count value of the first counter after clearing as the corresponding first count value; if not, adding 1 to the count value of the first counter, and using the count value of the first counter after adding 1 as the corresponding first count value;
[0073] Here, the single-day counter is reset to zero at a preset single-day time point;
[0074] Step C2, converting the current time into a timestamp format to obtain a corresponding second timestamp;
[0075] Step C3, a corresponding first identification item is formed by the preset information separator, the first node identification, the first count value, the first session identification and the second timestamp; and a corresponding current node service identification is formed by the first parent node service identification and the first identification item.
[0076] Here, the information separator is a preset ASCII code character, such as "%", " / ", etc.
[0077] In another specific implementation of the embodiment of the present invention, the first service flow network 4 is specifically used for collecting the process log to obtain the corresponding first node service log and storing it in the first service log library 5:
[0078] Step D1, each first session instance of each first flow transfer node 41 in the network collects information on the step function description, step execution time and step execution status of each pre-specified business processing step during the processing of the corresponding business processing of the node, to obtain a set of corresponding first processing step descriptions, first step execution time and first step execution status;
[0079] Step D2, a corresponding first node business log is formed by the first parent node business identifier and the first node business identifier corresponding to the current first session instance and each group of first processing step descriptions, first step execution time and first step execution status and stored in the first business log library 5.
[0080] (V) First business log library 5:
[0081] The first business log library 5 is connected to the first business tracing end 6 .
[0082] The first business log library 5 is used to save the first node business log; wherein, the first node business log includes the first parent node business identifier, the first node business identifier, the first processing step description, the first step execution time and the first step execution status; the first step execution status includes a success status and an error status.
[0083] The first business log library 5 is also used to identify the log status of the received first node business log to obtain the corresponding first log status; and when the first log status is an error status, the first business tracing application carrying the current first node business log is sent to the first business tracing terminal 6; wherein the first log status includes a success status and an error status.
[0084] In another specific implementation method of the embodiment of the present invention, the first business log library 5 is specifically used to identify the first step execution status of the first node business log when the log status of each first node business log is identified to obtain the corresponding first log status; if the first step execution status is a success status, the corresponding first log status is set to a success status; if the first step execution status is an error status, the corresponding first log status is set to an error status.
[0085] (VI) First business traceability terminal 6:
[0086] The first business tracing end 6 is used to extract the corresponding first node business log from the received first business tracing application; and trace the business chain log of the first business log library 5 according to the business identifier of the first node business log to obtain the corresponding first business chain log sequence; and send the first business chain log sequence to the preset debugging notification interface.
[0087] Here, the debugging notification interface is a pre-set processing interface, which can be connected to the staff responsible for business debugging or the system for business debugging. After sending the first business chain log sequence to the interface, the personnel or system responsible for business debugging can immediately reproduce the corresponding business flow process based on the first business chain log sequence received at that time, without spending a lot of human resources to analyze and screen the local logs of each node.
[0088] In another specific implementation of the embodiment of the present invention, the first business tracing end 6 is specifically used to perform business chain log tracing on the first business log library 5 according to the business identifier of the first node business log to obtain the corresponding first business chain log sequence,
[0089] Step E1, extracting the corresponding first parent node service identifier and the first node service identifier from the first node service log as the corresponding current parent node service identifier and the current node service identifier; and initializing a first service chain log sequence with empty content;
[0090] Step E2, extract all first node business logs in the first business log library 5 that match the first parent node business identifier and the first node business identifier with the corresponding current parent node business identifier and the current node business identifier, and sort them in chronological order to form a corresponding first node business log sequence; and add the first node business log sequence obtained this time to the sequence head of the first business chain log sequence;
[0091] Step E3, and identify whether the first transfer node 41 corresponding to the current node service identifier is the head node; if not, go to step E4; if yes, go to step E5;
[0092] Step E4, taking any first node service identifier in the first service log library 5 that matches the current parent node service identifier as the corresponding first log; and extracting the first parent node service identifier and the first node service identifier of the first log as the new current parent node service identifier and the current node service identifier; and returning to step E2;
[0093] Step E5: Output the latest first service chain log sequence as the tracing result of this service chain log tracing.
[0094] An embodiment of the present invention provides a microservice processing system that supports business tracing, the system comprising: multiple first clients, a first business access terminal, a first business identification library, multiple first business flow networks, a first business log library and a first business tracing terminal; the system of the present invention adds a first business identification library, a first business log library and a first business tracing terminal to the traditional microservice processing system; and allocates a unique global business identification to each first business request initiated by each first client through the first business identification library; and in the business node flow process of the first business flow network, the first node first uses the global business identification as the corresponding parent node business identification, and adds the current node's identification item to the current parent node business identification to form the corresponding self-node business identification, and then the next-level calling node uses the node business identification of the upper-level node as the corresponding parent node business identification, and adds the current node's identification item to the current parent node business identification to form the corresponding self-node business identification Point business identification, recursively from any flow node on each business chain, you can reversely deduce all the node information that the business has circulated at that time; and in the process of business node circulation in the first business circulation network, add the parent node business identification and the own node business identification corresponding to the current node to the node business log generated on each flow node, and store each node business log in the first business log library; the first business log library identifies the log status of each node business log, and after identifying the node business log in the error state, sends the current error log to the first business tracing end; the first business tracing end starts from the current error log and traces the node business log sequence of all flow nodes that have circulated the business chain level by level until the log sequence of the first node is obtained, and stops, and composes the corresponding business chain log sequence from the obtained node business log sequences at all levels in the sorting direction from the first node to the error node, and sends the business chain log sequence to the preset debugging notification interface. The system of the present invention can reversely trace the business flow that has errors on any flow node. The system of the present invention not only reduces a large amount of human resource consumption, but also reduces the difficulty of business tracing of the microservice processing system, and improves the debugging efficiency of erroneous business.
[0095] The professionals should further realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to the function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians 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 the present invention.
[0096] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0097] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A microservice processing system supporting business traceability, characterized in that: The system comprises: a plurality of first clients, a first service access terminal, a first service identification library, a plurality of first service flow networks, a first service log library and a first service tracing terminal; Each of the first client and the first service access terminal; the first client is used to send a first service request to the first service access terminal; and receive a first service feedback sent back by the first service access terminal; the first service request includes a first service interface; The first service access terminal is connected to the first service identification library and each of the first service transfer networks respectively; the first service access terminal is used to, when receiving the first service request, use the request time of the current first service request as the corresponding first request time; extract the corresponding first service interface from the first service request; and send the first global identification application carrying the first request time and the first service interface to the first service identification library; and receive the first service global identification sent back by the first service identification library; and form a corresponding first service internal request composed of the first service global identification and the first service request to the first service transfer network corresponding to the first service interface; and send the first service feedback sent back by the first service transfer network back to the first client; The first service identification library is used to store multiple first service identification records using a Redis database; the first service identification record includes a first service interface field and a first service global identification field; The first service identification library is further used to create a corresponding first global identification processing thread for each first global identification application received at the time when one or more first global identification applications are received at the same time; and each first global identification processing thread performs global identification generation and service identification record setting processing according to the first global identification application to obtain the corresponding first service global identification and send it back to the first service access terminal; Each of the first business flow networks is connected to the first business log library respectively; the first business flow network includes a plurality of first flow nodes; the first flow nodes in the first business flow network are connected according to a preset business flow microservice call rule; the first business flow network is used to process the business process according to the first business internal request to obtain the corresponding first business feedback and send it back to the first business access terminal; the first business flow network is also used to collect the process log during each business process processing to obtain the corresponding first node business log and store it in the first business log library; The first business log library is connected to the first business tracing end; the first business log library is used to store the first node business log; the first business log library is also used to identify the log state of the received first node business log to obtain the corresponding first log state; and when the first log state is an error state, the first business tracing application carrying the current first node business log is sent to the first business tracing end; the first log state includes a success state and an error state; The first business tracing end is used to extract the corresponding first node business log from the received first business tracing application; and trace the business chain log of the first business log library according to the business identifier of the first node business log to obtain the corresponding first business chain log sequence; and send the first business chain log sequence to a preset debugging notification interface.
2. The microservice processing system supporting business tracing according to claim 1 is characterized in that: The first service identification library is specifically used for extracting the corresponding first request time and the first service interface from the first global identification application by the first global identification processing thread when each of the first global identification processing threads performs global identification generation and service identification record setting processing according to the first global identification application to obtain the corresponding first service global identification and sends it back to the first service access terminal; And based on a preset distributed lock processing mechanism, record locking processing is performed on the first business identification record whose first business interface field in the Redis database matches the first business interface to obtain a corresponding first locking result; and when the first locking result is a locking failure, after waiting for a specified period of time, record locking processing is continued based on the distributed lock processing mechanism on the first business identification record whose first business interface field in the Redis database matches the first business interface until the first locking result is a locking success; and when the first locking result is that the locking is successful, taking the first service identification record currently locked as the corresponding current locking record; The first locking result includes locking success and locking failure; and converting the first request time into a timestamp format to obtain a corresponding first request timestamp; and taking the difference between the first request timestamp and the preset first start timestamp as the corresponding first timestamp; and extracting the first business additional identification field of the first correspondence record in the preset first correspondence list, in which the second business interface field matches the first business interface, as the corresponding first business additional identification; the first correspondence list includes a plurality of the first correspondence records; the first correspondence record includes the second business interface field and the first business additional identification field; And identify whether the current time is the preset single-day sequence number clearing time; if so, set a new first business sequence number as the preset single-day starting sequence number; if not, extract the first business sequence number of the first business global identification field of the currently locked record as the corresponding previous business sequence number, and add 1 to the previous business sequence number as the new first business sequence number; and forming a new first business global identifier by using the first timestamp, the first business additional identifier and the new first business sequence number; and resetting the first business global identifier field of the currently locked record based on the new first business global identifier; After the reset is successful, the current locked record is unlocked based on a preset locked record unlocking mechanism; And send the new first service global identifier back to the first service access terminal.
3. The microservice processing system supporting business traceability according to claim 1 is characterized in that: The first service transfer network is specifically used for recording the first first transfer node in the network as the corresponding head node, and recording any other first transfer node except the head node as the corresponding process node when the first service feedback corresponding to the first service is obtained by performing service process processing according to the first service internal request and sending it back to the first service access terminal; The first node receives the first service internal request; and extracting the first service global identifier of the first service internal request as the corresponding first parent node service identifier; And create a corresponding first session instance for the current first business internal request; and assign a corresponding first session identifier to the first session instance; and use the locally preset node identifier as the corresponding first node identifier; And based on the first node identifier, the first session identifier and the preset node service identifier addition rule, the first parent node service identifier is processed for identification information addition to obtain the corresponding current node service identifier; and the first session instance performs the current node service processing according to the first service internal request based on the local node service processing code to obtain the corresponding first service feedback and send it back to the first service access terminal; and during the processing of the current node service processing of the first session instance, if it is necessary to make a service call to other process nodes, the process node called at that time is recorded as the corresponding current child node, and the transmission parameters required for the current call are used as the corresponding first call parameters, and the current node service identifier is used as the corresponding first node service identifier, and the obtained first node service identifier and the first call parameter form a corresponding first service node request to send to the current child node, and perform subsequent service processing based on the first node feedback returned by the current child node; When any of the process nodes is called by the first node or another process node, the first node or another process node that calls itself is recorded as the corresponding current parent node; and the first node service identifier of the first service node request sent by the current parent node is extracted as the corresponding first parent node service identifier; and create a corresponding first session instance for the current first service node request; and assigning a corresponding first session identifier to the first session instance; And based on the first node identifier, the first session identifier and the preset node service identifier addition rule, the first parent node service identifier is processed for identification information addition to obtain the corresponding current node service identifier; and the first session instance performs the current node service processing according to the first service node request based on the local node service processing code to obtain the corresponding first node feedback and send it back to the current parent node; And during the processing of the business processing of the node of the first session instance, if it is necessary to make a service call to other process nodes, the other process nodes called at that time will be recorded as the corresponding current child nodes, and the transmission parameters required for the current call will be used as the corresponding first call parameters, and the current node business identifier will be used as the corresponding first node business identifier, and the corresponding first business node request composed of the obtained first node business identifier and the first call parameter will be sent to the current child node, and subsequent business processing will be performed based on the first node feedback returned by the current child node.
4. The microservice processing system supporting business tracing according to claim 3 is characterized in that: Any of the first flow transfer nodes of the first service flow transfer network is specifically used to identify whether the current time is the preset single-day counter clearing time when the first parent node service identifier is processed for identification information addition based on the first node identifier, the first session identifier and the preset node service identifier addition rule to obtain the corresponding current node service identifier; if so, clear the count value of the locally preset first counter, and use the count value of the first counter after clearing as the corresponding first count value; if not, add 1 to the count value of the first counter, and use the count value of the first counter after adding 1 as the corresponding first count value; and converting the current time into a timestamp format to obtain a corresponding second timestamp; A corresponding first identification increment is formed by a preset information separator, the first node identification, the first count value, the first session identification and the second timestamp; and a corresponding current node service identification is formed by the first parent node service identification and the first identification increment.
5. The microservice processing system supporting business traceability according to claim 3 is characterized in that: The first service flow network is specifically used for collecting the process log to obtain the corresponding first node service log and storing it in the first service log library, and collecting information on the step function description, step execution time and step execution status of each pre-specified service processing step in the corresponding processing process of the local node service by each first session instance of each first flow node in the network to obtain a set of corresponding first processing step description, first step execution time and first step execution status; The first parent node business identifier and the first node business identifier corresponding to the current first session instance, together with each group of the first processing step description, the first step execution time and the first step execution status, form a corresponding first node business log which is stored in the first business log library; the first node business log includes the first parent node business identifier, the first node business identifier, the first processing step description, the first step execution time and the first step execution status; the first step execution status includes a success status and an error status.
6. The microservice processing system supporting business traceability according to claim 3 is characterized in that: The first business log library is specifically used to identify the first step execution status of the first node business log when the log status of each first node business log is identified to obtain the corresponding first log status; if the first step execution status is a success status, set the corresponding first log status to a success status; if the first step execution status is an error status, set the corresponding first log status to an error status.
7. The microservice processing system supporting business traceability according to claim 5, characterized in that: The first service tracing end is specifically used for tracing the service chain log of the first service log library according to the service identifier of the first node service log to obtain the corresponding first service chain log sequence: Step 71, extracting the corresponding first parent node service identifier and the first node service identifier from the first node service log as the corresponding current parent node service identifier and the current node service identifier; And initialize a first service chain log sequence with empty content; Step 72, extract all the first node business logs in the first business log library that match the first parent node business identifier and the first node business identifier with the corresponding current parent node business identifier and the current node business identifier, and sort them in chronological order to form a corresponding first node business log sequence; and add the first node business log sequence obtained this time to the sequence head of the first business chain log sequence; Step 73, identifying whether the first transfer node corresponding to the current node service identifier is the first node; if not, go to step 74; If yes, go to step 75; Step 74, taking any first node service log in the first service log library that matches the current parent node service identifier as the corresponding first log; and extracting the first parent node service identifier and the first node service identifier of the first log as the new current parent node service identifier and the current node service identifier; And return to step 72; Step 75: output the latest first service chain log sequence as the tracing result of this service chain log tracing.
