Resource call chain log recording method and device under micro-service architecture

By generating request identifiers for each service request under the microservice architecture, recording and processing resource call chain logs of each microservice module, the problem of difficult log files is solved, and efficient log file management and system performance optimization is achieved.

CN120407326AActive Publication Date: 2025-08-01CAIXUETANG EDUCATION CULTURE MEDIA CHENGDU CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202510486779.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-18
Publication Date
2025-08-01
Estimated Expiration
2045-04-18

AI Technical Summary

Technical Problem

Log files are difficult to manage under the microservice architecture, resulting in low management efficiency.

Method used

By generating a request identifier for each service request, recording the task attributes of each resource in each microservice module, generating resource call chain logs, and performing structured processing and storage.

Benefits of technology

It realizes fine-grained end-to-end call chain tracking, improves log file management efficiency, and improves the system's debuggability and fault location efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120407326A_ABST
    Figure CN120407326A_ABST
Patent Text Reader

Abstract

The invention discloses a resource call chain log recording method and device under a micro-service architecture, and relates to the technical field of micro-services, the method comprises the following steps: receiving a service request, and generating a request identifier according to the service request; obtaining a task attribute of each resource in each micro-service module according to the request identifier; wherein the task attribute of each resource in each micro-service module is defined and recorded by a resource call chain log model; performing structured processing on the task attribute of each resource in each micro-service module to obtain a resource call chain log; and recording and storing the resource call chain log. According to the invention, end-to-end call chain tracking of fine granularity can be realized, logs of each micro-service module in the micro-service system can be associated and called, the management efficiency of log files is improved, and the debuggeability of the system, the efficiency of fault positioning and the efficiency of system performance optimization are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of microservices, and in particular to a method and device for resource call chain logging under a microservice architecture. Background Art

[0002] With the rapid development of network service complexity and globalization, the deployment and monitoring methods of existing software systems have encountered challenges. The continuous development of microservice research represented by containers (Docker) has replaced traditional resource virtualization and become a new trend.

[0003] The microservice architecture is a method of developing a single application as a set of small services. In a microservice system built based on the microservice architecture style, for an application request, it is split into different application functions, and corresponding microservices are built, and then these microservices are distributed to different servers. Each microservice is implemented through its own application process and communicates through lightweight mechanisms.

[0004] The microservice architecture has advantages such as independent deployment, flexible expansion, and effective resource isolation. However, at the same time, the microservice architecture also has disadvantages. For example: Since each microservice is distributed on different servers, a large number of log files will be generated during the response process of each microservice, and these log files are also distributed on different servers, which makes it difficult to manage the log files in the microservice system, unable to associate the resource calls within the microservice, and resulting in low management efficiency of the log files.

[0005] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:

[0006] The log files in the microservice system are difficult to manage, resulting in low management efficiency of the log files. Summary of the Invention

[0007] The purpose of the present invention is to provide a method and device for resource call chain logging under a microservice architecture to solve the technical problem that the log files in the microservice system are difficult to manage, resulting in low management efficiency of the log files in the prior art.

[0008] The many technical effects that can be produced by the preferred technical solutions provided by the present invention are described in detail below.

[0009] To achieve the above object, the present invention provides the following technical solutions:

[0010] In a first aspect, the present invention provides a method for resource call chain logging under a microservice architecture, including:

[0011] Receiving a service request, and generating a request identifier according to the service request;

[0012] Obtain the task attributes of each resource in each microservice module according to the request identifier; wherein, the task attributes of each resource in each microservice module are defined and recorded by the resource call chain log model;

[0013] Perform structured processing on the task attributes of each resource in each microservice module to obtain the resource call chain log;

[0014] Record and store the resource call chain log.

[0015] Optionally, the task attributes of each resource in each microservice module are defined and recorded by the resource call chain log model. The method for generating the resource call chain log model in the microservice module includes:

[0016] Establish a standard resource type enumeration according to the database, cache, and message queue;

[0017] Perform parameterized desensitization processing on the SQL statements in the database, and record the method and path of the call request to obtain the standardized operation instructions;

