Method, system, storage medium, and electronic device for updating topological relationship in real time
Through streaming analysis and OTel agent's real-time update of topological relationships, the problem of real-time analysis of calling links in distributed systems is solved, performance improvement and stability enhancement under high concurrency are achieved, and problems of memory consumption and recursive search are avoided. .
Patent Information
- Application Number
- CN202211706627.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-29
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2042-12-29
AI Technical Summary
In distributed systems, existing technologies are difficult to achieve real-time analysis and tracking of distributed call links, especially in high concurrency situations, resulting in poor analysis performance and requiring a large amount of memory to store massive Span data.
Adopting a streaming analysis solution, the OTel agent registers information when the application is started, and injects token information when the application is called to update topological relationships in real time. There is no need to cache Span data. It is directly analyzed and stored on the observability service platform to achieve real-time updates. and delete Span.
It reduces the pressure on analysis nodes, improves server performance and stability, avoids problems caused by memory consumption and recursive search, and enables real-time and accurate call topological relationship analysis.
Smart Images

Figure CN115883385B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of cloud computing, and in particular relates to a method, system, storage medium, and electronic device for updating topological relationships in real time. Background Art
[0002] With the expansion of Internet business and the upgrade of architecture, systems are becoming increasingly complex, and more and more systems are moving towards distributed systems. System distribution can bring great performance improvement and functional decoupling, but it also has certain disadvantages. Since distributed systems often have many service units, and service units are interdependent, a request may involve many internal services calling each other. Once errors and exceptions occur, it is difficult to locate them. Therefore, in the distributed system architecture, there is an urgent need for distributed call link tracking, which tracks the call relationship between each service from the user's request, so as to quickly locate the root cause of the problem.
[0003] At present, there are many open source systems for call chain tracking and analysis, such as jaeger, zikpin, elasticapm, pinpoint, and skywalking. There are also many ways to analyze the topology architecture of distributed systems. Most of them use querying stored call chain data to analyze topological relationships offline, and count upstream and downstream calls based on the call chain data in the corresponding time range. However, there are few methods for real-time analysis of topology and call status, especially how to ensure the performance of analysis under high concurrency.
[0004] For example, the Chinese invention patent with publication number CN111464352A discloses a call link data processing method and device. The invention uses Span span data to parse the service-to-service topological relationship. First, the Span data with the same traceId is written to the same partition of the message middleware according to hash (traceId), and then the Span data with the same traceId is written to redis. At the same time, the traceId key value is cached locally and the validity period is set. When the key value expires, all spans are obtained from redis according to this traceId to analyze the service-to-service topological relationship. In essence, it is still a scheduled task to obtain all spans for analysis. Redis needs to store massive Span data and consumes a lot of memory. Summary of the invention
[0005] In view of the above-mentioned problems existing in the prior art, the present invention provides a method, system, storage medium, and electronic device for updating topological relationships in real time. The method adopts a streaming analysis solution, eliminates the need to cache Span data, and implements the process of completing the analysis immediately upon receiving the Span, thereby alleviating the pressure on the analysis node and improving the performance and stability of the server.
[0006] The present invention adopts the following technical solutions:
[0007] A first aspect of an embodiment of the present invention provides a method for updating a topological relationship in real time, comprising the steps of:
[0008] The upstream application and the downstream application are started, and the application information is registered to the observability service platform through their respective Otel agents. The observability service platform returns the tokenA information corresponding to the upstream application and the tokenB information corresponding to the downstream application.
[0009] The user calls the upstream application, which creates the first span and injects tokenA information into it.
[0010] The upstream application calls its internal service ServiceA, ServiceA calls the service ServiceB in the downstream application, ServiceA creates the second Span and injects the information in the first Span into the second Span, ServiceB creates the third Span and injects the information in the second Span into the third Span, as well as the tokenB information;
[0011] ServiceA reports the second Span to the observability service platform, and ServiceB reports the third Span to the observability service platform. The observability service platform updates and stores the topological relationship in real time based on the corresponding information in the second Span and the third Span, and deletes the second Span and the third Span after obtaining the topological relationship.
[0012] As a preferred solution, OTeL agent registers the instance information, project information and other contexts of upstream and downstream applications to the observability service platform. The observability service platform returns the tokenA information corresponding to the upstream application and the tokenB information corresponding to the downstream application.
[0013] As a preferred solution, the tokenA information and the entry name information in the first Span are injected into the second Span, and the second Span also includes the exit address information.
[0014] As a preferred solution, the tokenA information, the entry name information, the exit address information in the second Span are injected into the third Span, and the tokenB information is also injected.
[0015] As a preferred solution, if a network failure occurs when ServiceA calls ServiceB for the second time, the observability service platform updates and stores the topology relationship in real time based on the topology relationship stored when ServiceA calls ServiceB for the first time and the span reported when ServiceA calls ServiceB for the second time, and deletes the span reported by ServiceA for the second time after obtaining the topology relationship.
[0016] A second aspect of an embodiment of the present invention provides a system for updating topological relationships in real time, the system comprising an observability service platform, multiple applications, and an Otel agent deployed in the application;
[0017] OTel agent, used to propagate application information to the observability service platform when the application starts;
[0018] Observability service platform, used to return the application token information to the corresponding application;
[0019] OTel agent is also used to inject the application token information into the created span;
[0020] OTel agent is also used to upload span information to the observability service platform;
[0021] OTel agent is also used to propagate the key information of the current span of the application when the application is called internally or across applications, so that the called application can report the key information of the upstream application at the same time when reporting the span to the observability service platform;
[0022] The observability service platform is also used to update and store the topology relationship in real time based on the Span information reported by the application, and delete the Span after obtaining the topology relationship.
[0023] As a preferred solution, OTeL agent is used to register the application's instance information, project information and other contexts to the observability service platform when the application starts.
[0024] As a preferred solution, when an application is called internally, OTeL agent propagates the token information and entry name information in the application Span to the Span created by the internal service of the application.
[0025] As a preferred solution, when calling across applications, OTeL agent propagates the token information, entry name information, and exit address information in the Span created by the internal service of the application to the downstream application.
[0026] A third aspect of an embodiment of the present invention provides a computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable the computer to execute a method for real-time updating of topological relationships as described in the first aspect of the embodiment of the present invention and any one of the first aspects.
[0027] A fourth aspect of an embodiment of the present invention provides an electronic device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the computer instructions to execute a method for real-time updating of topological relationships as described in the first aspect of the embodiment of the present invention and any one of the first aspects.
[0028] The beneficial effects of the present invention are:
[0029] Through secondary development and transformation of OTeL agent, the key information of the current Span is propagated during internal and cross-application calls, so that when the downstream application reports the Span, the key information of the upstream application can be reported at the same time. When the observability service platform receives the Span reported by the downstream application, it analyzes the calling relationship between services in real time without relying on historical Span span data, effectively reducing the pressure on the analysis node and improving system stability.
[0030] By adopting a streaming analysis solution, there is no need to cache Span data, and the analysis process can be completed immediately after receiving the Span, which relieves the pressure on the analysis node and improves the performance and stability of the server. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0032] Figure 1 is a flow chart of a method for updating topological relationships in real time according to an embodiment of the present invention;
[0033] Figure 2 is a structural block diagram of a system for updating topological relationships in real time according to an embodiment of the present invention;
[0034] Figure 3 is a schematic diagram of the structure of a computer-readable storage medium provided according to an embodiment of the present invention;
[0035] Figure 4 is a schematic diagram of the structure of an electronic device provided according to an embodiment of the present invention. DETAILED DESCRIPTION
[0036] The following describes the embodiments of the present invention through specific embodiments, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0037] Embodiment 1:
[0038] In order to realize the function of discovering topological relationships in real time through streaming analysis, we transformed OTelagent through secondary development to propagate the key information of the current Span when calling within the application and across applications, so that when the downstream application reports the Span, the key information of the upstream application can be reported at the same time. The backend service generates the topological relationship between applications in real time based on the current application information of the reported Span and the key information of the upstream application.
[0039] The core idea is to register instance information, project information and other contexts to the backend service through the Otel agent when the application starts, and record the returned token information. When the user initiates a call to the application to generate a span, the above token information is attached, and it is propagated when the internal method is called to create the span. Other applications also attach the propagated token and entry name when they receive the request and generate a span. After the interface processing is completed, the span is asynchronously reported to the backend service. The backend service parses the token into the application's instance information, project information and other contexts, and updates the topology relationship in real time.
[0040] Reference Figure 1 As shown, a method for updating a topological relationship in real time disclosed in this embodiment includes the steps of:
[0041] The upstream application and the downstream application are started, and the application information is registered to the observability service platform through their respective Otel agents. The observability service platform returns the tokenA information corresponding to the upstream application and the tokenB information corresponding to the downstream application.
[0042] OTel agent registers the instance information, project information and other contexts of upstream and downstream applications to the observability service platform. The observability service platform returns the tokenA information corresponding to the upstream application and the tokenB information corresponding to the downstream application.
[0043] The user calls the upstream application, which creates the first span and injects tokenA information into it.
[0044] The upstream application calls its internal service ServiceA, ServiceA calls the service ServiceB in the downstream application, ServiceA creates the second Span and injects the information in the first Span into the second Span, ServiceB creates the third Span and injects the information in the second Span into the third Span, as well as the tokenB information;
[0045] The tokenA information and the entry name information in the first Span are injected into the second Span, and the second Span also includes the exit address information.
[0046] Inject the tokenA information, entry name information, exit address information, and tokenB information in the second Span into the third Span.
[0047] ServiceA reports the second Span to the observability service platform, and ServiceB reports the third Span to the observability service platform. The observability service platform updates and stores the topological relationship in real time based on the corresponding information in the second Span and the third Span, and deletes the second Span and the third Span after obtaining the topological relationship.
[0048] Among them, when ServiceA calls ServiceB for the first time, the network is normal. If a network failure occurs when ServiceA calls ServiceB for the second time, the observability service platform updates the topology relationship in real time and stores it based on the topology relationship stored when ServiceA calls ServiceB for the first time and the span reported when ServiceA calls ServiceB for the second time, and deletes the span reported by ServiceA for the second time after obtaining the topology relationship.
[0049] Specifically, the following examples are given:
[0050] The overall processing flow of this solution includes two scenarios: normal call and abnormal call. In the normal call scenario, for example, a user initiates an interface call to application A's interface ControllerA, ControllerA calls the internal service ServiceA, ServiceA initiates an interface call to application B's interface ControllerB, and application B responds to A with a message. In this scenario, the interface ControllerA generates the external entry Span1 (name=ControllerA, token=tokenA, traceId=1, spanId=1), the internal service ServiceA generates Span2 (name=ServiceA, token=tokenA, traceId=1, spanId=2, parentSpanId=1, ParentName=ControllerA, dest=1.2.3.4), and when ControllerB of application B calls it, it generates Span3 (name=ControllerB, token=tokenB, traceId=1, spanId=3, parentSpanId=2, parentToken=tokenA, parentName=ControllerA, parentDest=1.2.3.4). When the backend service receives the Span3 data, it parses the tokenA to obtain the ServiceA name, and combines the other information of Span3 to obtain the following call relationship table 1:
[0051] Table 1 The first call relationship table
[0052] Upstream Downstream Number of calls Abnormal number A.ControllerA B.ControllerB 1 0
[0053] If a network failure or other reasons occur when application A calls application B, causing the request to fail to reach B, it is necessary to analyze the communication address when A initiates the call to B.
[0054] During the first normal call, the backend service analyzes the Span2 and obtains the following call relationship table 2:
[0055] Table 2 Second call relationship table
[0056] Upstream Downstream Number of calls Abnormal number A.ControllerA 1.2.3.4 1 0
[0057] When a network failure occurs during the second call, ServiceA generates Span2` (name=ServiceA, token=tokenA, traceId=1, spanId=2, parentSpanId=1, ParentName=ControllerA, dest=1.2.3.4). The backend service analyzes and statistics Span2` and the topological relationship stored during the first call, that is, the second call relationship table, and obtains relationship table 3:
[0058] Table 3 The third call relationship table
[0059] Upstream Downstream Number of calls Abnormal number A.ControllerA 1.2.3.4 2 1
[0060] Because the request cannot reach B, the statistics of A->B remain unchanged, and the call relationship table stored during the first normal call is still used, as shown in Table 4:
[0061] Table 4 The fourth call relationship table
[0062] Upstream Downstream Number of calls Abnormal number A.ControllerA B.ControllerB 1 0
[0063] Combining Table 3 and Table 4, the final call topology relationship is analyzed as shown in the following table:
[0064] Upstream Downstream Number of calls Abnormal number A.ControllerA B.ControllerB 1 0 A.ControllerA 1.2.3.4 1 1
[0065] The solution of the present invention fully considers normal and abnormal scenarios, and can accurately analyze the call topology relationship of the application in real time through streaming processing, abandoning the memory consumption problem caused by recursively searching the parent Span through parentSpanId, significantly reducing memory consumption, alleviating the pressure on the analysis node, and improving the performance and stability of the server.
[0066] Embodiment 2:
[0067] Reference Figure 2 As shown, this embodiment provides a system for updating topological relationships in real time, the system including an observability service platform, multiple applications, and an Otel agent deployed in the application;
[0068] OTel agent, used to propagate application information to the observability service platform when the application starts;
[0069] Observability service platform, used to return the application token information to the corresponding application;
[0070] OTel agent is also used to inject the application token information into the created span;
[0071] OTel agent is also used to upload span information to the observability service platform;
[0072] OTel agent is also used to propagate the key information of the current span of the application when the application is called internally or across applications, so that the called application can report the key information of the upstream application at the same time when reporting the span to the observability service platform;
[0073] The observability service platform is also used to update and store the topology relationship in real time based on the Span information reported by the application, and delete the Span after obtaining the topology relationship.
[0074] Specifically:
[0075] OTel agent is used to register the application's instance information, project information and other contexts to the observability service platform when the application starts.
[0076] When an application is called internally, OTeL agent propagates the token information and entry name information in the application span to the span created by the internal service of the application.
[0077] When calling across applications, OTeL agent propagates the token information, entry name information, and exit address information in the span created by the internal service of the application to the downstream application.
[0078] It should be noted that the system for real-time updating of topological relationships provided in this embodiment is similar to that in the first embodiment and will not be described in detail here.
[0079] Embodiment three:
[0080] Reference Figure 3 As shown, the embodiment of the present invention further provides a storage medium on which a computer program 601 is stored. When the instruction is executed by the processor, the steps of a method for updating a topological relationship in real time in the above embodiment are implemented. Those skilled in the art can understand that the implementation of all or part of the process in the method of the above embodiment can be completed by instructing related hardware through a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the process of the above embodiment 1.
[0081] Among them, the storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory (Flash Memory), a hard disk (Hard Disk Drive, abbreviated as: HDD) or a solid-state drive (SSD), etc.; the storage medium can also include a combination of the above types of memory.
[0082] Embodiment 4:
[0083] Reference Figure 4 As shown, an embodiment of the present invention further provides an electronic device, which may include a processor 51 and a memory 52, wherein the processor 51 and the memory 52 may be connected via a bus or other means. Figure 4 The example of connecting through bus is taken in the following.
[0084] The processor 51 may be a central processing unit (CPU). The processor 51 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above chips.
[0085] The memory 52 is a non-transitory computer-readable storage medium that can be used to store non-transitory software programs, non-transitory computer executable programs and modules, such as the corresponding program instructions / modules in the embodiment of the present invention. The processor 51 executes various functional applications and data processing of the processor by running the non-transitory software programs, instructions and modules stored in the memory 52, that is, a method for real-time updating of topological relationships in the above-mentioned embodiment 1 is implemented.
[0086] The memory 52 may include a program storage area and a data storage area, wherein the program storage area may store an application required for operating the device and at least one function; the data storage area may store data created by the processor 51, etc. In addition, the memory 52 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some embodiments, the memory 52 may optionally include a memory remotely arranged relative to the processor 51, and these remote memories may be connected to the processor 51 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0087] The one or more modules are stored in the memory 52, and when executed by the processor 51, a method for real-time updating of topological relationships described in the first embodiment is executed.
[0088] The specific details of the above electronic device can be understood by referring to the corresponding descriptions and effects in the first embodiment, which will not be repeated here.
[0089] The embodiments described above are merely descriptions of preferred implementations of the present invention and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary technicians in this field should all fall within the protection scope of the present invention.
Claims
1. A method for updating topological relationships in real time, characterized in that: Includes steps: The upstream application and the downstream application are started, and the application information is registered to the observability service platform through their respective Otel agents. The observability service platform returns the tokenA information corresponding to the upstream application and the tokenB information corresponding to the downstream application. The user calls the upstream application, which creates the first span and injects tokenA information into it. The upstream application calls its internal service ServiceA, ServiceA calls the service ServiceB in the downstream application, ServiceA creates the second Span and injects the information in the first Span into the second Span, ServiceB creates the third Span and injects the information in the second Span into the third Span, as well as the tokenB information; ServiceA reports the second Span to the observability service platform, and ServiceB reports the third Span to the observability service platform. The observability service platform updates and stores the topological relationship in real time based on the corresponding information in the second Span and the third Span, and deletes the second Span and the third Span after obtaining the topological relationship.
2. A method for updating topological relationships in real time according to claim 1, characterized in that: OTel agent registers the instance information, project information and other contexts of upstream and downstream applications to the observability service platform. The observability service platform returns the tokenA information corresponding to the upstream application and the tokenB information corresponding to the downstream application.
3. A method for updating topological relationships in real time according to claim 1, characterized in that: The tokenA information and the entry name information in the first Span are injected into the second Span, and the second Span also includes the exit address information.
4. A method for updating topological relationships in real time according to claim 3, characterized in that: Inject the tokenA information, entry name information, exit address information in the second Span into the third Span, and inject the tokenB information.
5. A method for updating topological relationships in real time according to claim 4, characterized in that: If a network failure occurs when ServiceA calls ServiceB for the second time, the observability service platform updates and stores the topology relationship in real time based on the topology relationship stored when ServiceA calls ServiceB for the first time and the span reported when ServiceA calls ServiceB for the second time, and deletes the span reported by ServiceA for the second time after obtaining the topology relationship.
6. A system for updating topological relationships in real time, characterized in that: The system includes an observability service platform, multiple applications, and Otel agents deployed in the applications; OTel agent, used to propagate application information to the observability service platform when the application starts; Observability service platform, used to return the application token information to the corresponding application; OTel agent is also used to inject the application token information into the created span; OTel agent is also used to upload span information to the observability service platform; OTel agent is also used to propagate the key information of the current span of the application when the application is called internally or across applications, so that the called application can report the key information of the upstream application at the same time when reporting the span to the observability service platform; The observability service platform is also used to update and store the topology in real time based on the Span information reported by the application, and delete the Span after obtaining the topology; When the application is called internally, OTeL agent propagates the token information and entry name information in the application span to the span created by the internal service of the application; When calling across applications, OTeL agent propagates the token information, entry name information, and exit address information in the span created by the internal service of the application to the downstream application.
7. A system for updating topological relationships in real time according to claim 6, characterized in that: OTel agent is used to register the application's instance information, project information and other contexts to the observability service platform when the application starts.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the method for updating topological relationships in real time as described in any one of claims 1 to 5.
9. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for real-time updating of topological relationships as described in any one of claims 1-5 by executing the computer instructions.
Citation Information
Patent Citations
Call link data processing method and device
CN111464352A
Converged storage method of service source data
CN104572856A
Calling chain data generation method and system, topology generation method and system and computer equipment
CN112363855A
Data flow tokens to trace execution of services in a service provider network
US10284660B1
