Distributed link acquisition method, device, computing device and storage medium
By receiving and aggregating the link information of sub-nodes in the microservice architecture, and determining the faulty link according to the exception discrimination rules, the problem of fault diagnosis under the microservice architecture is solved, and efficient fault location and diagnosis are achieved.
Patent Information
- Application Number
- CN202010212340.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-24
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2040-03-24
AI Technical Summary
Under the microservice architecture, traditional diagnostic methods such as logs and return values are difficult to effectively handle fault diagnosis, especially because only a small number of call links are collected, which may cause a link failure and the cause of the failure cannot be determined.
By receiving the call request sent by the parent node, the link aggregation information of the child node is obtained, and based on the exception identification rules, it is determined whether there is an abnormality in the service call. Only the faulty link information is collected and transmitted to the computing center to ensure the accuracy of fault diagnosis. and efficiency.
It effectively reduces the total amount of distributed link sampling, reduces the calculation amount and storage resource occupation of the computing center, and at the same time ensures the efficiency and accuracy of fault diagnosis.
Smart Images

Figure CN113452607B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, apparatus, computing device and storage medium for distributed link acquisition. Background Art
[0002] In the cloud computing environment, more and more businesses are deployed using the microservice architecture, which makes each service more detailed. The execution of a request involves the execution results of multiple microservices. Therefore, traditional diagnostic methods such as logs and return values cannot effectively cope with fault diagnosis under the microservice architecture.
[0003] In related technologies, distributed call chain tracing technology is used to implement fault diagnosis under microservice architecture. In this technology, 1% of all call chains are statically sampled (for example, there are 1 million call chains under the microservice architecture, and only 10,000 call chains are collected). Then, the link characteristics and some bottleneck problems in daily operation are inferred through statistical principles.
[0004] Since only a small part of the call chain is collected, it is possible that a link fails, but this part of the link is not stored, making it impossible to determine the cause of the failure. Summary of the invention
[0005] In order to solve the problem of being unable to determine the cause of a fault, the present application provides a method, apparatus, computing device, and storage medium for distributed link collection. The technical solution is as follows:
[0006] In the first aspect, a method for distributed link collection is provided, the method comprising: receiving a first call request sent by a parent node, wherein the first call request includes a call chain (trace) identifier and a call span (span) identifier assigned by the parent node. Execute child node call processing, and obtain link aggregation information sent by all child nodes of this node, wherein, for the link aggregation information sent by any child node, the link aggregation information sent by the child node includes one or more of the number of spans, span depth, involved middleware, and involved microservice names in the downstream call process of the child node; when it is determined according to the stored exception discrimination rules that the service call indicated by the trace identifier is abnormal, the link aggregation information of all child nodes of this node is aggregated to obtain the first link aggregation information. The first link information and the first link aggregation information corresponding to the trace identifier on this node are transmitted to the computing center, wherein the first link information includes the child span identifier of this node and the internal key call stack.
[0007] In the scheme shown in the present application, a business request is received in the microservice framework. When executing the processing corresponding to the business request, the node where any microservice other than the first microservice in the microservice to execute the business request is located will receive the first call request sent by the node where the upstream microservice is located (which can be called the parent node). The first call request includes a trace identifier and a span identifier, the trace identifier is used to indicate the unique identifier of the business request, and the span identifier is used to indicate the span identifier of the called child node. The target node belonging to the called microservice can receive the first call request (the target node is any node that executes the process of this application). After the target node receives the first call request, if the target node has a downstream microservice to call, the target node can execute the processing of calling the downstream microservice after executing its own internal processing. Specifically, the target node can generate a span identifier, and use the span identifier in the first call request as the parent span identifier of the span identifier generated by the target node, and use the span identifier generated by the target node as the child span identifier of the parent span identifier. The target node can send a second call request to the node where the downstream microservice is located (i.e., the child node of the target node). The second call request carries the trace identifier and the span identifier generated by the target node. In this way, since the target node generates a span identifier for the microservice it calls, the target node can obtain the child span identifier of the target node.
[0008] The target node can receive response messages returned by all its child nodes. The response message returned by each child node includes the link aggregation information of the child node. The link aggregation information can include one or more of the number of spans, span depth, middleware involved, and microservice name involved in the downstream call process of the child node. The number of spans is the total number of spans experienced by all nodes downstream of the target node in the call chain identified by the trace. The span depth is the longest depth of all nodes downstream of the target node in the call chain identified by the trace.
[0009] The target node can determine, based on the stored exception discrimination rules, that the service call indicated by the trace identifier is abnormal, and then aggregate the link aggregation information of all child nodes of this node to obtain the first link aggregation information. And the target node obtains the first link information corresponding to the trace identifier on this node. The first link information includes the subspan identifier and the internal key call stack of the target node. The internal call stack may include the key function call status of the target node's internal call, internal call abnormalities, etc. The target node can then send the first link information and the first link aggregation information to the computing center. In this way, by only collecting faulty links, not only is the total amount of distributed link sampling relatively small, but it can also ensure that the fault diagnosis efficiency is not affected.
[0010] In one possible implementation, the method also includes: sending an exception indication identifier to the parent node, wherein the exception indication identifier is used to instruct the parent node to transmit the second link information and second link aggregation information corresponding to the trace identifier on the parent node to the computing center, the second link information includes the child span identifier and internal key call stack of the parent node, and the second link aggregation information is obtained by aggregating the link aggregation information sent by the child nodes of the parent node.
[0011] According to the solution shown in the present application, when the target node determines that the service call indicated by the trace identifier is abnormal according to the stored exception discrimination rules, the target node can determine the parent node that sent the first call request. The target node then sends a response message to the parent node, and carries the exception indication identifier in the response message. The exception indication identifier is used to instruct the parent node to transmit the information aggregated from the second link information corresponding to the trace identifier on the parent node and the link aggregation information sent by its own child node to the computing center. In this way, the link information on the parent node of the target node whose service call is abnormal can also be provided to the computing center, which facilitates the computing center to determine the fault location.
[0012] In one possible implementation, the exception indication identifier is also used to instruct the parent node to notify the upstream node that directly or indirectly calls the parent node, and transmit the third link information and third link aggregation information corresponding to the trace identifier to the computing center, where the third link information includes the sub-span identifier and internal key call stack of the upstream node, and the second link aggregation information is obtained by aggregating the link information sent by the child nodes of the upstream node.
[0013] In the scheme shown in the present application, the abnormal indication message provided by the target node to the parent node can also notify the parent node of the parent node of the target node to send a response message. The response message also includes an abnormal indication identifier, which is used to instruct the parent node of the parent node to transmit the third link information and the third link aggregation information corresponding to the trace identifier to the computing center. In this way, more information about the call chain indicated by the trace identifier can be obtained, which facilitates the computing center to determine the fault location.
[0014] In a possible implementation, the method further includes: when it is determined according to a stored exception judgment rule that there is no exception in the service call indicated by the trace identifier, aggregating the first link information and the first link aggregation information to obtain fourth link aggregation information; and sending the fourth link aggregation information to the parent node.
[0015] In the scheme shown in the present application, when the target node determines that there is no abnormality in the service call indicated by the trace identifier according to the stored abnormality discrimination rules, the target node can aggregate the first link information and the link aggregation information sent by all child nodes of the target node to obtain the fourth link aggregation information. The target node then sends the fourth link aggregation information to the computing center. In this way, even if the service call is normal, the upstream node is provided with the information of the downstream node.
[0016] In a possible implementation, the method also includes: if the interface return status code corresponding to any child node of the present node is abnormal, the interface return error code includes a preset keyword, the interface response time is abnormal, or one or more of the corresponding abnormal indication identifiers are satisfied, then it is determined that there is an abnormality in the service call indicated by the trace identifier.
[0017] In the scheme shown in the present application, this node may be referred to as a target node here. The target node may obtain the interface return status code in each response message from the response message returned by any child node of the target node. The target node determines whether each interface return status code is within a preset value range. If one or more interface return status codes are within a preset value range, the target node may determine that the service call indicated by the trace identifier is abnormal. The target node may determine the time point of receiving the response message returned by any child node of the target node, and determine the time point from when the call request is issued to when the response message is received (i.e., the interface response time). The target node determines whether each interface response time exceeds the preset time. If one or more interface response times exceed the preset time, the target node may determine that the service call indicated by the trace identifier is abnormal. The target node may obtain the interface return error code in each response message from the response message returned by any child node of the target node. The target node determines whether each interface return error code is a preset keyword. If one or more interface return error codes are preset keywords, the target node may determine that the service call indicated by the trace identifier is abnormal. The above three situations are local call errors for the target node, and it is determined that the service call indicated by the trace identifier has an exception. If at least one of the above three situations is met, the target node can determine that the service call indicated by the trace identifier has an exception. The service call indicated by the trace identifier has an exception, which also includes the following situation. After the target node receives a response message sent by the directly called child node, if the response message includes an exception indication identifier, it can also be determined that the service call indicated by the trace identifier has an exception. In this case, it is actually the service call of the downstream node of the target node that is abnormal. In this way, it can be accurately determined that the service call has an exception.
[0018] In a possible implementation, the method includes: periodically determining whether an abnormality determination rule is received; when an abnormality determination rule is received, replacing a currently stored abnormality determination rule with the received abnormality determination rule.
[0019] In the scheme shown in the present application, the target node can periodically determine whether the abnormality discrimination rule is received according to a preset period. When the target node determines that the abnormality discrimination rule is received, the received abnormality discrimination rule can be used to replace the currently stored abnormality discrimination rule. In this way, the timely update of the abnormality discrimination rule can be achieved.
[0020] In a second aspect, the present application provides a device for distributed link collection, which includes one or more modules, and the one or more modules are used to implement the distributed link collection method provided by the above-mentioned first aspect or a possible implementation method of the first aspect.
[0021] In a third aspect, the present application provides a computing device for distributed link collection, the computing device comprising a processor and a memory, wherein the memory stores computer instructions; the processor executes the computer instructions so that the computing device implements the method for distributed link collection provided by the above-mentioned first aspect or a possible implementation of the first aspect, or enables the computing device to implement the functions of the apparatus for distributed link collection provided by the above-mentioned third aspect.
[0022] In a fourth aspect, the present application provides a computer-readable storage medium, which stores computer instructions, wherein the computer instructions instruct the computing device to execute the method for distributed link acquisition provided by the above-mentioned first aspect or a possible implementation of the first aspect, or the computer instructions instruct the computing device to deploy the apparatus for distributed link acquisition provided by the above-mentioned third aspect.
[0023] In a fifth aspect, the present application provides a computer program product comprising instructions, wherein the computer program product includes computer instructions instructing the computing device to execute the method for distributed link acquisition provided by the above-mentioned first aspect or a possible implementation of the first aspect, or the computer program product includes computer instructions instructing the computing device to deploy the apparatus for distributed link acquisition provided by the above-mentioned third aspect.
[0024] The beneficial effects of the technical solution provided by the embodiment of the present application are:
[0025] In the embodiment of the present application, by only collecting data on the links with faults, not only the total amount of distributed link sampling is effectively reduced, but also the diagnostic efficiency of the fault is not affected. Moreover, since only the links with faults are collected, not only the amount of calculation in the computing center can be reduced, but also the occupied storage resources can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 It is a schematic diagram of a span provided in an embodiment of the present application;
[0027] Figure 2 is a schematic diagram of the structure of a computing device provided in an embodiment of the present application;
[0028] Figure 3 This is a schematic diagram of a distributed link collection scenario provided by an embodiment of the present application;
[0029] Figure 4 It is a flow chart of a method for distributed link collection provided in an embodiment of the present application;
[0030] Figure 5 This is a schematic diagram of an application scenario of distributed link collection provided by an embodiment of the present application;
[0031] Figure 6 It is a structural diagram of a distributed link collection device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0032] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0033] In order to facilitate the understanding of the embodiments of the present application, the concepts of the terms involved are first introduced below:
[0034] The call chain (Trace) indicates the tracking of the complete call of a business request. Specifically, it means that in a business request, the first microservice that executes the business request in the microservice architecture generates a globally unique trace identifier, which is used to identify this business request. During the process of calling this business request, the trace identifier will remain unchanged no matter how many microservices it passes through, and it will be continuously passed with the call of each layer of microservices. Finally, the trace identifier can be used to string together all the paths of this business request in the microservice architecture. For example, when executing a certain request, microservice A calls microservice B, microservice B calls microservice C and microservice D, and there is a call chain from microservice A to microservice B, and from microservice B to microservice C and microservice D.
[0035] The call span starts from the first microservice in the call chain (which can be called microservice 1). The first span is as follows Figure 1 As shown in the figure, the process is: Microservice 1 sends a call request to the next downstream Microservice 2. After receiving the call request, Microservice 2 starts processing. After processing, it sends a response message to Microservice 1. After Microservice 1 receives the response message, this process can be considered as a span. Of course, there cannot be only these two microservices, and multiple spans can form a trace.
[0036] Microservices are based on small building blocks that focus on a single responsibility and function. They use a modular approach to combine complex large applications. Each building block communicates with each other using a language-independent / language agnostic application programming interface (API) set.
[0037] In order to solve the problem that the cause of the fault cannot be diagnosed, an embodiment of the present application provides a method for distributed link acquisition, and the execution subject of the method can be a target node for distributed link acquisition. Among them, the target node can be a software device or a hardware device. When the target node is a hardware device, the target node can be a computing device with a microservice, etc. When the target node is a software device, it can be a software program deployed on a computing device (the computing device is provided with a microservice), etc.
[0038] Figure 2 A possible architecture diagram of a computing device of the present application is provided as an example. The computing device may include a processor 201, a memory 202, a communication interface 203, and a bus 204. In the computing device, the number of processors 201 may be one or more. Figure 2 Only one of the processors 201 is shown. Optionally, the processor 201 may be a central processing unit (CPU). If the computing device has multiple processors 201, the types of the multiple processors 201 may be different or the same. Optionally, the multiple processors of the computing device may also be integrated into a multi-core processor.
[0039] The memory 202 stores computer instructions and data. The memory 202 can store computer instructions and data required to implement the method for distributed link acquisition provided in the present application. The memory 202 can be any one or any combination of the following storage media: non-volatile memory (such as read-only memory (ROM), solid state disk (SSD), hard disk (HDD), optical disk, etc.), volatile memory.
[0040] The communication interface 203 may be any one or any combination of the following devices: a network interface (such as an Ethernet interface), a wireless network card, or other devices with a network access function.
[0041] The communication interface 203 is used for the computing device to perform data communication with other computing devices or terminals.
[0042] Figure 2 A thick line represents the bus 204. The bus 204 can connect the processor 201 with the memory 202 and the communication interface 203. Thus, through the bus 204, the processor 201 can access the memory 202, and can also use the communication interface 203 to exchange data with other nodes or terminals.
[0043] In the present application, the computing device executes the computer instructions in the memory 202, so that the computing device implements the distributed link collection method provided in the present application. For example, the computing device executes the steps performed by the receiving module in the distributed link collection method described below. For another example, the computing device executes the steps performed by the sending module in the distributed link collection method described below.
[0044] This application can be applied to Figure 3 The microservice architecture shown includes microservice 1, microservice 2, ..., microservice n (all of which are distributed microservices, and each microservice generates a call chain when executing business processing), and n is greater than 2. A process is set in each microservice to determine whether there is an exception in the service call. The microservice architecture is also connected to a configuration center, which can be implemented by hardware or software. The configuration center is used to issue exception discrimination rules for the microservice architecture. The microservice architecture is also connected to a computing center, which can be implemented by hardware or software. The computing center can be used to determine the cause of the fault based on the link information provided by the microservice. In the specific implementation, the configuration center and the computing center can be deployed in the same hardware device or in different hardware devices.
[0045] In this embodiment, a user interface (UI) is provided for configuring exception discrimination rules for users using a microservice architecture (users may be operation and maintenance personnel in this application). The user can set the contents of the exception discrimination rules in the UI interface, and the exception discrimination rules are used to determine whether there is an exception in the service call. Specifically, the exception discrimination rules may include the interface response time exceeding the preset time (such as 500ms), the interface return status code is a preset numerical range (such as 0-200, 400-600, etc.), the interface return error code is a preset keyword, etc., and the preset keyword may be error, failed, exception, etc. It should be noted here that the interface response time is actually the call time. For example, for the hypertext transfer protocol http, when the interface return status code is not 200, the service call is abnormal. The exception discrimination rule may also include an exception indication mark in the response message. For example, the value of the exception indication mark is "true".
[0046] After the user sets the contents of the exception judgment rule in the UI interface, the exception judgment rule can be sent to the configuration center (such as a configuration server, etc.). After the configuration center receives the exception judgment rule, it can store the exception judgment rule in the form of a key-value pair. Then the configuration center can send the exception judgment rule to the node where each microservice is located. After each microservice node receives the exception judgment rule, it can store the exception judgment rule.
[0047] In addition, after the user submits the contents of the exception discrimination rule, the exception discrimination rule can also be modified through the UI interface, and the modified exception discrimination rule can be sent to the configuration center. After the configuration center receives the modified exception discrimination rule, it can store the modified exception discrimination rule and send the modified exception discrimination rule to the node where each microservice is located. The node where each microservice is located can periodically determine whether the exception discrimination rule is received according to a preset period (such as the period is 30 seconds, etc.). When each microservice node determines that the exception discrimination rule is received, the node where each microservice is located can use the received exception discrimination rule to replace the currently stored exception discrimination rule. In this way, the timely update of the exception discrimination rule can be achieved.
[0048] In addition, each microservice node can also periodically send an abnormality discrimination rule acquisition request to the abnormality discrimination rule configuration center. If the existing abnormality discrimination rules have been updated in the configuration center, the configuration center can send the updated abnormality discrimination rules to each microservice node, so that each microservice node can update the abnormality discrimination rules in a timely manner. If the existing abnormality discrimination rules have not been updated in the configuration center, the configuration device can send a non-updated indication message to each microservice node.
[0049] In this way, through the above method, each microservice node on the microservice architecture obtains the exception judgment rules.
[0050] The following will be combined with specific implementation methods. Figure 4 The processing flow shown is described in detail, and the content can be as follows:
[0051] Step 401: The target node receives a first call request sent by a parent node, where the first call request includes a trace identifier and a span identifier assigned by the parent node.
[0052] The target node is a node other than the first node.
[0053] In this embodiment, a business request is received in the microservice framework. When executing the processing corresponding to the business request, the node where any microservice other than the first microservice in the microservice to execute the business request is located will receive the first call request sent by the node where the upstream microservice is located (which can be called the parent node). The first call request includes a trace identifier and a span identifier, the trace identifier is used to indicate the unique identifier of the business request, and the span identifier is used to indicate the span identifier of the child node where the called microservice is located (that is, the target node mentioned later). The target node belonging to the called microservice can receive the first call request.
[0054] It should be noted here that the node where the first microservice is located (i.e., the first node) will receive the business request. The first node can perform the processing it needs to perform, specifically generating a trace identifier and a span identifier corresponding to the business request. When the first node wants to call the second microservice, it can generate a span identifier for the second microservice (the span identifier serves as the parent span identifier in the second microservice), and add the span identifier to the first call request. The first call request includes the trace identifier and the span identifier. The first node then sends the first call request to the node where the second microservice is located.
[0055] In step 402, the target node executes child node call processing to obtain link aggregation information sent by all child nodes of the target node, wherein, for the link aggregation information sent by any child node, the link aggregation information sent by the child node includes one or more of the number of spans, span depth, involved middleware, and involved microservice names in the downstream call process of the child node.
[0056] In this embodiment, after the target node receives the first call request, if the target node has a downstream microservice to call, the target node can execute the processing of calling the downstream microservice after executing its own internal processing. Specifically, the target node can generate a span identifier, and use the span identifier in the first call request as the parent span identifier of the span identifier generated by the target node, and use the span identifier generated by the target node as the child span identifier of the parent span identifier. The target node can send a second call request to the node where the downstream microservice is located (that is, the child node of the target node). The second call request carries the trace identifier and the span identifier generated by the target node. In this way, since the target node generates a span identifier for the microservice it calls, the target node can obtain the child span identifier of the target node.
[0057] The target node can receive response messages returned by all its child nodes, and the response message returned by each child node includes the link aggregation information of the child node, and the link aggregation information can include one or more of the number of spans, span depth, middleware involved, and microservice name involved in the downstream call process of the child node. The number of spans is the total number of spans experienced by all nodes downstream of the target node in the call chain belonging to the trace identifier. The span depth is the longest depth of all nodes downstream of the target node in the call chain belonging to the trace identifier. For example, microservice A calls microservice B, microservice B calls microservice C and microservice D, microservice C calls microservice E, and there is an exception in the service call of microservice B. The total number of spans experienced by the downstream of microservice B is 3, and the span depth is 2. The middleware involved in the call process may include structured query language (SQL), message queue (MQ), cache, and corresponding instance name, etc. The microservice name involved in the call process is the name of the microservice called in the call process.
[0058] Step 403: The target node determines whether there is an exception in the service call indicated by the trace identifier according to the stored exception identification rule.
[0059] In this embodiment, the target node can obtain the interface return status code in each response message from the response message returned by any child node of the target node. The target node determines whether each interface return status code is within a preset value range. If one or more interface return status codes are within a preset value range, the target node can determine that there is an abnormality in the service call indicated by the trace identifier. The situation where multiple interface return status codes are returned here is that the response messages returned by multiple child nodes directly called by the target node all include the interface return status code.
[0060] The target node can determine the time point of receiving the response message returned by any child node of the target node, and determine the time from the time point of issuing the second call request to the time of receiving the response message (i.e., the interface response time). The target node determines whether the response time of each interface exceeds the preset time. If one or more interface response times exceed the preset time, the target node can determine that there is an abnormality in the service call indicated by the trace identifier. The situation of multiple interface response times here is that multiple child nodes directly called by the target node all return response messages.
[0061] The target node can obtain the interface return error code in each response message from the response message returned by any child node of the target node. The target node determines whether each interface return error code is a preset keyword. If one or more interface return error codes are preset keywords, the target node can determine that there is an exception in the service call indicated by the trace identifier. The situation where multiple interfaces return status codes here is: the response messages returned by multiple child nodes directly called by the target node all include interface return error codes.
[0062] The above three situations are local call errors of the target node, and it is determined that the service call indicated by the trace identifier is abnormal. If at least one of the above three situations is met, the target node can determine that the service call indicated by the trace identifier is abnormal.
[0063] In addition, the service call indicated by the trace identifier has an exception, which also includes the following situation: after the target node receives a response message sent by the directly called child node, if the response message includes an exception indication identifier, it can also be determined that the service call indicated by the trace identifier has an exception. In this case, it is actually the service call of the node downstream of the target node that has an exception.
[0064] If at least one of the above four conditions is satisfied, the target node can determine that the service call indicated by the trace identifier is abnormal. If none of the above four conditions is satisfied, the target node can determine that the service call indicated by the trace identifier is not abnormal.
[0065] For example, Figure 5 As shown, microservice A calls microservice B, and microservice B calls microservice C. Step 1, microservice A sends a first call request to microservice B. Step 2, microservice B receives the first call request and performs internal processing. Step 3, microservice B sends a second call request to microservice C. Step 4, microservice C receives the second call request and performs internal processing. Step 5, microservice C sends a response message to microservice B. Step 6, microservice B receives the response message sent by microservice C and performs internal processing. Step 7, microservice B sends a response message to microservice A. In these 7 steps, as long as errors occur in steps 2, 3, 5, and 6, there are exceptions in the service call in microservice B. For step 2, it is an internal processing error of microservice B; for step 3, it is that microservice B did not issue a second call request; for step 5, microservice B did not receive the response message sent by microservice C or the duration of receiving the response message (i.e., the interface response duration) exceeded the above-mentioned preset duration; for step 6, it is an internal processing error.
[0066] It should be noted that in step 403, the target node can first determine whether there is an exception indication mark in the response message received from the node where the downstream microservice is located. If the response message includes the exception indication mark, it can directly determine that the service call indicated by the trace mark is abnormal without determining whether there is an abnormality in the local call of the target node. If the response message does not include the exception indication mark, the target node will then determine whether the local call is abnormal.
[0067] Step 404: When the target node determines that there is an exception in the service call indicated by the trace identifier based on the stored exception judgment rules, the target node aggregates the link aggregation information of all child nodes of the target node to obtain the first link aggregation information; the first link information and the first link aggregation information corresponding to the trace identifier on the target node are transmitted to the computing center, wherein the first link information includes the sub-span identifier of the node and the internal key call stack.
[0068] Among them, the computing center can be a link device used to determine the microservice architecture, such as a server.
[0069] In this embodiment, if the target node determines that the service call indicated by the trace identifier is abnormal, the first link information corresponding to the trace identifier on the node can be obtained. The first link information includes the subspan identifier of the target node and the internal key call stack. The internal call stack may include the key function call status of the target node's internal call, the internal call abnormality, etc. The target node can then send the first link information to the computing center.
[0070] Furthermore, the target node may aggregate the link aggregation information of all child nodes of the target node to obtain the first link aggregation information. Specifically, the target node adds the number of spans in all link aggregation information to obtain the number of spans in the first link aggregation information. The target node adds 1 to the longest span depth in all link aggregation information to obtain the span depth in the first link aggregation information. The target node takes the union of the middleware involved in all link aggregation information to obtain the middleware involved in the first link aggregation information. The target node takes the union of the microservice names involved in all link aggregation information to obtain the microservice names involved in the first link aggregation information. Then the target node can send the first link aggregation information to the computing center.
[0071] Specifically, the target node may package the first link aggregation information and the first link information together and send them to the computing center.
[0072] It should be noted here that, in this embodiment, it is assumed that the target node also calls the downstream microservice. If the target node no longer calls the downstream microservice, the target node will not receive the link aggregation information sent by the node where the downstream microservice is located.
[0073] In addition, the sub-span identifier in the first link information is the sub-span identifier of all microservices directly called by the target node. For example, microservice A calls microservice B, microservice B calls microservice C and microservice D, and there is an exception in the service call of microservice B. The sub-span identifier of microservice B includes the sub-span identifier of microservice C and the sub-span identifier of microservice D. The first link information can also include the local call duration, that is, the duration taken by the target node to call its child node. For example, microservice A calls microservice B, and microservice B calls microservice C and microservice D. For microservice A, the local call duration is the duration from when microservice A sends a call request to microservice B to when it receives the response message sent by microservice B.
[0074] Step 405, when the target node determines that there is an exception in the service call indicated by the trace identifier based on the stored exception judgment rules, the target node sends an exception indication identifier to the parent node, wherein the exception indication identifier is used to instruct the parent node to transmit the second link information and second link aggregation information corresponding to the trace identifier on the parent node to the computing center, the second link information includes the child span identifier and internal key call stack of the parent node, and the second link aggregation information is obtained by aggregating the link aggregation information sent by the child nodes of the parent node.
[0075] In this embodiment, when the target node determines that the service call indicated by the trace identifier is abnormal according to the stored abnormality discrimination rules, the target node can determine the parent node that sent the first call request. The target node then sends a response message to the parent node, and carries the abnormality indication identifier in the response message. The abnormality indication identifier is used to instruct the parent node to transmit the second link information corresponding to the trace identifier on the parent node and the link aggregation information of its own child node to the computing center.
[0076] After the parent node receives the response message sent by the target node, it can parse the response message, obtain the exception indication mark, and then determine that the service call corresponding to the trace mark has an exception. The parent node can obtain the second link information corresponding to the trace mark, and the second link information can include all child span marks and internal call stacks of the parent node. And after the parent node obtains the exception indication mark, it can also aggregate the link aggregation information sent by its own child nodes to obtain the second link aggregation information (aggregation processing see step 404). The parent node sends the second link aggregation information and the second link information to the computing center. In this way, the link information on the parent node of the target node where the service call has an exception can also be provided to the computing center, so that the computing center can determine the fault location.
[0077] For example, when executing a business request, the node where microservice A is located is the first node and generates a trace identifier. Microservice A calls microservice B, and microservice B calls microservice C and microservice D. Microservice B determines that there is an exception in the service call corresponding to the trace identifier. The node where microservice B is located sends a response message to the node where microservice A is located (that is, the parent node), and the response message carries an exception indication identifier. The parent node where microservice A is located sends the second link information corresponding to the trace identifier to the computing center.
[0078] In addition, the sub-span identifier in the second link information is the sub-span identifier of all microservices called by the parent node. The second link information can also include the local call duration, that is, the duration used by the parent node to call its child node. For example, microservice A calls microservice B, and microservice B calls microservice C and microservice D. For microservice A, the local call duration is the duration from when microservice A sends a call request to microservice B to when it receives the response message sent by microservice B.
[0079] In addition, after the parent node receives the response message including the abnormal indication identifier, it can send a response message to the parent node of the parent node. The response message also includes an abnormal indication identifier, and the abnormal indication identifier is used to instruct the parent node of the parent node to transmit the third link information and the third link aggregation information corresponding to the trace identifier to the computing center. The third link information may include the child span identifier and the internal key call stack of the parent node of the parent node. In this way, the parent node of the parent node can also send a response message including the abnormal indication identifier to its parent node. In this way, it is equivalent to the abnormal indication identifier also being used to indicate that the parent node of the target node notifies the node that directly or indirectly calls the parent node to transmit the third link information corresponding to the trace identifier to the computing center. The third link aggregation information is obtained after each upstream parent node of the parent node of the target node receives the link aggregation information from its own child node and performs aggregation processing. In this way, more information corresponding to the Trace identifier can be provided to the computing center, which is convenient for the computing center to locate the fault location.
[0080] Step 406: When the target node determines that the service call indicated by the trace identifier is not abnormal according to the stored abnormality identification rule, it aggregates the first link information and the first link aggregation information to obtain fourth link aggregation information. The target node sends the fourth link aggregation information to the parent node.
[0081] The first link diagnostic information also includes the middleware called by the target node and the microservice name of the microservice called by the target node.
[0082] In this embodiment, when the target node determines that there is no abnormality in the service call indicated by the trace identifier according to the stored abnormality discrimination rule, the target node can aggregate the first link information and the link aggregation information sent by all child nodes of the target node to obtain the fourth link aggregation information. Specifically, the target node can add the sub-span identifier, local call duration and internal call stack in the first link information to the first link aggregation information, and the target node adds the number of sub-span identifiers in the first link information to the number of spans in the first link aggregation information to obtain the number of spans in the fourth link aggregation information. And the target node adds 1 to the span depth in the first link aggregation information to obtain the span depth in the fourth link aggregation information. And the target node takes the middleware in the first link aggregation information and the middleware in the first link information to obtain the middleware in the fourth link aggregation information. And the target node takes the microservice name in the first link aggregation information and the microservice name in the first link information to obtain the middleware in the fourth link aggregation information. Then the target node sends the fourth link aggregation information to the parent node. In this way, even if the service call is normal, the information of the downstream node can be provided to the upstream node.
[0083] In addition, in this embodiment, after receiving all link information and link aggregation information corresponding to the trace identifier, the computing center can verify and clean all link information and link aggregation information, save them to the database, and create an index for them. For example, the computing center can use the trace identifier to create an index. In addition, in order to save storage resources, the computing center can also compress all link information and link aggregation information before storing them.
[0084] In addition, the computing center can determine the fault location based on the link information and link aggregation information, and send an alarm to the user's terminal, so that the user can understand the faulty microservice in a timely manner and take corresponding measures. Specifically, the computing center can determine the faulty node and the corresponding program stack through the link information and link aggregation information (such as analyzing whether the key call stack is correct, whether the call sequence is normal, etc.), and then the computing center sends the faulty node and the corresponding program stack to the user's terminal.
[0085] It should be noted that, in this embodiment, the target node is any node except the first node and the last node on the call chain for executing the service request.
[0086] In addition, a collection device is provided on the target node to intercept various microservice calls to create span identifiers, trace identifiers, and transmit span identifiers, trace identifiers, etc. The collection device can be similar to the non-intrusive loading of class libraries javaagent in java applications. In addition, the collection device is also used for the target node to receive the exception discrimination rules issued by the configuration center, and send link information, link aggregation information, etc. to the computing center according to the exception discrimination rules.
[0087] In addition, this embodiment also provides a process to avoid overload of link information reporting caused by frequent microservice errors: in the actual operation of the microservice framework, frequent microservice errors may cause 100% upload of link information. Within a statistical period, if the computing center determines that the error rate exceeds a preset value, the computing center notifies the nodes where each microservice in the microservice framework is located of other content except for the content that has been reported, and no other content will be reported to the computing center.
[0088] It should be noted that, in the embodiment of the present application, the child node refers to the node where the called microservice runs.
[0089] In the embodiment of the present application, the abnormal discrimination rule is used to determine the link with faults. By only collecting the links with faults, not only the total amount of distributed link sampling is effectively reduced, but also the diagnostic efficiency of the fault is not affected. Moreover, since only the links with faults are collected, the amount of calculation in the computing center can be reduced, and the occupied storage resources can be reduced.
[0090] Figure 6 The structure diagram of the device for distributed link collection provided in the embodiment of the present application. The device can be implemented as part or all of the device through software, hardware or a combination of both. The device provided in the embodiment of the present application can implement the embodiment of the present application Figure 4 The process described above, the device includes: a receiving module 610, an execution module 620 and a sending module 630, wherein:
[0091] The receiving module 610 is used to receive a first call request sent by a parent node, wherein the first call request includes a call chain trace identifier and a call span identifier allocated by the parent node, and can be specifically used to implement the receiving function of step 401 and the implicit steps included in step 401;
[0092] An execution module 620 is used to execute child node call processing and obtain link aggregation information sent by all child nodes of the node, wherein, for the link aggregation information sent by any child node, the link aggregation information sent by the child node includes one or more of the number of spans, span depth, involved middleware, and involved microservice names in the downstream call process of the child node; when it is determined that the service call indicated by the trace identifier is abnormal according to the stored abnormality discrimination rule, the link aggregation information of all child nodes of the node is aggregated to obtain the first link aggregation information, which can be specifically used to implement the execution functions of steps 402 to 404 and the implicit steps included in steps 402 to 404;
[0093] The sending module 630 is used to transmit the first link information and the first link aggregation information corresponding to the trace identifier on the current node to the computing center, wherein the first link information includes the sub-span identifier and the internal key call stack of the current node, and the parent span identifier of the sub-span identifier is the span identifier assigned by the parent node, which can be specifically used to implement the sending function of step 404 and the implicit steps contained in step 404.
[0094] In a possible implementation, the sending module 630 is further configured to:
[0095] An exception indication identifier is sent to the parent node, wherein the exception indication identifier is used to instruct the parent node to transmit the second link information and second link aggregation information corresponding to the trace identifier on the parent node to the computing center, the second link information includes the child span identifier and internal key call stack of the parent node, and the second link aggregation information is obtained by aggregating the link aggregation information sent by the child nodes of the parent node.
[0096] In a possible implementation, the exception indication identifier is also used to instruct the parent node to notify the upstream node that directly or indirectly calls the parent node to transmit the third link information and third link aggregation information corresponding to the trace identifier to the computing center, the third link information includes the sub-span identifier and internal key call stack of the upstream node, and the third link aggregation information is obtained by aggregating the link aggregation information sent by the child nodes of the upstream node.
[0097] In a possible implementation, the execution module 620 is further configured to, when it is determined according to the stored abnormality identification rule that the service call indicated by the trace identifier does not have an abnormality, aggregate the first link information and the first link aggregation information to obtain fourth link aggregation information;
[0098] The sending module is further configured to send the fourth link aggregation information to the parent node.
[0099] In a possible implementation, the execution module 620 is further configured to:
[0100] If the interface return status code corresponding to any child node of the present node is abnormal, the interface return error code includes preset keywords, the interface response time is abnormal, or one or more of the corresponding abnormal indication identifiers are satisfied, it is determined that the service call indicated by the trace identifier is abnormal.
[0101] In a possible implementation, the execution module 620 is further configured to:
[0102] Periodically determine whether an abnormality discrimination rule has been received;
[0103] When an abnormality determination rule is received, the received abnormality determination rule is used to replace the currently stored abnormality determination rule.
[0104] The division of modules in the above embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, each functional module in each embodiment of the present application may be integrated into a processor, or may exist physically separately, or two or more modules may be integrated into one module. The above integrated modules may be implemented in the form of hardware or in the form of software functional modules.
[0105] It should be noted that: the distributed link collection device provided in the above embodiment only uses the division of the above functional modules as an example for distributed link collection. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the distributed link collection device provided in the above embodiment and the distributed link collection method embodiment belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0106] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a server or terminal, the process or function described in the embodiment of the present application is generated in whole or in part. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a server or terminal or a data storage device such as a server or data center that includes one or more available media integration. The available medium can be a magnetic medium (such as a floppy disk, a hard disk and a tape, etc.), or an optical medium (such as a digital video disk (Digital Video Disk, DVD), etc.), or a semiconductor medium (such as a solid-state hard disk, etc.).
Claims
1. A method for distributed link collection, It is characterized in that The method comprises: Receive a first call request sent by a parent node, wherein the first call request includes a call chain trace identifier and a call span identifier allocated by the parent node; Execute child node call processing to obtain link aggregation information sent by all child nodes of the node, wherein, for the link aggregation information sent by any child node, the link aggregation information sent by the child node includes one or more of the number of spans, span depth, involved middleware, and involved microservice names in the downstream call process of the child node; When it is determined according to the stored exception discrimination rule that the service call indicated by the trace identifier is abnormal, aggregating the link aggregation information of all child nodes of the node to obtain first link aggregation information; The first link information and the first link aggregation information corresponding to the trace identifier on the node are transmitted to the computing center, wherein the first link information includes the sub-span identifier of the node, the internal key call stack, and the duration used to call the sub-node, the internal key call stack includes the key function call status of the internal call and the internal call exception status, and the parent span identifier of the sub-span identifier is the span identifier assigned by the parent node; An exception indication identifier is sent to the parent node, wherein the exception indication identifier is used to instruct the parent node to transmit the second link information and second link aggregation information corresponding to the trace identifier on the parent node to the computing center, the second link information includes the child span identifier and internal key call stack of the parent node, and the second link aggregation information is obtained by aggregating the link aggregation information sent by the child nodes of the parent node.
2. The method according to claim 1, It is characterized in that The exception indication identifier is also used to instruct the parent node to notify the upstream node that directly or indirectly calls the parent node, and transmit the third link information and third link aggregation information corresponding to the trace identifier to the computing center, the third link information includes the sub-span identifier and internal key call stack of the upstream node, and the third link aggregation information is obtained by aggregating the link aggregation information sent by the child nodes of the upstream node.
3. The method according to claim 1 or 2, It is characterized in that The method further comprises: When it is determined according to the stored abnormality identification rule that there is no abnormality in the service call indicated by the trace identifier, aggregating the first link information and the first link aggregation information to obtain fourth link aggregation information; The fourth link aggregation information is sent to the parent node.
4. The method according to claim 1 or 2, It is characterized in that The method further comprises: If the interface return status code corresponding to any child node of the present node is abnormal, the interface return error code includes preset keywords, the interface response time is abnormal, or one or more of the corresponding abnormal indication identifiers are satisfied, it is determined that the service call indicated by the trace identifier is abnormal.
5. The method according to claim 1 or 2, It is characterized in that The method comprises: Periodically determine whether an abnormality discrimination rule has been received; When an abnormality determination rule is received, the received abnormality determination rule is used to replace the currently stored abnormality determination rule.
6. A device for distributed link collection, It is characterized in that The device comprises: A receiving module, configured to receive a first call request sent by a parent node, wherein the first call request includes a call chain trace identifier and a call span identifier allocated by the parent node; An execution module, used to execute child node call processing, obtain link aggregation information sent by all child nodes of the node, wherein, for the link aggregation information sent by any child node, the link aggregation information sent by the child node includes one or more of the number of spans, span depth, involved middleware, and involved microservice names in the downstream call process of the child node; when it is determined that the service call indicated by the trace identifier is abnormal according to the stored abnormality discrimination rule, the link aggregation information of all child nodes of the node is aggregated to obtain the first link aggregation information; A sending module, used to transmit the first link information and the first link aggregation information corresponding to the trace identifier on the node to a computing center, wherein the first link information includes the sub-span identifier of the node, an internal key call stack, and the duration used to call the sub-node, the internal key call stack includes the key function call status of the internal call and the internal call exception status, and the parent span identifier of the sub-span identifier is the span identifier assigned by the parent node; An exception indication identifier is sent to the parent node, wherein the exception indication identifier is used to instruct the parent node to transmit the second link information and second link aggregation information corresponding to the trace identifier on the parent node to the computing center, the second link information includes the child span identifier and internal key call stack of the parent node, and the second link aggregation information is obtained by aggregating the link aggregation information sent by the child nodes of the parent node.
7. The device according to claim 6, It is characterized in that The exception indication identifier is also used to instruct the parent node to notify the upstream node that directly or indirectly calls the parent node, and transmit the third link information and third link aggregation information corresponding to the trace identifier to the computing center, the third link information includes the sub-span identifier and internal key call stack of the upstream node, and the third link aggregation information is obtained by aggregating the link aggregation information sent by the child nodes of the upstream node.
8. The device according to claim 6 or 7, It is characterized in that The execution module is further configured to aggregate the first link information and the first link aggregation information to obtain fourth link aggregation information when it is determined that the service call indicated by the trace identifier does not have an abnormality according to the stored abnormality discrimination rule; The sending module is further configured to send the fourth link aggregation information to the parent node.
9. The device according to claim 6 or 7, It is characterized in that The execution module is further used for: If the interface return status code corresponding to any child node of the present node is abnormal, the interface return error code includes preset keywords, the interface response time is abnormal, or one or more of the corresponding abnormal indication identifiers are satisfied, it is determined that the service call indicated by the trace identifier is abnormal.
10. The device according to claim 6 or 7, It is characterized in that The execution module is further used for: Periodically determine whether an abnormality discrimination rule has been received; When an abnormality determination rule is received, the received abnormality determination rule is used to replace the currently stored abnormality determination rule.
11. A computing device for distributed link collection, It is characterized in that The computing device comprises a processor and a memory, wherein: The memory stores computer instructions; The processor executes the computer instructions so that the computing device implements the method described in any one of claims 1 to 5, or enables the computing device to implement the function of the apparatus described in any one of claims 6 to 10.
12. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer instructions, which instruct a computing device to execute the method described in any one of claims 1 to 5, or the computer instructions instruct the computing device to implement the function of the apparatus described in any one of claims 6 to 10.