[0018] Unify the status codes to obtain a status code system;

[0019] Use a high-precision timer to record the start and end times of the operation, and calculate the time difference to obtain a time-consuming calculation rule;

[0020] Fuse the standard resource type enumeration, operation instructions, status code system, and time-consuming calculation rule to obtain the resource call chain log model in the microservice module.

[0021] Optionally, the receiving of the service request and generating the request identifier according to the service request includes:

[0022] Receive the service request sent by the user;

[0023] Generate a request identifier for the service request through a hash algorithm; wherein, each different service request will generate a different and unique request identifier, and the request identifier will be injected into the request context and transmitted along the call link.

[0024] Optionally, the generating of the request identifier for the service request through the hash algorithm includes:

[0025] Extract the request parameters in the service request;

[0026] Convert the request parameters into a json string;

[0027] Concatenate the current timestamp in the json string;

[0028] Perform MD5 processing on the JSON string concatenated with the current timestamp to obtain a unique request identifier.

[0029] Optionally, in obtaining the task attributes of each resource in each microservice module, the task attributes include the resource type of the resource operation, the operation command, the operation status, and the operation time consumption.

[0030] Optionally, the resource type is classified and counted through the Link field, and a performance bottleneck analysis report can be generated according to the resource type.

[0031] Optionally, after recording and storing the resource call chain log, it further includes:

[0032] Deliver the resource call chain log to the Alibaba Cloud Log Service for log display and / or old log archiving.

[0033] In a second aspect, the present invention further provides a resource call chain log recording and processing device under a microservice architecture, including:

[0034] A generation module that receives a service request and generates a request identifier according to the service request;

[0035] An acquisition module that acquires the task attributes of each resource in each microservice module according to the request identifier; wherein, the task attributes of each resource in each microservice module are defined and recorded by a resource call chain log model;

[0036] A processing module that structurally processes the task attributes of each resource in each microservice module to obtain a resource call chain log;

[0037] A recording module that records and stores the resource call chain log.

[0038] In a third aspect, the present invention further provides a terminal device, including:

[0039] One or more processors and a memory;

[0040] Wherein, the memory is used to store one or more computer programs, and the one or more processors are used to execute the one or more computer programs stored in the memory, so that the processors execute the steps of the resource call chain log recording method under the microservice architecture.

[0041] In a fourth aspect, the present invention further provides a computer-readable storage medium, on which a computer program is stored, characterized in that when the program is executed by a processor, it implements the steps of the resource call chain log recording method under the microservice architecture.

[0042] Implementing one of the above technical solutions of the present invention has the following advantages or beneficial effects:

[0043] The method recorded in the present invention generates a request identifier for each service request, records the task attributes of each resource inside the microservice module, and finally processes the task attributes to obtain the resource call chain log, so as to achieve fine-grained end-to-end call chain tracing, which can associate and call the logs of each microservice module in the microservice system, improve the management efficiency of log files, and improve the system's debuggability, the efficiency of fault location, and the efficiency of system performance optimization. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following described drawings are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings. In the drawings:

[0045] Figure 1 is a schematic diagram of the work flow of Embodiment 1 of the present invention;

[0046] Figure 2 is a schematic diagram of the work flow of Embodiment 2 of the present invention;

[0047] Figure 3 is a schematic diagram of the structure of Embodiment 3 of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0048] In order to make the objectives, technical solutions and advantages of the present invention clearer and more understandable, the various exemplary embodiments to be described below will refer to the corresponding drawings, which form a part of the exemplary embodiments and describe various exemplary embodiments that may be adopted to implement the present invention. Unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. It should be understood that they are only examples of processes, methods, and devices, etc., that are consistent with some aspects of the present invention disclosed in detail in the appended claims. Other embodiments may also be used, or structural and functional modifications may be made to the embodiments listed herein without departing from the scope and essence of the present invention.

