Message tracking method and device, computer equipment, readable storage medium and program product
By generating and summarizing the information of the message tracking unit in a distributed system, the problems of message loss, duplication and delay in a distributed system are solved, and the full process tracking of Kafka messages and the improvement of system efficiency are achieved.
Patent Information
- Application Number
- CN202411716653.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-02-28
AI Technical Summary
As the scale of distributed systems expands and complexity increases, there may be problems such as message loss and duplication, message processing delay, etc., and it is necessary to improve system efficiency by tracking the flow of Kafka messages.
When creating a target message to be sent at the first end of the distributed system, a corresponding first message tracking unit is generated and tracking information is recorded, the identification information is embedded in the target message, and the identification information is extracted after receiving the message on the second end, the second message tracking unit is created to record the processing process, and finally the two information is summarized to obtain the message tracking result.
The full process tracking of Kafka messages is realized, helping to identify problems in the message delivery process and improving the work efficiency of distributed systems.
Smart Images

Figure CN119544707A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a message chasing method, apparatus, computer equipment, computer-readable storage medium and computer program product. Background Art
[0002] With the development of computer technology, distributed system technology has emerged. In a distributed system, a group of independent computers present a unified whole to users, just like a system. The system has a variety of common physical and logical resources, which can dynamically allocate tasks, and the scattered physical and logical resources can exchange information through computer networks. There is a distributed operating system in the system that manages computer resources in a global manner. For distributed systems, there are a large number of message transmission and data stream processing requirements. At this time, this requirement can generally be met through a high-throughput distributed publish-subscribe messaging system such as Kafka to realize asynchronous communication processing of distributed systems.
[0003] However, as the scale of distributed systems continues to expand and their complexity increases, there may be problems such as message loss and duplication, message processing delays, etc. Therefore, it is necessary to improve the efficiency of distributed systems by tracking the flow of Kafka messages and analyzing problems in message delivery. Summary of the invention
[0004] Based on this, it is necessary to provide a message tracking method, device, computer equipment, computer-readable storage medium and computer program product that can effectively track the Kafka message flow process in response to the above technical problems.
[0005] In a first aspect, the present application provides a message tracking method, comprising:
[0006] When a target message to be sent is created at the first end of the distributed system, a first message tracking unit corresponding to the target message is generated, and first message tracking information of the target message is recorded in the first message tracking unit;
[0007] embedding the identification information of the first message tracking unit into the target message, and pushing the target message to the second end of the distributed system;
[0008] In the case where the target message is received at the second end of the distributed system, extracting identification information from the target message;
[0009] Based on the identification information, creating a second message tracking unit as a subunit of the first message tracking unit at the second end, and recording the processing process of the target message in the second message tracking unit to obtain second message tracking information;
[0010] The first message tracing information and the second message tracing information are aggregated to obtain a message tracing result of the target message.
[0011] In one embodiment, the method further comprises:
[0012] intercepting, at a cluster node of the distributed system, a message processing event for the target message;
[0013] An event message tracking unit corresponding to the message processing event is generated, and event information of the message processing event is recorded in the event message tracking unit.
[0014] In one of the embodiments, the message processing events include message partition events, message replication events, and message replica synchronization events.
[0015] In one embodiment, the aggregating the first message tracing information and the second message tracing information to obtain the message tracing result of the target message includes:
[0016] Uploading the first message tracking information and the second message tracking information to a collector;
[0017] In the collector, classification processing is performed based on information attributes of each type of information in the first message tracing information and the second message tracing information to obtain information classification data corresponding to each of the first message tracing information and the second message tracing information;
[0018] Saving the information classification data to a tracking information database;
[0019] Data analysis and processing are performed based on the information classification data stored in the tracking information database to obtain the message tracking result of the target message.
[0020] In one embodiment, performing data analysis and processing according to the information classification data stored in the tracking information database to obtain the message tracking result of the target message includes:
[0021] Identifying the call dependency relationship of the message tracking unit corresponding to the information classification data stored in the tracking information database;
[0022] Based on the call dependency, generating a call link of the target message;
[0023] Performing page generation processing according to the call link and the information classification data to obtain a visual monitoring page of the target message;
[0024] The visual monitoring page is fed back, and a message tracking result based on the returned visual monitoring page is received.
[0025] In one embodiment, the method further comprises:
[0026] When a rule configuration request is obtained, the alarm rule configuration page is fed back;
[0027] Acquire alarm rule configuration information based on the alarm rule configuration page feedback, and generate a message tracking alarm rule;
[0028] The step of feeding back the visual monitoring page and receiving the message tracking result returned based on the visual monitoring page further includes:
[0029] Verifying the display information of the visual monitoring page based on the message tracking alarm rule to determine the alarm information in the display information;
[0030] Annotating the alarm information in the visual monitoring page to obtain an alarm annotation page;
[0031] The feeding back the visual monitoring page and receiving the message tracking result returned based on the visual monitoring page includes:
[0032] The alarm marking page is fed back, and a message tracking result returned based on the alarm marking page is received.
[0033] In a second aspect, the present application further provides a message tracking device, the device comprising:
[0034] A first unit creation module, configured to generate a first message tracking unit corresponding to a target message to be sent when creating the target message to be sent at the first end of the distributed system, and record first message tracking information of the target message in the first message tracking unit;
[0035] A message pushing module, configured to embed the identification information of the first message tracking unit into the target message, and push the target message to the second end of the distributed system;
[0036] an identification extraction module, configured to extract identification information from the target message when the target message is received at the second end of the distributed system;
[0037] A second unit creation module, configured to create, on the second end, a second message tracking unit as a subunit of the first message tracking unit based on the identification information, and record the processing process of the target message in the second message tracking unit to obtain second message tracking information;
[0038] The tracking information processing module is used to aggregate the first message tracking information and the second message tracking information to obtain the message tracking result of the target message.
[0039] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0040] When a target message to be sent is created at the first end of the distributed system, a first message tracking unit corresponding to the target message is generated, and first message tracking information of the target message is recorded in the first message tracking unit;
[0041] embedding the identification information of the first message tracking unit into the target message, and pushing the target message to the second end of the distributed system;
[0042] In the case where the target message is received at the second end of the distributed system, extracting identification information from the target message;
[0043] Based on the identification information, creating a second message tracking unit as a subunit of the first message tracking unit at the second end, and recording the processing process of the target message in the second message tracking unit to obtain second message tracking information;
[0044] The first message tracing information and the second message tracing information are aggregated to obtain a message tracing result of the target message.
[0045] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0046] When a target message to be sent is created at the first end of the distributed system, a first message tracking unit corresponding to the target message is generated, and first message tracking information of the target message is recorded in the first message tracking unit;
[0047] embedding the identification information of the first message tracking unit into the target message, and pushing the target message to the second end of the distributed system;
[0048] In the case where the target message is received at the second end of the distributed system, extracting identification information from the target message;
[0049] Based on the identification information, creating a second message tracking unit as a subunit of the first message tracking unit at the second end, and recording the processing process of the target message in the second message tracking unit to obtain second message tracking information;
[0050] The first message tracing information and the second message tracing information are aggregated to obtain a message tracing result of the target message.
[0051] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0052] When a target message to be sent is created at the first end of the distributed system, a first message tracking unit corresponding to the target message is generated, and first message tracking information of the target message is recorded in the first message tracking unit;
[0053] embedding the identification information of the first message tracking unit into the target message, and pushing the target message to the second end of the distributed system;
[0054] In the case where the target message is received at the second end of the distributed system, extracting identification information from the target message;
[0055] Based on the identification information, creating a second message tracking unit as a subunit of the first message tracking unit at the second end, and recording the processing process of the target message in the second message tracking unit to obtain second message tracking information;
[0056] The first message tracing information and the second message tracing information are aggregated to obtain a message tracing result of the target message.
[0057] The above-mentioned message tracking method, apparatus, computer device, computer-readable storage medium and computer program product generate a first message tracking unit corresponding to the target message when creating a target message to be sent at the first end of the distributed system, and record the first message tracking information of the target message in the first message tracking unit; embed the identification information of the first message tracking unit into the target message, and push the target message to the second end of the distributed system; extract the identification information in the target message when the target message is received at the second end of the distributed system; based on the identification information, create a second message tracking unit as a subunit of the first message tracking unit at the second end, and record the processing process of the target message in the second message tracking unit to obtain the second message tracking information; summarize the first message tracking information and the second message tracking information to obtain the message tracking result of the target message. The present application creates a first message tracking unit at the sending end of the target message to record the first message tracking information, and then extracts the identification information carried in the message at the receiving end to establish a second message tracking unit as a subunit of the first message tracking unit, and records the second message tracking information of the target message processing process. Finally, by summarizing the first message tracking information and the second message tracking information, the message tracking process before and after the target message is sent is completed, thereby helping the staff to determine the problems in the flow process and transmission process of the target message, so as to improve the work efficiency of the distributed system. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0059] FIG1 is an application environment diagram of a message tracking method in one embodiment;
[0060] FIG2 is a schematic diagram of a flow chart of a message tracking method in one embodiment;
[0061] FIG3 is a schematic diagram of a flow chart of an event information tracking step in one embodiment;
[0062] FIG4 is a schematic diagram of a flow chart of a tracking data aggregation and analysis step in one embodiment;
[0063] FIG5 is a flow chart of a message tracking method in another embodiment;
[0064] FIG6 is a structural block diagram of a message tracking device in one embodiment;
[0065] FIG. 7 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0066] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0067] The message tracking method provided in the embodiment of the present application can be applied to the application environment as shown in Figure 1. Among them, the terminal 102 communicates with the server 104 in the distributed system through the network, and each end in the distributed system communicates through Kafka. For example, the server 104 can communicate with the server 106 through Kafka. The data storage system can store data that the distributed system needs to process. For example, store various types of message tracking information. When the user of the terminal 102 needs to use the service provided by the distributed system, the corresponding service request can be initiated to the distributed system through the terminal. The service request first arrives at the server 104 in the distributed system. When the server 104 processes the service request, it will generate a target message that needs to be transferred to the next node server 106 in the distributed system for corresponding processing. At this time, the message tracking method of the present application can be used to track and process the target message inside the distributed system. First, when the first end server 104 of the distributed system creates a target message to be sent, a first message tracking unit corresponding to the target message is generated, and the first message tracking information of the target message is recorded in the first message tracking unit; the identification information of the first message tracking unit is embedded in the target message, and the target message is pushed to the second end server 106 of the distributed system; when the second end server 106 of the distributed system receives the target message, the identification information in the target message is extracted; based on the identification information, a second message tracking unit is created as a subunit of the first message tracking unit on the second end server 106, and the processing process of the target message is recorded in the second message tracking unit to obtain the second message tracking information; the first message tracking information and the second message tracking information are summarized to obtain the message tracking result of the target message. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices, and the Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car devices, projection devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The head mounted device may be a virtual reality (VR) device, an augmented reality (AR) device, smart glasses, etc. The server 104 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.
[0068] In an exemplary embodiment, as shown in FIG2 , a message tracing method is provided, which is described by taking the method applied to the distributed system in FIG1 as an example, and includes the following steps 201 to 209. Among them:
[0069] Step 201: When a target message to be sent is created at a first end of a distributed system, a first message tracking unit corresponding to the target message is generated, and first message tracking information of the target message is recorded in the first message tracking unit.
[0070] Among them, a distributed system is a system in which hardware or software components are distributed on different network computers and communicate and coordinate with each other through message passing. The present application is specifically used to implement message tracking for a distributed system. In one embodiment, the distributed system can be specifically a microservice system. The microservice system is a software architecture design pattern that decomposes the application into small, autonomous service units that can be independently deployed, expanded and maintained, and each service is an independent microservice. The main purpose of the microservice system is to improve the modularity of the application so that development, deployment and expansion can be more independent and flexible. The various components of the distributed system are distributed on different network computers, and there are communication needs between these network computers. For example, when the server 104 in Figure 1 needs to send a message to the server 106, the server 104 can be used as the first end of the distributed system in the present application. The target message is the message that needs to be sent from the server 104 to 106, and the present application is used to track and process the target message. The first message tracking unit is used to record the relevant information of the message, such as the message target service, the address of the message middleware, the operation of the message, the subject of the message, etc. can all be used as the first message tracking information recorded in the first message tracking unit.
[0071] For example, in a distributed system, as the scale of the system continues to expand and the complexity increases, there may be problems such as message loss and duplication, message processing delay, etc. At this time, in order to analyze the specific message transmission performance of the distributed system, the message tracking method of the present application can be used to track the message-related information in each node of the message transmission process during the message transmission process, thereby realizing data analysis and processing of the message transmission process of the distributed system, and providing a data basis for system optimization. The message tracking can be started in the message generation process. When one end of the distributed system creates a target message that needs to be sent to the other end, the present application can generate a first message tracking unit corresponding to the target message at the first end, and record the first message tracking information of the target message in the first message tracking unit, so as to record these information in the message generation stage through the first message tracking unit. In one embodiment, the distributed system in the present application communicates based on the Kafka system. Kafka is a high-throughput distributed publish-subscribe message system. In modern distributed systems, Kafka is widely used in message transmission and data stream processing scenarios. Message tracing is implemented based on Jaeger, and the message tracing unit Span is created based on Jaeger. Jaeger is a distributed tracing system based on the opentracing protocol, which can comprehensively trace and visualize requests in distributed systems. It is the basic tracing unit in the distributed tracing system, representing an operation in the application processing process. Each Span has a start time and an end time, and records other metadata, such as the node to which the span belongs, the parent-child relationship of the span, error information, and the label of the span. In a trace path, there can be a parent-child relationship between spans, indicating the nested relationship of the call link, which can be used to trace the path of the request in the distributed system, monitor the system status, and analyze performance indicators. When the message is created and needs to be sent, a corresponding Span is created for each message. At this time, the information to be tracked can be added to the attributes of the Span, such as the target service, Kafka address, message operation, message topic, etc.
[0072] Step 203: embed the identification information of the first message tracking unit into the target message, and push the target message to the second end of the distributed system.
[0073] The identification information refers to information used to mark the identity of the first message tracking unit, and may specifically include the identity ID of the first message tracking unit, ie, SpanID, and its path ID, ie, TraceID.
[0074] For example, in order to subsequently identify the message tracking unit corresponding to the target message, the relevant information of the first message tracking unit can be embedded into the metadata of the message before sending the message, and the data sending process can be performed after the embedding is completed. In addition, if the message fails to be sent, the corresponding failure information will also be entered into the first message tracking unit as the basic data for subsequent analysis.
[0075] Step 205: When the second end of the distributed system receives the target message, extract the identification information in the target message.
[0076] Step 207: Based on the identification information, a second message tracking unit is created at the second end as a subunit of the first message tracking unit, and the processing process of the target message is recorded in the second message tracking unit to obtain second message tracking information.
[0077] The second message tracking unit is created as a subunit of the first message tracking unit, and both record various tracking information involved in the message sending process and the message receiving and processing process. The second message tracking unit records various tracking information during the receiving and processing process of the target message.
[0078] Exemplarily, after the target message is sent at the first end, the message will flow through the distributed system and enter the second end of the distributed system, and the solution of the present application can create a second message tracking unit at the second end to record the processing process of the target message. For the specific processing process, when the second end of the distributed system receives the target message, the identification information of the message tracking unit stored can be first extracted from the metadata of the target message, and then based on the identification information, a second message tracking unit as a subunit of the first message tracking unit is created at the second end, and the second message tracking information of the processing process of the target message is recorded. Thereby, an association is established between the tracking information of the target message in the sending process and the tracking information of the receiving process. In addition, if the message reception fails, a corresponding second message tracking unit will also be established, and the corresponding error information will be added to the second message tracking unit.
[0079] Step 209: Summarize the first message tracing information and the second message tracing information to obtain a message tracing result of the target message.
[0080] Exemplarily, after recording the first message tracking information of the target message sending process in the first message tracking unit and recording the second message tracking information of the target message receiving process and processing process in the second message tracking unit, the message tracking result for the target message can be obtained by summarizing the first message tracking information and the second message tracking information. In addition, in a specific embodiment, each type of tracking information can be classified and processed, and then different types of data can be analyzed separately. In another embodiment, various message processing events from message sending to message receiving process can also be recorded. Thereby obtaining more detailed tracking information.
[0081] The message tracking method described above generates a first message tracking unit corresponding to the target message when a target message to be sent is created at the first end of the distributed system, and records the first message tracking information of the target message in the first message tracking unit; embeds the identification information of the first message tracking unit into the target message, and pushes the target message to the second end of the distributed system; extracts the identification information in the target message when the target message is received at the second end of the distributed system; based on the identification information, creates a second message tracking unit as a subunit of the first message tracking unit at the second end, and records the processing process of the target message in the second message tracking unit to obtain the second message tracking information; summarizes the first message tracking information and the second message tracking information to obtain the message tracking result of the target message. The present application records the first message tracking information by creating a first message tracking unit at the sending end of the target message, and then extracts the identification information carried in the message at the receiving end to establish a second message tracking unit as a subunit of the first message tracking unit, and records the second message tracking information of the processing process of the target message. Finally, by summarizing the first message tracking information and the second message tracking information, the message tracking processing before and after the target message is sent is completed, thereby helping the staff to determine the problems existing in the flow process and transmission process of the target message, so as to improve the work efficiency of the distributed system.
[0082] In an exemplary embodiment, as shown in FIG3 , the method of the present application further includes:
[0083] Step 302: intercepting a message processing event for a target message at a cluster node of the distributed system.
[0084] Step 304: Generate an event message tracking unit corresponding to the message processing event, and record event information of the message processing event in the event message tracking unit.
[0085] Among them, the cluster nodes of the distributed system refer to the nodes involved in the target message transmission process. For example, for a distributed system that implements message transmission through Kafka, its cluster nodes are Broker nodes. Various message processing events such as message partition events, message replication events, and message replica synchronization events will be triggered on the Broker nodes.
[0086] Exemplarily, the present application can also record various types of message processing events triggered for the target message during the message delivery process through a custom message interceptor. After the message enters the cluster node, if a message processing event for the target message is monitored, such as a message partition event, a message replication event, and a message replica synchronization event, the message interceptor will automatically intercept these events, generate a corresponding event message tracking unit, and add the information that needs to be tracked, such as the delay and status of each stage, to the attributes of the event message tracking unit. For example, in one of the embodiments, the present application implements message delivery through Kafka. When the target message enters the Kafka Broker, its partition is first determined, and an event message tracking unit Span is generated before and after the partition operation, and partition-related information and performance indicators such as the time consumed during partitioning are reported. When the message is copied to other Broker nodes, an event message tracking unit Span can be generated during the copy, and performance indicators such as the copy time consumed from the Leader Broker to the Follower Broker can be recorded. In this embodiment, by intercepting various types of message processing events triggered by the target message transmission process and establishing a corresponding event message tracking unit, the message processing process of the cluster node is tracked, thereby effectively completing the comprehensive tracking of the message processing process and ensuring the comprehensiveness of the tracking information.
[0087] In an exemplary embodiment, as shown in FIG. 4 , step 209 includes:
[0088] Step 401: Upload the first message tracking information and the second message tracking information to a collector.
[0089] Step 403: In the collector, classification processing is performed based on information attributes of each type of information in the first message tracing information and the second message tracing information to obtain information classification data corresponding to each of the first message tracing information and the second message tracing information.
[0090] Step 405, save the information classification data to the tracking information database.
[0091] Step 407, performing data analysis and processing based on the information classification data stored in the tracking information database to obtain the message tracking result of the target message.
[0092] Exemplarily, the present application can specifically complete the data collection and processing of the message tracking process through the collector Collector. The first message tracking unit on the first end records the first message tracking information, and the first message tracking information and the first message tracking unit can be uploaded to the collector. Similarly, after the second message tracking unit at the second end records the second message tracking information, the recorded data will also be uploaded to the collector. Similarly, for the event message tracking unit in the above embodiment, the event information recorded by it will also be uploaded to the collector for analysis and processing. In the collector, classification processing will be performed based on the information attributes of each type of information in the first message tracking information and the second message tracking information, so that the various types of information obtained by tracking are sorted according to the information type, and the information classification data corresponding to each of the first message tracking information and the second message tracking information is obtained; and the information classification data is saved to the tracking information database; finally, data analysis and processing are performed based on the information classification data saved in the tracking information database to obtain the message tracking result of the target message. In this embodiment, the tracking information collected by the collector is sorted and classified and stored in a database, and then analyzed based on the classified data of various types of information stored in the database, which can effectively ensure the accuracy of the tracking data analysis, thereby ensuring the improvement of the working efficiency of the distributed system.
[0093] In an exemplary embodiment, step 407 includes: identifying the call dependency relationship of the message tracking unit corresponding to the information classification data stored in the tracking information database; generating a call link of the target message based on the call dependency relationship; performing page generation processing according to the call link and the information classification data to obtain a visual monitoring page of the target message; feeding back the visual monitoring page, and receiving the message tracking results returned based on the visual monitoring page.
[0094] Exemplarily, the present application can specifically display the message tracking data in a visual way, so as to display more intuitive message tracking data and ensure the effect of analyzing the tracking data. Since the second message tracking unit is established as a child node of the first message tracking unit in the message transmission process, there is a call dependency relationship between them. In addition, for the message processing event, the event message tracking unit established by it will also have a dependency relationship with the first message tracking unit of the target message. Therefore, based on these call dependencies, the call link of the message transmission process can be generated. Then, on the basis of the call link, the page generation process is performed to obtain a visual monitoring page, so as to display the call dependency relationship in the message transmission process and the key information such as the call time, call source, and call target of the upstream and downstream services. If a call chain involves multiple services, the services involved will be displayed. Finally, the generated visual monitoring page is fed back to the analysis staff, and then the message tracking result returned by the staff based on the visual monitoring page is received, and the analysis and processing process of the message tracking information is completed. In this embodiment, the call link is generated based on the call dependency relationship, and then the visual page is generated and processed on the basis of the call link. The data analysis is effectively realized through the generated visual page, which can effectively ensure the efficiency and accuracy of the data analysis.
[0095] Further, the method also includes: in the case of obtaining a rule configuration request, feeding back an alarm rule configuration page; obtaining alarm rule configuration information based on the alarm rule configuration page feedback, and generating a message tracking alarm rule. Feedback to the visual monitoring page, before receiving the message tracking result returned based on the visual monitoring page, also includes: verifying the display information of the visual monitoring page based on the message tracking alarm rule, determining the alarm information in the display information, and marking the alarm information in the visual monitoring page to obtain an alarm marking page. Feedback to the visual monitoring page, receiving the message tracking result returned based on the visual monitoring page includes: feeding back the alarm marking page, and receiving the message tracking result returned based on the alarm marking page. That is, the scheme of the present application can also provide alarm configuration processing for message tracking information. Before performing data analysis, the alarm rule configuration page is fed back according to the user's rule configuration request, and then the various alarm rules in the message tracking process are generated through the information filled in by the user on the alarm rule configuration page. At the same time, for the generated visual monitoring page, the display information of the visual monitoring page can be verified based on the message tracking alarm rule to determine the alarm information in the display information. Then, these alarm messages are annotated to indicate abnormalities on the visualization page. Finally, the alarm annotation page is fed back, and the message tracking results returned based on the alarm annotation page are received. In this embodiment, by presetting alarm rules and annotating the generated visualization monitoring page accordingly according to the alarm rules, it can help staff to promptly discover and solve problems such as delays, message loss or consumption failures, and ensure the efficiency and accuracy of the analysis of message tracking information.
[0096] In one embodiment, the distributed system of the present application is a microservice system, which implements communication through Kafka and creates Span as a message tracking unit based on Jaeger. The specific process of the present application can be shown in Figure 5, which specifically includes:
[0097] Step 1: Integrate JaegerSDK
[0098] Integrate Jaeger's SDK into the code of Kafka producers and consumers, that is, upstream and downstream services in the microservice architecture system. Ensure that upstream and downstream services can generate and manage Jaeger's tracing units (Span) to track the sending and receiving process of messages.
[0099] Step 2: Kafka upstream service implements transmission of tracking information
[0100] Create a Span at the message sending end of the Kafka upstream service and report it. When sending a message, create a corresponding Span for each message. At this time, you can add the information you need to track to the attributes of the Span, such as the target service, Kafka address, message operation, message topic, etc., and then embed the relevant information of the Span into the metadata of the message, for example, pass the TraceID and SpanID as the header information of the message and report it to the Collector. If the message fails to be sent, the corresponding error information will be added to the Span.
[0101] Step 3: Customize KafkaProducer's interceptor
[0102] After the message enters the Broker node of Kafka, when the partition, replication, and replica synchronization events are triggered, these events are intercepted, the corresponding span is generated, and the information that needs to be tracked, such as the delay and status of each stage, is added to the attributes of the span. For example, when the message enters the Kafka Broker, its partition is first determined, and spans are generated before and after the partition operation, and partition-related information and performance indicators such as the time consumed during partitioning are reported. When the message is copied to other Broker nodes, spans can be generated during the copying process to record performance indicators such as the copying time consumed from the Leader Broker to the Follower Broker.
[0103] Step 4: The Kafka downstream service receives upstream tracking information and implements the call dependency relationship during message delivery
[0104] Create a span at the message receiving end of the Kafka downstream service. When receiving a message, extract the tracking information delivered by the upstream service from the message header information, use the extracted information to create a corresponding child span to identify the call dependency, record the message processing process, and then report it to the Collector. If the message fails to be received, the corresponding error information will be added to the span.
[0105] Step 5: Data reporting and processing
[0106] The spans generated by Kafka upstream and downstream services are reported to the configured Collector in real time. After the Collector collects the reported span information, it will classify the span information according to the attributes and store it in the database of the application performance monitoring system.
[0107] Step 6: Visualize Tracking Information
[0108] The visual monitoring page provided by the application performance monitoring system is used to display the call dependencies in the message transmission process and key information such as the call duration, call source, and call target of upstream and downstream services. If a call chain involves multiple services, all the services involved will be displayed.
[0109] The present application provides a Kafka call tracing method based on Jaeger, which creates corresponding spans in the upstream and downstream services during the Kafka message transmission process, embeds tracing information in the message header of the upstream service, intercepts these events when the message enters the Broker, partitions, replicates, and synchronizes the replica, generates corresponding spans according to the information in the message header, reports the delay, status, and other key information of each stage, and the downstream service takes out the information transmitted by the upstream after receiving the message, and creates a sub-span accordingly, so as to connect the upstream and downstream calls of the message in series, and can track the message processing process of the Broker node inside Kafka, connect the tracing information to the distributed tracing system, provide a visual page to display the tracing information, and view the link, delay, error information and other key information in the message transmission and processing process, so as to realize the comprehensive tracking of the message flow process, and provide a visual alarm configuration page, support the configuration of custom alarm rules, and can timely discover and solve problems such as delays, lost messages or consumption failures.
[0110] This application has good scalability and applicability, and can help developers and operation and maintenance personnel to more effectively monitor and optimize the message delivery process in distributed systems.
[0111] This application solves the problem that the Jaeger tracing method does not support tracing message queues (such as Apache Kafka). It can effectively trace the delivery process of Kafka messages, especially the message processing process of Broker nodes inside Kafka, monitor and analyze the problems and performance bottlenecks in message delivery in real time, and provide a visual monitoring page, support the configuration of related alarms, improve the observability and maintainability of Kafka message processing in distributed systems, reduce operation and maintenance costs and time costs, and improve operation and maintenance efficiency.
[0112] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0113] Based on the same inventive concept, the embodiment of the present application also provides a message tracking device for implementing the message tracking method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more message tracking device embodiments provided below can refer to the limitations on the message tracking method above, and will not be repeated here.
[0114] In an exemplary embodiment, as shown in FIG6 , a message tracking device is provided, including: an M module, an N module and an L module, wherein:
[0115] The first unit creation module 601 is used to generate a first message tracking unit corresponding to the target message when creating a target message to be sent at the first end of the distributed system, and record the first message tracking information of the target message in the first message tracking unit.
[0116] The message pushing module 603 is used to embed the identification information of the first message tracking unit into the target message, and push the target message to the second end of the distributed system.
[0117] The identification extraction module 605 is used to extract identification information in the target message when the second end of the distributed system receives the target message.
[0118] A second unit creation module 607, configured to create, at the second end, a second message tracking unit as a subunit of the first message tracking unit based on the identification information, and record the processing process of the target message in the second message tracking unit to obtain second message tracking information;
[0119] The tracking information processing module 609 is used to aggregate the first message tracking information and the second message tracking information to obtain a message tracking result of the target message.
[0120] In one embodiment, an event tracking module is also included, which is used to: intercept message processing events for target messages in cluster nodes of the distributed system; generate an event message tracking unit corresponding to the message processing event, and record event information of the message processing event in the event message tracking unit.
[0121] In one embodiment, the message processing events include message partition events, message replication events, and message replica synchronization events.
[0122] In one embodiment, the tracking information processing module 609 is specifically used to: upload the first message tracking information and the second message tracking information to a collector; in the collector, perform classification processing based on the information attributes of each type of information in the first message tracking information and the second message tracking information to obtain information classification data corresponding to each of the first message tracking information and the second message tracking information; save the information classification data to a tracking information database; perform data analysis processing based on the information classification data saved in the tracking information database to obtain a message tracking result for the target message.
[0123] In one embodiment, the tracking information processing module 609 is also used to: identify the call dependency relationship of the message tracking unit corresponding to the information classification data stored in the tracking information database; generate a call link of the target message based on the call dependency relationship; perform page generation processing according to the call link and the information classification data to obtain a visual monitoring page of the target message; feedback the visual monitoring page, and receive the message tracking results returned based on the visual monitoring page.
[0124] In one embodiment, it also includes a rule configuration module, which is used to: feedback the alarm rule configuration page when the rule configuration request is obtained; obtain the alarm rule configuration information based on the alarm rule configuration page feedback, and generate the message tracking alarm rule. The tracking information processing module 609 is also used to: verify the display information of the visual monitoring page based on the message tracking alarm rule, determine the alarm information in the display information; mark the alarm information in the visual monitoring page to obtain the alarm marking page; feedback the alarm marking page, and receive the message tracking result returned based on the alarm marking page.
[0125] Each module in the above message tracking device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0126] In an exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG7. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data related to the message tracking process. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a message tracking method is implemented.
[0127] Those skilled in the art will understand that the structure shown in FIG. 7 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0128] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0129] In one embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0130] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in the above-mentioned method embodiments.
[0131] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0132] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0133] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0134] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A message tracking method, characterized in that: The method comprises: When a target message to be sent is created at the first end of the distributed system, a first message tracking unit corresponding to the target message is generated, and first message tracking information of the target message is recorded in the first message tracking unit; embedding the identification information of the first message tracking unit into the target message, and pushing the target message to the second end of the distributed system; In the case where the target message is received at the second end of the distributed system, extracting identification information from the target message; Based on the identification information, creating a second message tracking unit as a subunit of the first message tracking unit at the second end, and recording the processing process of the target message in the second message tracking unit to obtain second message tracking information; The first message tracing information and the second message tracing information are aggregated to obtain a message tracing result of the target message.
2. The method according to claim 1, characterized in that The method further comprises: intercepting, at a cluster node of the distributed system, a message processing event for the target message; An event message tracking unit corresponding to the message processing event is generated, and event information of the message processing event is recorded in the event message tracking unit.
3. The method according to claim 2, characterized in that The message processing events include message partition events, message replication events, and message replica synchronization events.
4. The method according to claim 1, characterized in that The aggregating the first message tracing information and the second message tracing information to obtain the message tracing result of the target message includes: Uploading the first message tracking information and the second message tracking information to a collector; In the collector, classification processing is performed based on information attributes of each type of information in the first message tracing information and the second message tracing information to obtain information classification data corresponding to each of the first message tracing information and the second message tracing information; Saving the information classification data to a tracking information database; Data analysis and processing are performed based on the information classification data stored in the tracking information database to obtain the message tracking result of the target message.
5. The method according to claim 4, characterized in that The performing of data analysis and processing according to the information classification data stored in the tracking information database to obtain the message tracking result of the target message includes: Identifying the call dependency relationship of the message tracking unit corresponding to the information classification data stored in the tracking information database; Based on the call dependency, generating a call link of the target message; Performing page generation processing according to the call link and the information classification data to obtain a visual monitoring page of the target message; The visual monitoring page is fed back, and a message tracking result based on the returned visual monitoring page is received.
6. The method according to claim 5, characterized in that The method further comprises: When a rule configuration request is obtained, the alarm rule configuration page is fed back; Acquire alarm rule configuration information based on the alarm rule configuration page feedback, and generate a message tracking alarm rule; The step of feeding back the visual monitoring page and receiving the message tracking result returned based on the visual monitoring page further includes: Verifying the display information of the visual monitoring page based on the message tracking alarm rule to determine the alarm information in the display information; Annotating the alarm information in the visual monitoring page to obtain an alarm annotation page; The feeding back the visual monitoring page and receiving the message tracking result returned based on the visual monitoring page includes: The alarm marking page is fed back, and a message tracking result returned based on the alarm marking page is received.
7. A message tracking device, characterized in that: The device comprises: A first unit creation module, configured to generate a first message tracking unit corresponding to a target message to be sent when creating the target message to be sent at the first end of the distributed system, and record first message tracking information of the target message in the first message tracking unit; A message pushing module, configured to embed the identification information of the first message tracking unit into the target message, and push the target message to the second end of the distributed system; an identification extraction module, configured to extract identification information from the target message when the target message is received at the second end of the distributed system; A second unit creation module, configured to create, on the second end, a second message tracking unit as a subunit of the first message tracking unit based on the identification information, and record the processing process of the target message in the second message tracking unit to obtain second message tracking information; The tracking information processing module is used to aggregate the first message tracking information and the second message tracking information to obtain the message tracking result of the target message.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Distributed tracking system
CN105224445A
Distributed call tracking method, service system, monitoring system and storage medium
CN108462750A
Information analysis method based on cloud computing and big data and digital financial service platform
CN112671885A
Distributed service full-link monitoring method and device, electronic equipment and storage medium
CN113987074A
Monitoring method based on service grid and related equipment
CN114785690A
Cited By
Transmission path fault positioning method, system and device and storage medium
CN119945892A