[0049] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "transverse", etc. indicate the orientation or positional relationship based on the orientation shown in the drawings. They are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the indicated elements must have a specific orientation, be constructed and operated in a specific orientation. The terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. The meaning of the term "plurality" is two or more. The terms "connected" and "coupled" should be understood in a broad sense. For example, they can be fixedly connected, detachably connected, integrally connected, mechanically connected, electrically connected, communicatively connected, directly connected, indirectly connected through an intermediate medium, and can be the communication inside two elements or the interaction relationship between two elements. The term "and / or" includes any and all combinations of one or more of the related listed items. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0050] In order to illustrate the technical solutions described in the present invention, the following will be described by specific embodiments, and only the parts related to the embodiments of the present invention are shown.

[0051] Embodiment 1:

[0052] As Figure 1 shown, the present invention provides a method for recording resource call chain logs under a microservice architecture, including:

[0053] S10. Receive a service request and generate a request identifier according to the service request;

[0054] S20. Obtain the task attributes of each resource in each microservice module according to the request identifier; wherein, the task attributes of each resource in each microservice module are defined and recorded by a resource call chain log model;

[0055] S30. Perform structured processing on the task attributes of each resource in each microservice module to obtain a resource call chain log;

[0056] S40. Record and store the resource call chain log.

[0057] The resource call chain logging method under the microservice architecture provided by this embodiment includes receiving a service request and generating a request identifier according to the service request; then obtaining the task attributes of each resource in each microservice module according to the request identifier; subsequently, structuring the task attributes of each resource in each microservice module to obtain the resource call chain log; and finally, recording and storing the resource call chain log. The method described in this embodiment generates a request identifier for each service request, records the task attributes of each resource inside the microservice module, and finally processes the task attributes to obtain the resource call chain log, so as to achieve fine-grained end-to-end call chain tracing, and can associate and call the logs of each microservice module in the microservice system, improving the management efficiency of log files.

[0058] Next, Figure 1 the resource call chain logging method under the microservice architecture described in this embodiment will be elaborated in detail.

[0059] First, execute step S10 to receive a service request and generate a request identifier according to the service request. Specifically, the main process is as follows: receive the service request sent by the user; generate the service request into a request identifier through a hash algorithm; among them, each different service request will generate a different and unique request identifier, and the request identifier will be injected into the request context and transmitted along the call link.

[0060] Furthermore, the microservice system will first receive the service request sent by the user. After receiving the service request, the microservice system will generate a globally unique request identifier through a hash algorithm according to the difference of the service request. Specifically, the request identifier will be injected into the request context and transmitted throughout the system along the call link. This approach can ensure that in a complex microservice architecture, each service component can access this unique identifier, thereby realizing the whole-process tracking and monitoring of the service request, enabling the system to effectively manage and coordinate the interaction between each microservice component, and ensuring the correct processing and response of the request. At the same time, the existence of the request identifier also improves the debuggability of the system and the efficiency of fault location. The staff can quickly trace the link and cause of the problem through the request identifier.

[0061] Furthermore, generating the service request into a request identifier through a hash algorithm includes: extracting the request parameters in the service request; converting the request parameters into a json string; splicing the current timestamp in the json string; and performing md5 processing on the json string spliced with the current timestamp to obtain a unique request identifier.

[0062] First, extract all relevant request parameters from the service request. The request parameters include, but are not limited to, key information such as user ID, operation type, data range, etc. Next, convert these request parameters into a structured json string, and the format of the json string can ensure the clarity and easy processing of the data. After generating the json string, the current timestamp is concatenated into it. Specifically, the timestamp records the specific moment when the request is generated, which can further ensure the uniqueness of each request identifier. Even if the parameters of two requests are exactly the same, due to the different timestamps, the generated request identifiers will also be different. Finally, perform md5 processing on the json string concatenated with the current timestamp. It should be noted that md5 is a widely used hash algorithm, which can convert data of any length into a hash value of a fixed length. After performing md5 processing on the json string concatenated with the current timestamp, a unique request identifier is obtained. The request identifier can be used in subsequent scenarios such as log recording, request tracking, and data verification to ensure the efficient operation of the microservice system and the accuracy of the data.

[0063] In this embodiment, the request identifier generated by the hash algorithm actually refers to the message ID used to uniquely identify each request in a remote procedure call (RPC), which is rpc_msg_id in this embodiment. The request identifier generated by the hash algorithm ensures that each request has a unique identifier, thereby effectively tracking and managing related requests in the system. The use of the hash algorithm not only improves the uniqueness of the identifier but also enhances the security and reliability of the system. It should be noted that the rpc_msg_id in this embodiment is convenient for searching and troubleshooting, but in the actual troubleshooting process, other information needs to be combined for troubleshooting, such as the specific interface of the service request.

[0064] Then, execute step S20 to obtain the task attributes of each resource in each microservice module according to the request identifier; among them, the task attributes of each resource in each microservice module are defined and recorded by the resource call chain log model.

[0065] Specifically, the request identifier generated by the hash algorithm can effectively track and manage related requests in the microservice system. At the same time, due to the uniqueness and immutability of the request identifier, it can quickly locate and identify related requests in a complex microservice system. Therefore, the microservice system can easily obtain the task attributes of each resource in each microservice module according to the request identifier.

[0066] By using the request identifier generated by the hash algorithm, we can effectively track and manage related requests in the microservice system. This request identifier is unique and immutable, enabling quick location and identification of each request in a complex microservice architecture. Therefore, in the microservice system, through these request identifiers, we can easily obtain the task attributes of each resource in each microservice module.

[0067] Furthermore, the task attributes of each resource in each microservice module are defined and recorded by the resource call chain log model. The method for generating the resource call chain log model in the microservice module includes: establishing a standard resource type enumeration based on the database, cache, and message queue; performing parameterized desensitization on the SQL statements in the database and recording the method and path of the call request to obtain the standardized operation instructions; unifying the status codes to form a status code system; using a high-precision timer to record the start and end times of the operation and calculating the time difference to obtain the time-consuming calculation rule; and fusing the standard resource type enumeration, operation instructions, status code system, and time-consuming calculation rule to obtain the resource call chain log model in the microservice module.

[0068] In this embodiment, the task attributes of each resource in each microservice module are defined and recorded by the resource call chain log model. Generating the resource call chain log model in the microservice module includes the following steps.

[0069] First, it is necessary to establish a standard resource type enumeration according to the specific situations of the database (MySQL), cache (Redis), and message queue (RabbitMQ). The standard resource type enumeration is used to unify the types of different resources, ensuring accurate identification and classification when recording logs.

[0070] Next, it is necessary to perform parameterized desensitization on the SQL statements in the database (e.g., SELECT * FROM table WHERE id =?) to protect data security. At the same time, it is also necessary to record the method and path of each call request (e.g., POST / api / v1 / payment) to obtain the standardized operation instructions after processing. The standardized operation instructions after processing will provide a clear operation record for subsequent analysis and processing. It should be noted that the call requests recorded in this embodiment include HTTP requests and RPC requests.

[0071] Subsequently, it is also necessary to unify the status codes to form a complete and consistent status code system. This status code system can accurately record the status of each operation in the log, such as: 200 (success), 500 (exception), 404 (resource not found), etc. In this way, it is possible to better track and monitor the usage of resources.

[0072] In addition, a high-precision timer (PHP) is required to record the start and end times of each operation to further improve the accuracy of the log. By calculating the time difference, the time-consuming calculation rule for each operation can be obtained. In this embodiment, the calculated difference will be converted to milliseconds and can be defined using the following field: runtime = endTime - startTime. The time-consuming calculation rule can improve the efficiency of evaluating operations and identify possible performance bottlenecks.

[0073] Finally, the standard resource type enumeration, operation instructions, status coding system, and time-consuming calculation rule are integrated. After the integration process, a comprehensive resource call chain log model can be obtained, which will detail the call situation of each resource in the microservice module. The resource call chain log model can not only better understand the running situation of the system but also provide important diagnostic information when problems occur, so as to enhance the stability and reliability of the microservice system.

[0074] Furthermore, in obtaining the task attributes of each resource in each microservice module, the task attributes include the resource type of the resource operation, operation command, operation status, and operation time consumption. Specifically, the resource type refers to the type of the object being operated, such as a file, database record, or network request, etc. The operation command describes the specific action performed on the resource, such as create, read, update, or delete, etc. The operation status reflects the current progress of the task, such as whether it is being executed, completed, or failed, etc. Finally, the operation time consumption records the time required to complete the task, which helps to evaluate the system performance and optimize resource utilization.

[0075] In this embodiment, the resource type is marked by the link field (such as database / API), the operation instruction is recorded by command (such as SQL statement, API path), the operation status is defined by state, and the operation time consumption is defined by runtime.

[0076] Even further, the resource types are classified and counted through the Link field, and a performance bottleneck analysis report can be generated according to the resource types. Specifically, by using the Link field (for example: link: "MySQL.order_db") to classify and count various resource types in detail and generate a targeted performance bottleneck analysis report. Through in-depth analysis of the performance bottlenecks, specific improvement measures (not specifically limited in this embodiment) can be proposed to ensure the efficient utilization of resources and the stable operation of the system.

[0077] Subsequently, step S30 is executed to structure the task attributes of each resource in each microservice module, obtaining the resource call chain logs. Specifically, in this embodiment, it is also necessary to perform detailed structuring on the task attributes of each resource in each microservice module. After the structuring, the corresponding resource call chain logs will be obtained.

[0078] In the resource call chain logs, the call process and operation status of each resource in the microservice module will be recorded. Through the resource call chain logs, the usage of resources can be better understood, potential problems can be discovered, and the allocation and management of resources can be optimized. In addition, the resource call chain logs can also be used for fault troubleshooting and performance optimization. By viewing the call records in the logs, the location where the problem occurs can be quickly located and the cause of the problem can be analyzed. At the same time, based on the data in the logs, the performance of the resources can be evaluated, bottlenecks and deficiencies can be identified, and targeted optimizations can be carried out. At the same time, the microservice architecture can be better managed and optimized.

[0079] Finally, step S40 is executed to record and store the resource call chain logs for subsequent analysis and auditing work. Through the recorded resource call chain logs, the call process of each resource can be traced, which helps to better understand the operation of the system, timely discover potential problems, and provide strong data support for the optimization and improvement of the system. At the same time, reasonably recording and storing the resource call chain logs also helps to improve the efficiency of log query and can quickly locate and analyze problems when needed.

[0080] As an optional implementation, after recording and storing the resource call chain logs, it further includes: delivering the resource call chain logs to the Alibaba Cloud Log Service for log display and / or old log archiving. Specifically, after recording and storing the resource call chain logs, the log data of the resource call chain can also be delivered to the Alibaba Cloud Log Service (SLS) for real-time log display and analysis. At the same time, this function can also be used to archive old log data for historical data query and long-term storage.

[0081] The method described in this embodiment realizes fine-grained end-to-end call chain tracing by generating a request identifier for each service request, recording the task attributes of each resource inside the microservice module, and finally processing the task attributes to obtain the resource call chain logs. It can associate and call the logs of each microservice module in the microservice system, improve the management efficiency of log files, and at the same time improve the system's debuggability, the efficiency of fault location, and the efficiency of system performance optimization.

[0082] The embodiment is only a special case and does not indicate that the present invention has only such an implementation.

[0083] Embodiment 2:

[0084] Based on the same inventive concept, as Figure 2 shown, the second embodiment of the present invention further provides a resource call chain log recording and processing device under a microservice architecture, including:

[0085] A generation module S100, which receives a service request and generates a request identifier according to the service request;

[0086] An acquisition module S200, which acquires the task attributes of each resource in each microservice module according to the request identifier; wherein, the task attributes of each resource in each microservice module are defined and recorded by a resource call chain log model;

[0087] A processing module S300, which performs structured processing on the task attributes of each resource in each microservice module to obtain a resource call chain log;

[0088] A recording module S400, which records and stores the resource call chain log.

[0089] As an optional implementation manner, the task attributes of each resource in each microservice module are defined and recorded by a resource call chain log model. The generation method of the resource call chain log model in the microservice module includes:

[0090] Establish a standard resource type enumeration according to the database, cache, and message queue;

[0091] Perform parameterized desensitization processing on the SQL statements in the database, and record the method and path of the call request to obtain standardized operation instructions;

[0092] Unify the status codes to obtain a status code system;

[0093] Use a high-precision timer to record the start and end times of the operation, and calculate the time difference to obtain a time-consuming calculation rule;

[0094] Fuse the standard resource type enumeration, operation instructions, status code system, and time-consuming calculation rule to obtain a resource call chain log model in the microservice module.

[0095] As an optional implementation manner, receiving a service request and generating a request identifier according to the service request includes:

[0096] Receive the service request sent by the user;

[0097] Generate a request identifier from the service request through a hash algorithm; wherein, each different service request will generate a different and unique request identifier, and the request identifier will be injected into the request context and transmitted along the call link.

[0098] As an optional implementation manner, generating a request identifier for a service request through a hashing algorithm includes:

[0099] Extracting request parameters in the service request;

[0100] Converting the request parameters into a json string;

[0101] Concatenating the current timestamp in the json string;

[0102] Performing md5 processing on the json string concatenated with the current timestamp to obtain a unique request identifier.

[0103] As an optional implementation manner, in obtaining the task attributes of each resource in each microservice module, the task attributes include the resource type of the resource operation, the operation command, the operation status, and the operation duration.

[0104] As an optional implementation manner, the resource type is classified and counted through the Link field, and a performance bottleneck analysis report can be generated according to the resource type.

[0105] As an optional implementation manner, the processing device further includes:

[0106] A transfer and storage module that delivers the resource call chain log to the Alibaba Cloud Log Service for log display and / or old log transfer and storage.

[0107] Since the resource call chain log record processing under the microservice architecture introduced in this embodiment is the device adopted for implementing the resource call chain log record method under the microservice architecture in the first embodiment of the present application, based on the resource call chain log record method under the microservice architecture introduced in the first embodiment of the present application, those skilled in the art can understand the specific implementation manners and various variations of the resource call chain log record processing under the microservice architecture of this embodiment. Therefore, the implementation of how the resource call chain log record processing under the microservice architecture implements the method in the first embodiment of the present application will not be described in detail here. As long as those skilled in the art implement the device adopted for the resource call chain log record method under the microservice architecture in the first embodiment of the present application, it falls within the scope of protection of the present application.

[0108] Embodiment Three:

[0109] Based on the same inventive concept, the third embodiment of the present invention further provides a terminal device, as Figure 3 shown, including one or more processors 301 and a memory 302; wherein, the memory is used to store one or more computer programs, and the one or more processors are used to execute the one or more computer programs stored in the memory, so that the processor executes the features / steps of the xx method embodiment as described in Embodiment One.

[0110] Those of ordinary skill in the art can understand that all or part of the features / steps for implementing the above method embodiments can be realized by a method, a data processing system, or a computer program. These features can be implemented without using hardware, entirely using software, or using a combination of hardware and software. The aforementioned computer program can be stored in one or more computer-readable storage media. When the computer program stored on the storage media is executed (such as by a processor), it performs the steps of the method embodiments of the resource call chain logging method under the microservice architecture as described above.

[0111] Embodiment 4:

[0112] Based on the same inventive concept, the fourth embodiment of the present invention also provides a computer-readable storage medium. A computer program is stored on the computer-readable storage medium. When the program is executed by a processor, it realizes the steps of any of the methods of the resource call chain logging method under the microservice architecture described in Embodiment 1 above.

[0113] The above are only the preferred embodiments of the present invention. Those skilled in the art know that without departing from the spirit and scope of the present invention, various changes or equivalent substitutions can be made to these features and embodiments. Additionally, under the teaching of the present invention, these features and embodiments can be modified to adapt to specific situations and materials without departing from the spirit and scope of the present invention. Therefore, the present invention is not limited by the specific embodiments disclosed herein, and all embodiments falling within the scope of the claims of this application belong to the protection scope of the present invention.

Claims

1. A method for logging resource call chain under a microservice architecture, characterized in that, including: Receiving a service request and generating a request identifier according to the service request; Obtaining the task attributes of each resource in each microservice module according to the request identifier; wherein, the task attributes of each resource in each microservice module are defined and recorded by a resource call chain log model; Structuring the task attributes of each resource in each microservice module to obtain a resource call chain log; Recording and storing the resource call chain log.

2. The method for recording resource call chain logs in a microservices architecture according to claim 1, wherein The task attributes of each resource in each microservice module are defined and recorded by a resource call chain log model. The generation method of the resource call chain log model in the microservice module includes: Establishing a standard resource type enumeration according to a database, a cache, and a message queue; Performing parameterized desensitization processing on the SQL statements in the database, and recording the method and path of the call request to obtain a standardized operation instruction; Unifying the status codes to obtain a status code system; Using a high-precision timer to record the start and end times of an operation and calculating the time difference to obtain a time-consuming calculation rule; Performing a fusion process on the standard resource type enumeration, the operation instruction, the status code system, and the time-consuming calculation rule to obtain a resource call chain log model in the microservice module.

3. The method for logging resource call chain under the microservice architecture according to claim 1, characterized in that The receiving of the service request and generating a request identifier according to the service request includes: Receiving a service request sent by a user; Generating a request identifier from the service request through a hashing algorithm; wherein, each different service request generates a different and unique request identifier, and the request identifier is injected into the request context and transmitted along the call link.

4. The method for resource call chain logging under the microservice architecture according to claim 1, characterized in that The generating of the request identifier from the service request through the hashing algorithm includes: Extracting the request parameters from the service request; Converting the request parameters into a json string; Concatenating the current timestamp in the json string; Performing md5 processing on the json string concatenated with the current timestamp to obtain a unique request identifier.

5. The method for logging resource call chain under the microservice architecture according to claim 1, characterized in that In obtaining the task attributes of each resource in each microservice module, the task attributes include the resource type, operation command, operation status, and operation time-consuming of the resource operation.

6. The method for recording resource call chain logs in the microservice architecture according to claim 5, characterized in that, The resource type is classified and counted through a Link field, and a performance bottleneck analysis report can be generated according to the resource type.

7. The method for recording resource call chain logs in the microservice architecture according to claim 1, wherein After the recording and storing of the resource call chain log, it further includes: Delivering the resource call chain log to the Alibaba Cloud Log Service for log display and / or old log transfer.

8. A resource call chain log recording and processing device under a microservice architecture, characterized in that including: A generation module that receives a service request and generates a request identifier according to the service request; An acquisition module that obtains the task attributes of each resource in each microservice module according to the request identifier; wherein, the task attributes of each resource in each microservice module are defined and recorded by a resource call chain log model; A processing module that structures the task attributes of each resource in each microservice module to obtain a resource call chain log; A recording module that records and stores the resource call chain log.

9. A terminal device, characterized in that, including: One or more processors and a memory; Wherein, the memory is used to store one or more computer programs, and the one or more processors are used to execute the one or more computer programs stored in the memory, so that the processor executes the steps of the resource call chain logging method under the microservice architecture as described in any one of claims 1-7.

10. A computer-readable storage medium, on which a computer program is stored, characterized in that, When the program is executed by the processor, it implements the steps of the resource call chain logging method under the microservice architecture as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Distributed big data log link tracking method and system under micro-service architecture

    CN112612675A

  • Link collection method and system based on orchestration engine

    CN118055012A

  • Model training method and device, fault prediction method and device, medium and program product

    CN119204149A

  • Novel micro-service performance anomaly detection and root cause positioning system and method thereof

    CN119376990A

  • Microservice anomaly detection method, device, equipment and medium

    CN119538159A