[go: up one dir, main page]

WO2022022446A1 - Log printing method, device and system - Google Patents

Log printing method, device and system Download PDF

Info

Publication number
WO2022022446A1
WO2022022446A1 PCT/CN2021/108370 CN2021108370W WO2022022446A1 WO 2022022446 A1 WO2022022446 A1 WO 2022022446A1 CN 2021108370 W CN2021108370 W CN 2021108370W WO 2022022446 A1 WO2022022446 A1 WO 2022022446A1
Authority
WO
WIPO (PCT)
Prior art keywords
service
request
service module
module
log
Prior art date
Application number
PCT/CN2021/108370
Other languages
French (fr)
Chinese (zh)
Inventor
喻波
李艳丽
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2022022446A1 publication Critical patent/WO2022022446A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3006Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system is distributed, e.g. networked systems, clusters, multiprocessor systems
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3051Monitoring arrangements for monitoring the configuration of the computing system or of the computing system component, e.g. monitoring the presence of processing resources, peripherals, I/O links, software programs
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3089Monitoring arrangements determined by the means or processing involved in sensing the monitored data, e.g. interfaces, connectors, sensors, probes, agents

Definitions

  • the present application relates to the technical field of call chains, and in particular, to a method, device and system for printing logs.
  • Monolithic software system means that a software runs in an operating system, and often has only one process, and all commands of the software are completed in the operating system, such as QQ software.
  • a service-based software system often includes multiple sub-software, which can run in one or more operating systems, and each sub-software constitutes a business module. Multiple business modules with calling relationships form a calling chain, which is used to process a class of network requests from clients.
  • the log printed by the business module is mainly used to locate the business module with problems. Specifically, when the service module receives a network request, it prints an entry log; when the service module sends a network response, it prints an exit log. Finally, analyze the business module with problems through the entry log and exit log.
  • each call chain in the service-oriented software system will process a large number of network requests, and a large number of entry logs and exit logs need to be printed. Processes are undoubtedly resource-intensive.
  • An embodiment of the present application provides a method for printing logs, which is used to control the printing of logs, so as to reduce the number of logs to be printed, so as to avoid taking up a large amount of resources due to the printing of logs.
  • a first aspect of the embodiments of the present application provides a method for printing logs, the method includes: a first service module receives a first network request, the first network request is used to call the first service module, and the first network request may come from a client, It can also come from other business modules in the target call chain; based on the operation error of the first business module in the process of processing the first network request, or based on the first network response received by the first business module from the second business module that contains Error identification, the first service module prints a log, wherein the first network response is for the second network request, and the second network request is the process of the first service module processing the first network request to call the second service module.
  • the first service module and the second service module belong to the target call chain, and the error identifier indicates that there is a service module with an operation error in the target call chain.
  • the error identification may be various forms of the error identification, for example, it may be the value of the field added in the first response.
  • the number of logs printed is less than the first preset number.
  • the first period may be set according to actual needs, for example, one minute; the first preset number may also be set according to actual needs, for example, may be set to 5, 6, 7, and 8.
  • the embodiment of the present application can play a role of controlling the number of logs printed by the first service module without affecting the location of the faulty service module.
  • the method further includes: the first service module saves the data in the first network request to the memory; the first service module sends the first network request for the first network request.
  • the second network response, the second network response indicates the result of calling the first service module.
  • the printing of the log by the first service module includes: the first service module prints the entry log according to the stored data in the first network request; the first service module prints the exit log according to the data in the second network response.
  • the first service module After the first service module receives the first network request, it does not print the log, but saves the data in the first network request to the memory; when the first service module runs incorrectly in the process of processing the first network request, or When the first network response carries an error identifier, the first business module prints the entry log according to the data in the saved first network request, thereby avoiding printing the entry log when it is not determined that there is a business module with an operating error in the target call chain , occupying resources.
  • the first network request comes from a third service module, and the third service module belongs to the target call chain; sending the second network response to the first network request by the first service module includes: running based on the first service module If there is an error or the first network response carries an error identifier, the first service module sends a second network response carrying the error identifier to the first network request to the third service module, so that the third service module prints a log.
  • the method further includes: based on the first network request carrying the error identifier or the operation error of the first service module, the first service module sends the second network request carrying the error identifier to the second service module.
  • the method further includes: the first service module receives a third network request, and the third network request is used to call the first service module, wherein the third network request and the first network request are processed in the target call chain Received during the process of the same type of service request; based on the fact that the first service module does not run an error in the process of processing the third network request, and the received third network response does not contain an error identifier, the first service module does not print log.
  • the first business module does not run in error, and the received third network response does not contain an error identifier, the first business module does not print the log, which reduces the number of log prints and does not affect the location of the wrong business module; Moreover, since there is no business module with running error in the target call chain most of the time, the embodiment of the present application can greatly reduce the number of logs to be printed.
  • the method further includes: the first service module receives a third network request, and the third network request is used to invoke the first service module; based on a preset second period, the first service module is processing the third network In the case where there is no operation error during the request process and the received third network response does not contain an error identifier, the number of logs printed by the first service module is less than the second preset number, and the first service module prints the logs.
  • the first business module prints a log, which belongs to the correct log, so it can be used as a reference for the error log to determine the business module with an operating error;
  • the number of logs printed by the first business module in the above-mentioned situation is less than the second preset number, so that the number of logs printed can be controlled, preventing too many correct logs from being printed and occupying too many resources.
  • the target call chain belongs to the target service system and is used to process specific types of service requests sent by the client.
  • the target service system further includes a log management module, and the specific type of service requests include the first service request and the second service.
  • the target call chain further includes a fourth service module; the first network request is received by the first service module in the process of processing the first service request by the target call chain; wherein, the first network request may be the first network request from the client Service requests can also be network requests from other service modules.
  • the method further includes: the log management module obtains the log printed by the business module in the target call chain during the process of processing the first service request by the target call chain; the log printed by the business module in the target call chain does not include the log printed by the fourth business module. log, the log management module obtains the log printed by the fourth service module in the process of processing the second service request by the target call chain, and the log printed by the fourth service module in the process of processing the second service request by the target call chain is used to call the target The process of the chain processing the first service request is analyzed, and it is indicated that there is no service module in the target invocation chain that has an operating error during the process of the target invocation chain processing the second service request.
  • the request time of the second service request is earlier than and closest to the request time of the first service request.
  • the request time of the second service request is earlier than and closest to the request time of the first service request, so that the correct log obtained by the log management module is closer to
  • the fourth business module prints the correct log in the process of processing the first business request by the target call chain, thereby improving the accuracy of analyzing the process of the target call chain processing the first business request, and avoiding the correct log selected by the log management module and the fourth business request.
  • the correct log printed by the module during the process of processing the first service request by the target call chain is quite different, which affects the analysis of the process of the target call chain processing the first service request.
  • a second aspect of an embodiment of the present application provides an apparatus for printing a log, the apparatus comprising: a receiving unit, configured to receive a first network request; a log printing unit, configured to print a log based on an operating error in the process of processing the first network request, or The log is printed based on the received first network response to the second network request from the second service module that carries the error identifier, and the second network request is sent to call the second service module during the process of processing the first network request.
  • the second business module belongs to the target call chain, and the error identifier indicates that there is a business module with an operation error in the target call chain.
  • the number of logs printed is less than the first preset number.
  • the apparatus further includes: a saving unit, configured to save the data in the first network request to a memory; a sending unit, configured to send a second network response to the first network request, the second network response indicating The result of calling the first service module; the log printing unit is configured to print the entry log according to the stored data in the first network request, and print the exit log according to the data in the second network response.
  • the first network request comes from a third service module, and the third service module belongs to the target call chain; the device further includes a sending unit for running errors based on the first service module or the first network response carrying Error identification, sending the second network response carrying the error identification to the first network request to the third service module, so that the third service module prints a log.
  • the receiving unit is further configured to receive a third network request, and the third network request is used to call the first service module; the log printing unit is further configured to process the third network request based on the first service module. There is no running error in the process, and the third network response received does not contain an error flag, and no log is printed.
  • the receiving unit is further configured to receive a third network request, and the third network request is used to call the first service module; the log printing unit is further configured to process the third network request based on the first service module.
  • the received third network response does not contain an error identifier, and the log is printed; the first business module does not operate in error, the received third network response does not contain an error identifier, and the preset second During the period, the number of logs printed by the first service module is less than the second preset number.
  • the target call chain is used to process a specific type of service request sent by the client, and the specific type of service request includes a first service request; the first network request is that the first service module processes the first service request in the target call chain received during the process.
  • the target call chain belongs to the target business system, the target business system further includes a log management module, the specific type of business request further includes a second business request, and the target call chain further includes a fourth business module;
  • the log management module includes: a first obtaining unit, configured to obtain the log printed by the business module in the target call chain in the process of processing the first service request by the target call chain;
  • the second obtaining unit is configured to obtain the log printed by the fourth service module in the process of processing the second service request in the target call chain based on that the log printed by the service module in the target call chain does not include the log printed by the fourth service module, to Analyze the process of the target call chain processing the first service request, the log indication printed by the fourth service module in the process of processing the second service request by the target call chain, and the target call chain in the process of processing the second service request by the target call chain.
  • the request time of the second service request is earlier than and closest to the request time of the first service request.
  • a third aspect of an embodiment of the present application provides a server, including: at least one processor and a memory, where the memory stores computer-executable instructions that can run on the processor, and when the computer-executable instructions are executed by the processor, the The server executes the method for printing a log according to any one of the embodiments of the first aspect.
  • a fourth aspect of an embodiment of the present application provides a chip or a chip system, the chip or chip system includes at least one processor and a communication interface, the communication interface and the at least one processor are interconnected through a line, and the at least one processor is used for running a computer program or instruction , so as to execute the method for printing a log according to any one of the embodiments of the first aspect.
  • a fifth aspect of the embodiments of the present application provides a computer storage medium, where the computer storage medium is used for storing computer software instructions used by the above server, and the computer storage medium includes a program for executing a program designed for the server;
  • the server may be the device for printing a log described in the aforementioned second aspect.
  • a sixth aspect of the embodiments of the present application provides a computer program product, where the computer program product includes computer software instructions, and the computer software instructions can be loaded by a processor to implement the printing described in any one of the implementation manners of the first aspect above method of logging.
  • a seventh aspect of the embodiments of the present application provides a business system, including a target invocation chain, where the target invocation chain includes a first business module; the first business module is configured to execute the print log according to any one of the implementations of the first aspect above Methods.
  • the target call chain further includes a fourth service module, and the service system further includes a log management module; the target call chain is used to process a specific type of service request sent by the client, and the specific type of service request includes the first service request and the second service request; the first network request is received by the first service module in the process of processing the first service request by the target call chain.
  • the log management module is used to obtain the log printed by the business module in the target call chain in the process of processing the first service request by the target call chain; and the log printed by the business module in the target call chain does not include the log printed by the fourth business module.
  • log to obtain the log printed by the fourth service module in the process of processing the second service request by the target invocation chain, to analyze the process of processing the first service request by the target invocation chain, and the fourth service module in the target invocation chain to process the second service
  • the log printed in the process of the request indicates that there is no service module with an operation error in the target call chain in the process of processing the second service request by the target call chain.
  • the request time of the second service request is earlier than and closest to the request time of the first service request.
  • the request time of the second service request is earlier than and closest to the request time of the first service request, so that the correct log obtained by the log management module is closer to
  • the fourth business module prints the correct log in the process of processing the first business request by the target call chain, thereby improving the accuracy of analyzing the process of the target call chain processing the first business request, and avoiding the correct log selected by the log management module and the fourth business request.
  • the correct log printed by the module during the process of processing the first service request by the target call chain is quite different, which affects the analysis of the process of the target call chain processing the first service request.
  • FIG. 1 is a schematic diagram of the architecture of a business system in an embodiment of the application
  • FIG. 2 is a schematic diagram of a process of processing a specific type of network request by a call chain in an embodiment of the application
  • 3(a) is a schematic diagram of an embodiment of a method for printing a log in an embodiment of the present application
  • FIG. 3(b) is a schematic diagram of another embodiment of the method for printing a log in an embodiment of the present application.
  • FIG. 4 is a schematic diagram of an embodiment of processing a first network request by a first service module in an embodiment of the present application
  • FIG. 5 is a schematic diagram of another embodiment of processing a first network request by a first service module in an embodiment of the present application
  • FIG. 6 is a schematic diagram of an embodiment of a first service module integrated with a Tracer unit in an embodiment of the application;
  • FIG. 7 is a schematic diagram of an embodiment of an apparatus for printing a log provided by an embodiment of the present application.
  • FIG. 8 is a schematic structural diagram of a server in an embodiment of the present application.
  • FIG. 9 is a schematic diagram of an embodiment of a service system provided by an embodiment of the present application.
  • Embodiments of the present application provide a method, device, and system for printing logs, which are used to control the printing of logs, thereby reducing the number of logs to be printed, so as to avoid printing logs and occupying a large amount of resources.
  • the embodiments of the present application may be applied to a service system including at least one server. At least one business module can be deployed on each server. When multiple business modules need to be deployed on a server, multiple virtual machines can be deployed on the server, each virtual machine is installed with an operating system, the virtual machine can also be called a node, and then on each node Deploy one or more business modules in .
  • FIG. 1 is a schematic diagram of the architecture of a business system in an embodiment of the present application.
  • the business system in Figure 1 includes three servers, one of which is deployed with a business module A, one server is deployed with business module B and business module C, and the other server is deployed with business module D and business module E; this is Five business modules form a call chain for processing network requests from clients (for example, browsers).
  • call chains are used to process different types of network requests from clients, and network requests from clients can be specifically called service requests, so it can also be understood that each call chain is used to process specific types of services from clients ask.
  • This embodiment of the present application does not specifically limit a specific type of service request, for example, it may be a login request, a payment request, or an account query request, and the like.
  • the user operates on the client, triggering the client to send a login request to the business system in Figure 1, wherein the login request is received by the business module A; the business module A sends a login authentication request to the business module B; After receiving the login authentication request, the service module B sends an authentication request to the service module C; after receiving the authentication request, the service module C sends a request for obtaining user information to the service module D; the service module D receives the request for obtaining user information. After the request is made, a request for obtaining user information is sent to the service module E.
  • the service module E After the service module E receives the request for obtaining user information, it sends a network response to the request for obtaining user information from the network to the service module D; after the service module D receives the network response from the service module E, it sends the service module C to obtain The network response to the request for user information; after receiving the network response from the service module D, the service module C sends a network response to the authentication request to the service module B; after receiving the network response sent by the service module C, the service module B sends the The service module A sends a network response to the login authentication request; finally, after receiving the network response from the service module B, the service module A sends a network response to the login request to the client.
  • the call chain shown in FIG. 2 only includes five business modules such as A-E, and the calling relationship between these five business modules is relatively simple.
  • the process in which one service module sends a network request to another service module and receives a network response to the network request from the other service module is called the calling process of the service module. Relationships are called invocation relationships.
  • the number of business modules included in the call chain is large, and the call relationship may be complicated.
  • the business module B can call other business modules in addition to the business module C. That is, a business module can have a calling relationship with multiple business modules.
  • Printing the log means that the service module saves the operation data of the service module recorded in the memory to the memory.
  • the print log includes the print entry log and the print exit log.
  • the business module printing the entry log means that the business module saves the data in the received network request to the memory; the business module prints the exit log means that the business module will send the network request.
  • the data in the response is saved to memory.
  • the data in the network request may include the trace identifier TraceId, the time when the network request was received, and the network response identifier, etc.; similarly, the data in the network response may also include the trace identifier TraceId, the time when the network response was received, and the network response identifier. Wait.
  • the TraceId is globally unique and is used to mark each network request sent by the client, and each network request sent by the client carries a different TraceId.
  • the service module A receives multiple network requests from the client, and the TraceId contained in each network request is different.
  • business module A after receiving the network request, business module A will add the TraceId in the network request to the network request sent to business module B, and business module B will also add the TraceId to the network response sent to business module A. .
  • the client sends a specific type of service request, in the process of processing the specific type of service request in the call chain, the network request sent by each service module in the call chain, the received network request, the sent network response and the received The network response will carry the TraceId used to mark a specific type of service request.
  • the network response identifier is used to indicate the current status of the network request. For example, if the value of the network response identifier is 200, it indicates that the current status of the network request is successful; if the value of the network response identifier is 404, it indicates that the current status of the network request is successful. The status is no network response.
  • each business module in the call chain prints logs (including entry logs and exit logs), Then the business modules in the call chain will inevitably print a lot of logs, which will occupy a lot of resources such as memory, Input/Output (I/O), and Central Processing Unit (CPU).
  • I/O Input/Output
  • CPU Central Processing Unit
  • an embodiment of the present application provides a method for printing logs, the method can identify the situation that there is a business module with an operating error in the call chain, and print the log when there is a business module with an operating error in the calling chain In this way, it does not affect the positioning of the business module in which the problem occurs, but also realizes the control of the log printing, thereby reducing the number of log printing and the resource occupation of the log printing.
  • FIG. 3( a ) is a schematic diagram of an embodiment of a method for printing a log in an embodiment of the present application.
  • an embodiment of the present application provides an embodiment of a method for printing a log, including:
  • Step 101 the first service module receives a first network request, and the first network request is used to invoke the first service module.
  • each business module in the call chain will receive a network request when it is called; for example, each business module in the call chain shown in Figure 2 will receive a network request.
  • the first service module will also receive a first network request during the process of being called.
  • the first network request may come from the client or the target call other business modules in the chain; taking the call chain shown in Figure 2 as an example, when the first business module is business module A, the first network request comes from the client; when the first business module is business module B, The first network request comes from service module A.
  • the first network request may include the trace identifier TraceId, the time when the network request was received, the network response identifier, and the like.
  • Step 102 the first service module prints a log based on an error in the operation of the first service module in the process of processing the first network request, or based on the fact that the first network response from the second service module received by the first service module carries an error identifier .
  • the first network response is for the second network request, and the second network request is sent by the first service module for invoking the second service module in the process of processing the first network request.
  • the first service module and the second service module It belongs to the target call chain, and the error flag indicates that there is a business module running wrong in the target call chain.
  • the process of processing the first network request by the first service module includes two cases, and the two cases are described below with reference to FIG. 4 and FIG. 5 .
  • Case 1 As shown in Figure 4, the first service module first performs the first internal operation after receiving the first network request. After the first internal operation, the first service module sends the second service module to the second service module. Two network requests, the second network request is used to call the second service module; after that, the first service module will receive the first network response from the second service module, and the first network response indicates the result of calling the second service module. After receiving the first network response, the first service module may perform a second internal operation (for example, may process the first network response), and after the second internal operation, the first service module sends a message to the second service module. A second response to the first network request.
  • a second internal operation for example, may process the first network response
  • the process of processing the first network request by the first service module belongs to the above-mentioned process.
  • the error identifier at this time specifically represents the service invoked prior to the first service module in the target call chain
  • the first business module will add an error flag to the second network request; similarly, if the second business module runs wrong for the first time after receiving the first network request, or the second business If the second network request received by the module carries an error identifier, the second service module will also add the error identifier to the network requests sent to other service modules.
  • the first service module may print a log when there is an operation error, and may also print a log when the received first network response carries an error identifier.
  • the operation error of the first service module includes the first internal operation error of the first service module after receiving the first network request, and also includes the second internal operation error after receiving the first network response.
  • the second case as shown in Figure 5, the first service module runs internally after receiving the first network request, and after the internal operation, the first service module sends a second response to the first network request, that is, the first service The module did not call the business module in the target call chain.
  • the first business module is the last business module in the calling chain, so the first business module can complete the processing of the first network request without calling other business modules.
  • the first business module may is the business module E in the call chain shown in FIG. 2 .
  • Another application scenario may be that the first service module has an internal operation error or the first network request carries an error identifier. In this case, the first service module directly sends the second response to the first network request without calling other service modules. In order to indicate that there is a service module with running error in the target call chain of the client or service module that sends the first network request.
  • the first network request if the first network request carries an error identifier, it means that there is an error in the data in the first network request, which usually leads to an internal operation error of the first service module. Therefore, in this embodiment of the present application, the first network request carries an error identifier. The situation is a special case of the internal operation error of the first business module.
  • the first service module may print a log when there is an error in operation.
  • the operation error of the first service module includes an internal operation error of the first service module after receiving the first network request.
  • a new field can be added to the first response, when this field is used to indicate whether there is a business module with an operation error in the target call chain; specifically, when the value of this field is true, it indicates that the target call chain is in There is a business module with an operating error. When the value of this field is false, it means that there is no business module with an operating error in the target call chain.
  • printing the log in the case of identifying a business module with an operating error in the target call chain, printing the log can play a role in controlling the printing of the log, thereby reducing the number of logs to be printed, so as to avoid printing the log and occupying a lot of resources ; It will not affect the location of the faulty business module due to blindly reducing the number of log prints.
  • the embodiment of the present application controls the number of logs printed by the first service module when there is a service module with an operating error in the target call chain.
  • the number of logs printed is less than the first preset number.
  • the first period may be set according to actual needs, for example, one minute; the first preset number may also be set according to actual needs, for example, may be set to 5, 6, 7, and 8.
  • the embodiment of the present application the number of logs printed by the first business module in the first cycle and when there is a business module with an operating error in the target call chain is controlled, so as to prevent the first cycle from being caused by the same reason A certain business module runs incorrectly, so that the first business module prints a large number of logs; therefore, the embodiment of the present application can control the number of logs printed by the first business module without affecting the location of the wrong business module. effect.
  • the number of logs printed by the first service module in the preset first cycle is not specifically limited in this embodiment of the present application.
  • the number of logs is periodically controlled by a service module that receives a specific type of service request from a client.
  • the service module that receives the specific type of service request from the client adds the remaining number of error logs to the network request sent to the other service module in the process of calling another service module; when When the other business module needs to call other business modules, it also adds the remaining number of error logs to the network request sent to other business modules, and so on, each business module in the target call chain will receive the remaining number of error logs. Number of error logs.
  • the business module in the target call chain can print the log.
  • the service module that receives a specific type of service request from the client every time it receives a specific type of service request from the client, decrements the remaining number of error logs by 1 until it becomes 0.
  • the business module in the target call chain does not print the log.
  • the service module that receives the specific type of service request from the client will update the remaining number of error logs to the first preset number, thereby realizing periodic control of the number of logs.
  • service module A after receiving the network request from the client, service module A adds the remaining number of error logs to the network request sent to service module B, where the initial value of the remaining number of error logs is is the first preset number, and it is assumed here that the first preset number is 5; correspondingly, the service module B will receive the remaining number of error logs (5), and the service module B can determine whether to print according to the remaining number of error logs log. Specifically, when the service module B runs incorrectly or the service module B receives the network response from the service module C with an error identifier, since the number of remaining error logs is 5, which is greater than 0, the service module B prints the log.
  • business module B when business module B calls business module C, business module B will add the remaining number of error logs (5) to the network request sent to business module C, so that business module C can Quantity determines whether to print the log.
  • the method for the business module C to determine whether to print the log is the same as that for the business module B.
  • the remaining number of error logs added to the network request sent to the service module B will become 4. As the number of network requests received from the client by the service module A increases, the number of remaining error logs added will decrease sequentially. When the number of remaining error logs is reduced to 0, even if the service module B runs incorrectly or the service module B receives an error identifier in the network response from the service module C, the service module B does not print the log.
  • the service module A updates the remaining number of error logs to the first preset number every one minute (ie, the period for updating the remaining number of error logs).
  • the first service module print log includes print entry log and print exit log, and the process of print log will be described below.
  • the method further includes:
  • Step 103 the first service module saves the data in the first network request to the memory.
  • step 103 is executed after step 101 is executed. If the first service module sends the second network request to the second service module, step 103 is performed before the first service module sends the second network request.
  • the first service module after receiving the first network request, the first service module will save the data in the first network request to the memory, so as to prevent the data in the first network request from being cleared.
  • the data in the first network request may be sorted first, and the embodiment of the present application does not specifically limit the sorting method of the data in the first network request.
  • Step 104 the first service module sends a second network response to the first network request, and the second network response indicates the result of calling the first service module.
  • step 104 is executed after step 102 is executed.
  • the first service module after receiving the first network request, can process the first network request through internal operation, and send the second network response according to the processing result; the first service module can also perform the first The second internal operation is performed, and then the second network request is sent to the second service module, and the first network response from the second service module is received, and the second internal operation is performed according to the first network response to complete the response to the first network request. processing, and finally sending a second network response according to the processing result.
  • the first service module sends a second network response to the client; if the first network request comes from other service modules, the first service module sends other services to the client. The module sends a second network response.
  • the printing log of the first service module may include:
  • the first service module prints the entry log according to the stored data in the first network request.
  • printing the entry log includes outputting the saved data in the first network request to the memory.
  • the first service module prints the exit log according to the data in the second network response.
  • printing the export log includes outputting the saved data in the second network response to the memory.
  • the business module prints the entry log after receiving the network request, and after printing the entry log, sends a network request to the next business module to call the next business module, after that, the network
  • the data in the request is cleared from memory.
  • the first service module after receiving the first network request, the first service module does not print the log, but saves the data in the first network request to the memory; if the first service module is processing the first network If there is an error in the operation of the request, or the first network response carries an error identifier, the first service module will print the entry log according to the stored data in the first network request.
  • the first service module does not clear the data in the first network request after sending the second network request to the second service module, but prints the entry log and the data in the first network request. After the log is exported, the data in the first network request and the data in the second network response in the memory are cleared.
  • the first service module after receiving the first network request, does not print the log first, but saves the data in the first network request to the memory; when the first service module is processing the first network request When there is an error in the operation of the process, or the first network response carries an error identifier, the first service module prints the entry log according to the data in the saved first network request, so as to avoid the operation error in the undetermined target call chain. In the case of a module, the entry log is printed, resulting in a waste of resources.
  • the first network request may come from a service module or a client.
  • the following describes the case where the first network request comes from the service module.
  • the first network request comes from a third service module, and the third service module belongs to the target call chain; the first service module sends the first network request for the first network request.
  • Two network responses include:
  • the first service module Based on the operation error of the first service module or the error identifier carried in the first network response, the first service module sends the second network response carrying the error identifier to the first network request to the third service module, so that the third service module Print log.
  • the third business module will print a log after receiving the second network response carrying the error identifier, wherein the process of printing the log by the third business module is the same as the process of printing the log by the first business module, so the This will not be repeated.
  • the method further includes:
  • Step 105 the first service module receives a third network request, and the third network request is used to invoke the first service module.
  • step 105 is executed after step 104 is executed.
  • the third network request is similar to the first network request, and specifically, the third network request may be understood by referring to the relevant description of the first network request.
  • the first service module after receiving the third network request, the first service module will save the data in the third network request to the memory.
  • Step 106 based on the fact that the first service module does not have an error in the process of processing the third network request, and the received third network response does not contain an error identifier, the first service module does not print a log.
  • the first business module does not run in error, and the received third network response does not contain an error identifier, it means that there is no business module with an error in the target call chain; in order to control the number of logs printed, in this case, the first A business module does not print logs.
  • the first service module may clear the stored data in the third network request after determining that it does not run in error and the received third network response does not contain an error identifier.
  • the embodiment of the present application when the first service module does not run in error, and the received third network response does not contain an error identifier, the first service module does not print the log, which reduces the number of log prints and does not affect the Locate service modules that run incorrectly; and because there is no service module that runs incorrectly in the target call chain most of the time, the embodiment of the present application can greatly reduce the number of logs printed, and significantly reduce the resource occupation of printing logs.
  • the log printed when there is no faulty business module in the target call chain may be used as a reference, so there is no running fault in the target call chain.
  • some logs can also be printed; however, in order to avoid printing a large number of logs and occupying resources, the number of logs to be printed can be controlled.
  • the method further includes:
  • Step 107 the first service module receives a third network request, and the third network request is used to invoke the first service module.
  • the third network request and the first network request are received during the process of processing the same type of service request by the target call chain.
  • the first network request is a login request with an error
  • the network request is a login request without an error identifier; since the third network request is similar to the first network request, the third network request can be understood by referring to the relevant description of the first network request.
  • Step 108 based on the preset second period, the first service module has no error in the process of processing the third network request, and the received third network response does not contain an error identifier, the first service module has been When the number of printed logs is less than the second preset number, the first service module prints the logs. It can be understood that, within the preset second period, if there is no error during the processing of the third network request, and the received third network response does not contain an error identifier, if the first service module has When the number of printed logs is equal to the second preset number, the printing of logs will be stopped.
  • the first business module in the case where there is no business module with an operating error in the target call chain, the first business module prints the log, but within the preset second cycle, the first business module prints the log in the above situation
  • the number is smaller than the second preset number, so that the printing number of the log can be controlled.
  • the method of controlling the number of logs printed by the first business module to be less than the second preset number is the same as the method of controlling the number of logs printed by the first business module to be less than the first preset number.
  • the description of the method in which the number of printed logs is less than the first preset number should be understood.
  • the second period can also be set according to actual needs, for example, it can be one minute; the second preset number can also be set according to actual needs, for example, it can be set to 1.
  • the first business module can control the log printing through steps 105 and 106, or can perform log printing through steps 107 and 108. control.
  • the target call chain is used to process a specific type of service request sent by the client, and the number of the specific type of service request can be multiple; as an optional method, the target call chain belongs to the target service system, and For processing the specific type of service request sent by the client, the target service system further includes a log management module, the specific type of service request includes a first service request and a second service request, and the target call chain further includes a fourth service module.
  • the first network request is received by the first service module in the process of processing the first service request by the target call chain; it is understandable that the first network request may be the first service request from the client, or may be from other service modules network request.
  • the process of processing the first service request by the target call chain is usually analyzed according to the logs printed by each service module in the target call chain in the process of processing the first service request by the target call chain, so as to locate the wrong operation. business module. Before the analysis, it is necessary to obtain the logs printed by each service module in the target call chain during the process of processing the first service request by the target call chain.
  • TraceId is globally unique and is used to mark each network request sent by the client, and the logs printed by each business module in the target call chain usually contain TraceId; therefore, it can be obtained according to TraceId and processed in the target call chain During the process of the first service request, the target calls the logs printed by each service module in the chain.
  • the method for printing a log in the embodiment of the present application further includes:
  • the log management module acquires the log printed by the service module in the target call chain during the process of processing the first service request by the target call chain.
  • the log management module obtains the logs printed by each business module in the target call chain to form a complete log of the target call chain. Therefore, under normal circumstances, the logs printed by the business module obtained by the log management module will include the first log. The log printed by the business module and the log printed by the fourth business module. However, there are at least two reasons that may cause that the log printed by the fourth business module is not included in the log printed by the business module in the target call chain.
  • the first reason is that in the process of processing the first service request by the target call chain, the fourth service module is not called.
  • the service module C may directly send a network response to the service module B without sending a network request to the service module D; therefore, the service module D and the service module Module E will not be called, then the logs printed by the business modules in the target call chain obtained by the log management module include the logs printed by business module C, but not the logs printed by business modules D and E.
  • the second reason is that in the process of processing the first service request by the target call chain, the fourth service module does not run in error and the received network response does not contain an error identifier.
  • the service module D does not run in error
  • the network response received from the service module E does not contain an error identifier
  • the service module D does not print the log; however, the service module C receives After receiving the network response from the service module D, there is an error, then the service module C will print a log.
  • the log printed by the business module in the target call chain obtained by the log management module is the log printed by the business module C, but does not include the log printed by the business module D.
  • the log management module obtains the log printed by the fourth business module in the process of processing the second business request by the target call chain, and the fourth business module is in
  • the log printed in the process of processing the second service request by the target call chain indicates that there is no service module with an operating error in the target call chain during the process of processing the second service request by the target call chain, and is used to process the first service on the target call chain
  • the requested process is analyzed.
  • the log printed by the business module in the target call chain does not include the log printed by the fourth business module. Whether it is the first reason above or the second reason above, it is not the fourth reason.
  • the business module caused the wrong business module to appear in the target call chain. If the log printed by the fourth service module when there is a service module with an error in the target call chain is used to analyze the process of the target call chain processing the first service request, it may be mistaken for the target call chain to process the first service During the request process, the fourth service module runs incorrectly.
  • the embodiment of the present application uses the log printed by the fourth service module in the process of processing the second service request by the target call chain to analyze the process of processing the first service request by the target call chain, so as to avoid affecting the processing of the second service request by the target call chain.
  • the business modules in the target call chain are usually adjusted, for example, the functions of the business modules in the target call chain can be improved. Based on this, in the process of processing different business requests in the target call chain, since the business module has changed, even if there is no business module with an error in the target call chain, the logs printed by the business module may be different. Therefore, if the log printed by the business module in the process of processing one service request of the target call chain is used to analyze the process of processing another service request by the target call chain, the analysis result may be affected.
  • the request time of the second service request is earlier than and closest to the first service request request time.
  • the service module A successively receives three service requests from the client, namely service request M, service request N, and service request K; During the process, there is no business module running wrong in the call chain, but in the process of processing the business request K, there is a business module running wrong in the call chain.
  • the log management module will select the log printed by the business module D during the process of processing the business request N of the call chain.
  • the log of the call chain processing service request K is analyzed, and the log printed by the business module D during the process of the call chain processing the service request M is not selected, and the process of the call chain processing the service request K is analyzed.
  • the request time of the second service request is earlier than and closest to the request time of the first service request, so that the log management module obtains the
  • the correct log is closer to the correct log printed by the fourth business module in the process of processing the first business request by the target call chain, which makes the analysis of the process of the target call chain processing the first business request more accurate and avoids the selection of the log management module.
  • the difference between the correct log and the correct log printed by the fourth service module in the process of processing the first service request by the target call chain is large, which affects the analysis of the process of processing the first service request by the target call chain.
  • the first service module in the embodiment of the present application is different from the existing service module.
  • the first service module in the embodiment of the present application is not only used for processing received network requests, but also for controlling the printing of logs.
  • the first service module may perform at least one of the following operations.
  • the first service module in the embodiment of the present application prints a log when the first network response carries an error identifier or the first service module runs in error.
  • the specific process please refer to the relevant descriptions in the foregoing embodiments.
  • the first service module in the embodiment of the present application is controlled within a preset first period, and in the case that the first service module has a service module with an operating error in the target call chain, the number of logs printed is less than the first preset period. Set quantity.
  • the first service module in the embodiment of the present application does not print a log when the first network response does not contain an error identifier and the first service module does not run with errors.
  • the first service module in the embodiment of the present application prints a log when the first network response does not contain an error identifier and the first service module does not run in error, and controls it within a preset second period, and the first When the business module does not have a business module with an operating error in the target call chain, the number of logs printed by the first business module is less than the second preset number.
  • the specific control process please refer to the relevant descriptions in the foregoing embodiments.
  • a tracer unit may be integrated in the first service module shown in FIG.
  • the Tracer unit is integrated in the first service module shown in FIG. 5 ; the Tracer unit is responsible for performing at least one of the above operations, so as to realize the control of log printing.
  • This application example includes two scenarios.
  • the third service module sends the first network request, and the first service module receives the first network request.
  • eac290b095464ae5b4ebc754266a015a is the TraceId of the network request received by the service module A.
  • the first service module saves the data in the first network request to the memory, but does not print the entry log first.
  • the first service module processes the first network request through internal operation.
  • the first service module sends a second network request to the second service module.
  • the second service module After receiving the second network request, the second service module processes the second network request, and then sends the first network response to the first service module.
  • the first service module receives the first network response from the second service module.
  • the first service module processes the first network response through internal operation.
  • Step 7 Based on the operation error of the first service module in the process of processing the first network request, or based on the fact that the first network response from the second service module received by the first service module carries an error identifier, the first service module prints log.
  • the first service module sends a second network response to the first network request to the third service module.
  • the third service module sends a third network request, and the first service module receives the third network request.
  • the parameters in the third network request are the same as the parameters in the first network request in the first scenario.
  • the first service module saves the data in the third network request to the memory, but does not print the entry log first; then the first service module processes the third network request through internal operation.
  • the first business module calls the second business module, and in the calling process of calling the second business module and subsequent business modules, there is no business module with an operating error.
  • the first service module will receive a third network response from the second service module, and the third network response does not contain an error identifier.
  • the first service module does not print a log based on the fact that the first service module does not have an error in the process of processing the third network request, and the received third network response does not contain an error identifier.
  • the first service module sends a network response to the third network request to the third service module.
  • FIG. 7 is a schematic diagram of an embodiment of an apparatus for printing a log provided by an embodiment of the present application.
  • the apparatus includes:
  • a receiving unit 301 configured to receive a first network request
  • the log printing unit 302 is configured to print a log based on an operation error in the process of processing the first network request, or based on the received first network response to the second network request from the second service module that carries an error identifier.
  • the second network request is sent to call the second service module in the process of processing the first network request.
  • the second service module belongs to the target call chain, and the error flag indicates that there is a service module in the target call chain with an operating error.
  • the number of logs printed is less than the first preset number.
  • the apparatus further includes: a saving unit 303, configured to save the data in the first network request to a memory; a sending unit, configured to send a second network response to the first network request, the second network response Indicates the result of calling the first service module; the log printing unit is configured to print the entry log according to the data in the saved first network request, and print the exit log according to the data in the second network response.
  • the first network request comes from a third service module, and the third service module belongs to the target call chain; the apparatus further includes a sending unit 304, which is configured to be based on an operation error of the first service module or a carry in the first network response. If there is an error identifier, the second network response carrying the error identifier to the first network request is sent to the third service module, so that the third service module prints a log.
  • the receiving unit 301 is further configured to receive a third network request, and the third network request is used to invoke the first service module; the log printing unit 302 is further configured to process the third network based on the first service module There is no error during the request process, and the received third network response does not contain an error flag, and no log is printed.
  • the receiving unit 301 is further configured to receive a third network request, and the third network request is used to invoke the first service module;
  • the log printing unit 302 is further configured to process the third network based on the first service module There is no operation error in the process of the request, and the received third network response does not contain an error identifier, and the log is printed; the first business module does not operate with an error, the third network response received does not contain an error identifier, and the preset third network response does not contain an error identifier.
  • the number of logs printed by the first service module is less than the second preset number.
  • the target call chain is used to process a specific type of service request sent by the client, and the specific type of service request includes a first service request; the first network request is that the first service module processes the first service request in the target call chain received during the process.
  • the target call chain belongs to the target business system, the target business system further includes a log management module, the specific type of business request further includes a second business request, and the target call chain further includes a fourth business module;
  • the log management module includes: a first obtaining unit, configured to obtain the log printed by the business module in the target call chain in the process of processing the first service request by the target call chain;
  • the second obtaining unit is configured to obtain the log printed by the fourth service module in the process of processing the second service request in the target call chain based on that the log printed by the service module in the target call chain does not include the log printed by the fourth service module, to Analyze the process of the target call chain processing the first service request, the log indication printed by the fourth service module in the process of processing the second service request by the target call chain, and the target call chain in the process of processing the second service request by the target call chain.
  • the request time of the second service request is earlier than and closest to the request time of the first service request.
  • FIG. 8 is a schematic structural diagram of a server in an embodiment of the present application.
  • One embodiment of the server in this embodiment of the present application may include one or more processors 401 , a memory 402 , and a communication interface 403 .
  • the memory 402 may be ephemeral storage or persistent storage. Further, the processor 401 may be configured to communicate with the memory 402 to execute a series of instruction operations in the memory 402 on the control device.
  • the processor 401 may execute the steps of the methods in the foregoing embodiments, and details are not described herein again.
  • processor 401 may perform the following steps:
  • the second network request is sent by the first service module to call the second service module in the process of processing the first network request.
  • the first service module and the second service module belong to the target call chain, and the error flag indicates that there is a running operation in the target call chain. Wrong business module.
  • the division of specific functional modules in the processor 401 may be similar to the division of the functional modules described in FIG. 7 , which is not repeated here.
  • the embodiments of the present application further provide a chip or a chip system, the chip or chip system includes at least one processor and a communication interface, the communication interface and the at least one processor are interconnected by a line, and the at least one processor is used to run a computer program or instruction to The steps of the methods in the foregoing embodiments are performed, and details are not described herein again.
  • the communication interface in the chip may be an input/output interface, a pin, a circuit, or the like.
  • the embodiment of the present application also provides a first implementation manner of a chip or a chip system.
  • the chip or chip system described above in the present application further includes at least one memory, and instructions are stored in the at least one memory.
  • the memory may be a storage unit inside the chip, such as a register, a cache, etc., or a storage unit of the chip (eg, a read-only memory, a random access memory, etc.).
  • Embodiments of the present application also provide a computer storage medium, where the computer storage medium is used for storing computer software instructions used by the above-mentioned server, which includes a program for executing a program designed for the server.
  • the server may be the device for printing logs as described in the aforementioned FIG. 7 .
  • Embodiments of the present application also provide a computer program product, where the computer program product includes computer software instructions, and the computer software instructions can be loaded by a processor to implement the processes in the methods shown in the foregoing embodiments.
  • FIG. 9 is a schematic diagram of an embodiment of a service system provided by an embodiment of the present application.
  • an embodiment of the present application provides a business system, including a target call chain, and the target call chain includes a first business module 100; the first business module 100 is used to execute the print log in the foregoing embodiments Methods.
  • the target call chain further includes a fourth business module 200, and the business system further includes a log management module 300; the target call chain is used to process a specific type of service request sent by the client, and the specific type of service request includes the first The service request and the second service request; the first network request is received by the first service module 100 in the process of processing the first service request by the target call chain.
  • the log management module 300 is used to obtain the log printed by the business module in the target call chain in the process of processing the first service request by the target call chain; and the log printed based on the business module in the target call chain does not include the fourth business module 200
  • the log printed obtains the log printed by the fourth service module 200 in the process of processing the second service request by the target call chain, so as to analyze the process of processing the first service request by the target call chain, and the fourth service module 200 is in the target call chain.
  • the log printed in the process of processing the second service request indicates that there is no service module with an operating error in the target call chain in the process of processing the second service request by the target call chain.
  • the request time of the second service request is earlier than and closest to the request time of the first service request.
  • log management module 300 can be understood by referring to the relevant description of the log management module 300 in the foregoing embodiments.
  • the disclosed system, apparatus and method may be implemented in other manners.
  • the apparatus embodiments described above are only illustrative.
  • the division of the units is only a logical function division. In actual implementation, there may be other division methods.
  • multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not implemented.
  • the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, which may be electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units may be implemented in the form of hardware, or may be implemented in the form of software functional units.
  • the integrated unit if implemented in the form of a software functional unit and sold or used as an independent product, may be stored in a computer-readable storage medium.
  • the technical solutions of the present application can be embodied in the form of software products in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, and the computer software products are stored in a storage medium , including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage medium includes: U disk, mobile hard disk, Read-Only Memory (ROM, Read-Only Memory), Random Access Memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program codes .

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Quality & Reliability (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

A log printing method is used for controlling log printing so as to reduce the number of printed logs and avoid the occupation of a large quantity of resources due to log printing. The method comprises: a first service module receiving a first network request, which is used for invoking the first service module; the first service module printing a log on the basis that an operation error occurs in the process of processing the first network request by means of the first service module; and if in the process of processing the first network request, the first service module sends a second network request to invoke a second service module, the first service module printing a log on the basis that an error identifier is carried in a first network response which is received by the first service module from the second service module. The first network response is for the second network request, the first service module and the second service module belong to a target invoke chain, and the error identifier indicates that there is a service module, on which an operation error occurs, in the target invoke chain.

Description

一种打印日志的方法、装置及系统Method, device and system for printing log
本申请要求于2020年7月31日提交中国国家知识产权局、申请号为202010762131.9、申请名称为“一种打印日志的方法、装置及系统”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application with the application number of 202010762131.9 and the application title of "A method, device and system for printing logs", which was submitted to the State Intellectual Property Office of China on July 31, 2020, the entire contents of which are by reference Incorporated in this application.
技术领域technical field
本申请涉及调用链技术领域,尤其涉及一种打印日志的方法、装置及系统。The present application relates to the technical field of call chains, and in particular, to a method, device and system for printing logs.
背景技术Background technique
随着技术的发展,软件已经由原来的单体软件系统演变为现在的服务化软件系统。单体软件系统是指一个软件运行在一个操作系统中,并且往往只有一个进程,该软件的所有命令都住在该操作系统中完成,例如QQ软件。而服务化软件系统往往包含多个子软件,多个子软件可以运行在一个或多个操作系统中,每个子软件构成一个业务模块。多个存在调用关系的业务模块构成一条调用链,用于处理来自客户端的一类网络请求。With the development of technology, software has evolved from the original single software system to the current service-oriented software system. Monolithic software system means that a software runs in an operating system, and often has only one process, and all commands of the software are completed in the operating system, such as QQ software. A service-based software system often includes multiple sub-software, which can run in one or more operating systems, and each sub-software constitutes a business module. Multiple business modules with calling relationships form a calling chain, which is used to process a class of network requests from clients.
由于一类网络请求需要一条调用链中的多个业务模块来处理,并且这多个业务模块间的调用关系可能比较复杂,所以当服务化软件系统出现故障时,快速定位出现问题的业务模块显得尤其重要。目前,主要是利用业务模块打印的日志定位出现问题的业务模块。具体地,业务模块在接收到网络请求时,会打印入口日志;业务模块在发送网络响应时,会打印出口日志。最终通过入口日志和出口日志分析出现问题的业务模块。Since a type of network request needs multiple business modules in a call chain to be processed, and the calling relationship between these multiple business modules may be complicated, when the service-based software system fails, it is necessary to quickly locate the faulty business module. Especially important. At present, the log printed by the business module is mainly used to locate the business module with problems. Specifically, when the service module receives a network request, it prints an entry log; when the service module sends a network response, it prints an exit log. Finally, analyze the business module with problems through the entry log and exit log.
然而,由于服务化软件系统的业务量大,所以服务化软件系统中的每条调用链都会处理大量的网络请求,也就需要打印大量的入口日志和出口日志,而打印入口日志和出口日志的过程无疑会占用过多的资源。However, due to the large business volume of the service-oriented software system, each call chain in the service-oriented software system will process a large number of network requests, and a large number of entry logs and exit logs need to be printed. Processes are undoubtedly resource-intensive.
发明内容SUMMARY OF THE INVENTION
本申请实施例提供了一种打印日志的方法,用于控制日志的打印,以减少日志的打印数量,以避免打印日志而占用大量的资源。An embodiment of the present application provides a method for printing logs, which is used to control the printing of logs, so as to reduce the number of logs to be printed, so as to avoid taking up a large amount of resources due to the printing of logs.
本申请实施例第一方面提供了一种打印日志的方法,方法包括:第一业务模块接收第一网络请求,第一网络请求用于调用第一业务模块,第一网络请求可以来自客户端,也可以来自目标调用链中的其他业务模块;基于第一业务模块在处理第一网络请求的过程中运行错误,或基于第一业务模块接收的来自第二业务模块的第一网络响应中携带有错误标识,第一业务模块打印日志,其中,所述第一网络响应是对于第二网络请求的,第二网络请求是第一业务模块处理第一网络请求的过程中为调用第二业务模块而发送的,第一业务模块和第二业务模块属于目标调用链,错误标识指示目标调用链中存在运行错误的业务模块。其中,错误标识的形式可以有多种,例如可以是在第一响应中添加的字段的值。A first aspect of the embodiments of the present application provides a method for printing logs, the method includes: a first service module receives a first network request, the first network request is used to call the first service module, and the first network request may come from a client, It can also come from other business modules in the target call chain; based on the operation error of the first business module in the process of processing the first network request, or based on the first network response received by the first business module from the second business module that contains Error identification, the first service module prints a log, wherein the first network response is for the second network request, and the second network request is the process of the first service module processing the first network request to call the second service module. In the case of sending, the first service module and the second service module belong to the target call chain, and the error identifier indicates that there is a service module with an operation error in the target call chain. Wherein, there may be various forms of the error identification, for example, it may be the value of the field added in the first response.
先识别目标调用链中存在运行错误的业务模块的情况,然后打印日志,能够起到控制日志打印的作用,从而减少日志的打印数量,以避免打印日志而占用大量的资源;也不会因盲目减少日志打印数量而影响对出问题的业务模块的定位。First identify the business module that is running wrong in the target call chain, and then print the log, which can control the printing of the log, thereby reducing the number of logs to be printed, so as to avoid printing logs and occupying a lot of resources; Reducing the number of log prints affects the location of the faulty business module.
在一种实现方式下,预设第一周期内,第一业务模块在目标调用链中存在运行错误的业务模块的情况下,打印的日志数量小于第一预设数量。其中,第一周期可以根据实际需要进行设定,例如可以为一分钟;第一预设数量也可以根据实际需要进行设定,例如可以设置为5、6、7和8等。In an implementation manner, within the preset first cycle, when the first service module has a service module with an operating error in the target call chain, the number of logs printed is less than the first preset number. The first period may be set according to actual needs, for example, one minute; the first preset number may also be set according to actual needs, for example, may be set to 5, 6, 7, and 8.
控制第一业务模块在第一周期内,且在目标调用链中存在运行错误的业务模块的情况下打印的日志数量,从而防止在第一周期内,由于同一原因导致某一业务模块运行错误,以致于第一业务模块打印大量的日志;因此,本申请实施例能够在不对定位运行错误的业务模块造成影响的前提下,起到控制第一业务模块打印日志数量的作用。Control the number of logs printed by the first business module in the first cycle and when there is a business module with an operating error in the target call chain, so as to prevent a business module from running incorrectly due to the same reason in the first cycle, As a result, the first service module prints a large number of logs; therefore, the embodiment of the present application can play a role of controlling the number of logs printed by the first service module without affecting the location of the faulty service module.
在一种实现方式下,在第一业务模块接收第一网络请求之后,方法还包括:第一业务模块保存第一网络请求中的数据至内存;第一业务模块发送对于第一网络请求的第二网络响应,第二网络响应指示调用第一业务模块的结果。第一业务模块打印日志包括:第一业务模块根据保存的第一网络请求中的数据打印入口日志;第一业务模块根据第二网络响应中的数据打印出口日志。In an implementation manner, after the first service module receives the first network request, the method further includes: the first service module saves the data in the first network request to the memory; the first service module sends the first network request for the first network request. The second network response, the second network response indicates the result of calling the first service module. The printing of the log by the first service module includes: the first service module prints the entry log according to the stored data in the first network request; the first service module prints the exit log according to the data in the second network response.
第一业务模块在接收到第一网络请求后,先不打印日志,而是将第一网络请求中的数据保存至内存;当第一业务模块在处理第一网络请求的过程中运行错误,或第一网络响应中携带有错误标识时,第一业务模块根据保存的第一网络请求中的数据打印入口日志,从而避免在未确定目标调用链中存在运行错误的业务模块的情况下打印入口日志,占用资源。After the first service module receives the first network request, it does not print the log, but saves the data in the first network request to the memory; when the first service module runs incorrectly in the process of processing the first network request, or When the first network response carries an error identifier, the first business module prints the entry log according to the data in the saved first network request, thereby avoiding printing the entry log when it is not determined that there is a business module with an operating error in the target call chain , occupying resources.
在一种实现方式下,第一网络请求来自于第三业务模块,第三业务模块属于目标调用链;第一业务模块发送对于第一网络请求的第二网络响应包括:基于第一业务模块运行错误或第一网络响应中携带有错误标识,第一业务模块向第三业务模块发送对于第一网络请求的携带有错误标识的第二网络响应,以使得第三业务模块打印日志。In an implementation manner, the first network request comes from a third service module, and the third service module belongs to the target call chain; sending the second network response to the first network request by the first service module includes: running based on the first service module If there is an error or the first network response carries an error identifier, the first service module sends a second network response carrying the error identifier to the first network request to the third service module, so that the third service module prints a log.
在一种实现方式下,方法还包括:基于第一网络请求中携带有错误标识或第一业务模块运行错误,第一业务模块向第二业务模块发送携带有错误标识的第二网络请求。In an implementation manner, the method further includes: based on the first network request carrying the error identifier or the operation error of the first service module, the first service module sends the second network request carrying the error identifier to the second service module.
在一种实现方式下,方法还包括:第一业务模块接收第三网络请求,第三网络请求用于调用第一业务模块,其中,第三网络请求与第一网络请求是在目标调用链处理同一类型的业务请求的过程中接收到的;基于第一业务模块在处理第三网络请求的过程中未运行错误,且接收到的第三网络响应中不包含错误标识,第一业务模块不打印日志。In an implementation manner, the method further includes: the first service module receives a third network request, and the third network request is used to call the first service module, wherein the third network request and the first network request are processed in the target call chain Received during the process of the same type of service request; based on the fact that the first service module does not run an error in the process of processing the third network request, and the received third network response does not contain an error identifier, the first service module does not print log.
在第一业务模块未运行错误,且接收到的第三网络响应中不包含错误标识的情况下,第一业务模块不打印日志,减少了日志打印数量,且不影响定位运行错误的业务模块;并且,由于多数时间内目标调用链中都不存在运行错误的业务模块,所以本申请实施例能够极大地减少日志的打印数量。In the case that the first business module does not run in error, and the received third network response does not contain an error identifier, the first business module does not print the log, which reduces the number of log prints and does not affect the location of the wrong business module; Moreover, since there is no business module with running error in the target call chain most of the time, the embodiment of the present application can greatly reduce the number of logs to be printed.
在一种实现方式下,方法还包括:第一业务模块接收第三网络请求,第三网络请求用于调用第一业务模块;基于预设第二周期内,第一业务模块在处理第三网络请求的过程中未运行错误,且接收到的第三网络响应中不包含错误标识的情况下,第一业务模块已打印的日志数量小于第二预设数量,第一业务模块打印日志。In an implementation manner, the method further includes: the first service module receives a third network request, and the third network request is used to invoke the first service module; based on a preset second period, the first service module is processing the third network In the case where there is no operation error during the request process and the received third network response does not contain an error identifier, the number of logs printed by the first service module is less than the second preset number, and the first service module prints the logs.
在目标调用链中不存在运行错误的业务模块的情况下,第一业务模块打印日志,该日志属于正确的日志,所以可以作为错误日志的参照,用于确定运行错误的业务模块;且在 预设第二周期内,第一业务模块在上述情况下打印的日志数量小于第二预设数量,从而可以控制日志的打印数量,防止打印过多的正确日志导致占用过多的资源。In the case where there is no business module with an operating error in the target call chain, the first business module prints a log, which belongs to the correct log, so it can be used as a reference for the error log to determine the business module with an operating error; In the second cycle, the number of logs printed by the first business module in the above-mentioned situation is less than the second preset number, so that the number of logs printed can be controlled, preventing too many correct logs from being printed and occupying too many resources.
在一种实现方式下,目标调用链属于目标业务系统,且用于处理客户端发送的特定类型业务请求,目标业务系统还包括日志管理模块,特定类型业务请求包括第一业务请求和第二业务请求,目标调用链还包括第四业务模块;第一网络请求是第一业务模块在目标调用链处理第一业务请求的过程中接收到的;其中,第一网络请求可以是来自客户端的第一业务请求,也可以是来自其他业务模块的网络请求。In an implementation manner, the target call chain belongs to the target service system and is used to process specific types of service requests sent by the client. The target service system further includes a log management module, and the specific type of service requests include the first service request and the second service. request, the target call chain further includes a fourth service module; the first network request is received by the first service module in the process of processing the first service request by the target call chain; wherein, the first network request may be the first network request from the client Service requests can also be network requests from other service modules.
方法还包括:日志管理模块获取在目标调用链处理第一业务请求的过程中,目标调用链中业务模块打印的日志;基于目标调用链中业务模块打印的日志中未包含第四业务模块打印的日志,日志管理模块获取第四业务模块在目标调用链处理第二业务请求的过程中打印的日志,第四业务模块在目标调用链处理第二业务请求的过程中打印的日志用于对目标调用链处理第一业务请求的过程进行分析,且指示在目标调用链处理第二业务请求的过程中目标调用链中不存在运行错误的业务模块。The method further includes: the log management module obtains the log printed by the business module in the target call chain during the process of processing the first service request by the target call chain; the log printed by the business module in the target call chain does not include the log printed by the fourth business module. log, the log management module obtains the log printed by the fourth service module in the process of processing the second service request by the target call chain, and the log printed by the fourth service module in the process of processing the second service request by the target call chain is used to call the target The process of the chain processing the first service request is analyzed, and it is indicated that there is no service module in the target invocation chain that has an operating error during the process of the target invocation chain processing the second service request.
采用第四业务模块在目标调用链处理第二业务请求的过程中打印的正确日志,对目标调用链处理第一业务请求的过程进行分析,以避免在对目标调用链处理第一业务请求的过程进行分析时,误认为在目标调用链处理第一业务请求的过程中,第四业务模块运行错误,从而提高日志分析的准确度。Use the correct log printed by the fourth service module in the process of processing the second service request by the target call chain to analyze the process of processing the first service request by the target call chain, so as to avoid the process of processing the first service request by the target call chain During the analysis, it is mistakenly believed that the fourth service module runs in error during the process of processing the first service request by the target call chain, thereby improving the accuracy of log analysis.
在一种实现方式下,在目标调用链已处理的特定类型业务请求的所有业务请求中,第二业务请求的请求时间早于且最接近第一业务请求的请求时间。In an implementation manner, among all the service requests of the specific type of service requests processed by the target call chain, the request time of the second service request is earlier than and closest to the request time of the first service request.
在目标调用链已处理的特定类型业务请求的所有业务请求中,第二业务请求的请求时间早于且最接近第一业务请求的请求时间,使得日志管理模块获取到的正确日志更接近于,第四业务模块在目标调用链处理第一业务请求的过程中打印的正确日志,从而提高分析目标调用链处理第一业务请求的过程的准确性,避免日志管理模块选择的正确日志与第四业务模块在目标调用链处理第一业务请求的过程中打印的正确日志相差较大,而影响对目标调用链处理第一业务请求的过程的分析。Among all the service requests of the specific type of service requests processed by the target call chain, the request time of the second service request is earlier than and closest to the request time of the first service request, so that the correct log obtained by the log management module is closer to, The fourth business module prints the correct log in the process of processing the first business request by the target call chain, thereby improving the accuracy of analyzing the process of the target call chain processing the first business request, and avoiding the correct log selected by the log management module and the fourth business request. The correct log printed by the module during the process of processing the first service request by the target call chain is quite different, which affects the analysis of the process of the target call chain processing the first service request.
本申请实施例第二方面提供了一种打印日志的装置,装置包括:接收单元,用于接收第一网络请求;日志打印单元,用于基于在处理第一网络请求的过程中运行错误,或基于接收的来自第二业务模块的对于第二网络请求的第一网络响应中携带有错误标识,打印日志,第二网络请求是处理第一网络请求的过程中为调用第二业务模块而发送的,第二业务模块属于目标调用链,错误标识指示目标调用链中存在运行错误的业务模块。A second aspect of an embodiment of the present application provides an apparatus for printing a log, the apparatus comprising: a receiving unit, configured to receive a first network request; a log printing unit, configured to print a log based on an operating error in the process of processing the first network request, or The log is printed based on the received first network response to the second network request from the second service module that carries the error identifier, and the second network request is sent to call the second service module during the process of processing the first network request. , the second business module belongs to the target call chain, and the error identifier indicates that there is a business module with an operation error in the target call chain.
在一种实现方式下,预设第一周期内,第一业务模块在目标调用链中存在运行错误的业务模块的情况下,打印的日志数量小于第一预设数量。In an implementation manner, within the preset first cycle, when the first service module has a service module with an operating error in the target call chain, the number of logs printed is less than the first preset number.
在一种实现方式下,装置还包括:保存单元,用于将第一网络请求中的数据保存至内存;发送单元,用于发送对于第一网络请求的第二网络响应,第二网络响应指示调用第一业务模块的结果;日志打印单元,用于根据保存的第一网络请求中的数据打印入口日志,且根据第二网络响应中的数据打印出口日志。In an implementation manner, the apparatus further includes: a saving unit, configured to save the data in the first network request to a memory; a sending unit, configured to send a second network response to the first network request, the second network response indicating The result of calling the first service module; the log printing unit is configured to print the entry log according to the stored data in the first network request, and print the exit log according to the data in the second network response.
在一种实现方式下,第一网络请求来自于第三业务模块,第三业务模块属于目标调用 链;装置还包括发送单元,用于基于第一业务模块运行错误或第一网络响应中携带有错误标识,向第三业务模块发送对于第一网络请求的携带有错误标识的第二网络响应,以使得第三业务模块打印日志。In an implementation manner, the first network request comes from a third service module, and the third service module belongs to the target call chain; the device further includes a sending unit for running errors based on the first service module or the first network response carrying Error identification, sending the second network response carrying the error identification to the first network request to the third service module, so that the third service module prints a log.
在一种实现方式下,接收单元,还用于接收第三网络请求,第三网络请求用于调用第一业务模块;日志打印单元,还用于基于第一业务模块在处理第三网络请求的过程中未运行错误,且接收到的第三网络响应中不包含错误标识,不打印日志。In an implementation manner, the receiving unit is further configured to receive a third network request, and the third network request is used to call the first service module; the log printing unit is further configured to process the third network request based on the first service module. There is no running error in the process, and the third network response received does not contain an error flag, and no log is printed.
在一种实现方式下,接收单元,还用于接收第三网络请求,第三网络请求用于调用第一业务模块;日志打印单元,还用于基于第一业务模块在处理第三网络请求的过程中未运行错误,且接收到的第三网络响应中不包含错误标识,打印日志;第一业务模块未运行错误,接收到的第三网络响应中不包含错误标识,且在预设第二周期内,第一业务模块打印的日志数量小于第二预设数量。In an implementation manner, the receiving unit is further configured to receive a third network request, and the third network request is used to call the first service module; the log printing unit is further configured to process the third network request based on the first service module. There is no operation error in the process, and the received third network response does not contain an error identifier, and the log is printed; the first business module does not operate in error, the received third network response does not contain an error identifier, and the preset second During the period, the number of logs printed by the first service module is less than the second preset number.
在一种实现方式下,目标调用链用于处理客户端发送的特定类型业务请求,特定类型业务请求包括第一业务请求;第一网络请求是第一业务模块在目标调用链处理第一业务请求的过程中接收到的。In an implementation manner, the target call chain is used to process a specific type of service request sent by the client, and the specific type of service request includes a first service request; the first network request is that the first service module processes the first service request in the target call chain received during the process.
在一种实现方式下,目标调用链属于目标业务系统,目标业务系统还包括日志管理模块,特定类型业务请求还包括第二业务请求,目标调用链还包括第四业务模块;In an implementation manner, the target call chain belongs to the target business system, the target business system further includes a log management module, the specific type of business request further includes a second business request, and the target call chain further includes a fourth business module;
日志管理模块包括:第一获取单元,用于获取在目标调用链处理第一业务请求的过程中,目标调用链中业务模块打印的日志;The log management module includes: a first obtaining unit, configured to obtain the log printed by the business module in the target call chain in the process of processing the first service request by the target call chain;
第二获取单元,用于基于目标调用链中业务模块打印的日志中未包含第四业务模块打印的日志,获取第四业务模块在目标调用链处理第二业务请求的过程中打印的日志,以对目标调用链处理第一业务请求的过程进行分析,第四业务模块在目标调用链处理第二业务请求的过程中打印的日志指示,在目标调用链处理第二业务请求的过程中目标调用链中不存在运行错误的业务模块。The second obtaining unit is configured to obtain the log printed by the fourth service module in the process of processing the second service request in the target call chain based on that the log printed by the service module in the target call chain does not include the log printed by the fourth service module, to Analyze the process of the target call chain processing the first service request, the log indication printed by the fourth service module in the process of processing the second service request by the target call chain, and the target call chain in the process of processing the second service request by the target call chain. There are no business modules that are running incorrectly in .
在一种实现方式下,在目标调用链已处理的特定类型业务请求的所有业务请求中,第二业务请求的请求时间早于且最接近第一业务请求的请求时间。In an implementation manner, among all the service requests of the specific type of service requests processed by the target call chain, the request time of the second service request is earlier than and closest to the request time of the first service request.
本申请实施例第三方面提供一种服务器,包括:至少一个处理器和存储器,存储器存储有可在处理器上运行的计算机执行指令,当所述计算机执行指令被所述处理器执行时,该服务器执行如上述第一方面中任意一种实施方式所述的打印日志的方法。A third aspect of an embodiment of the present application provides a server, including: at least one processor and a memory, where the memory stores computer-executable instructions that can run on the processor, and when the computer-executable instructions are executed by the processor, the The server executes the method for printing a log according to any one of the embodiments of the first aspect.
本申请实施例第四方面提供一种芯片或者芯片系统,该芯片或者芯片系统包括至少一个处理器和通信接口,通信接口和至少一个处理器通过线路互联,至少一个处理器用于运行计算机程序或指令,以执行如上述第一方面中任意一种实施方式所述的打印日志的方法。A fourth aspect of an embodiment of the present application provides a chip or a chip system, the chip or chip system includes at least one processor and a communication interface, the communication interface and the at least one processor are interconnected through a line, and the at least one processor is used for running a computer program or instruction , so as to execute the method for printing a log according to any one of the embodiments of the first aspect.
本申请实施例第五方面提供了一种计算机存储介质,该计算机存储介质用于储存为上述服务器所用的计算机软件指令,其包括用于执行为服务器所设计的程序;A fifth aspect of the embodiments of the present application provides a computer storage medium, where the computer storage medium is used for storing computer software instructions used by the above server, and the computer storage medium includes a program for executing a program designed for the server;
该服务器可以如前述第二方面所描述的打印日志的装置。The server may be the device for printing a log described in the aforementioned second aspect.
本申请实施例第六方面提供了一种计算机程序产品,该计算机程序产品包括计算机软件指令,该计算机软件指令可通过处理器进行加载来实现上述第一方面中任意一种实施方式所述的打印日志的方法。A sixth aspect of the embodiments of the present application provides a computer program product, where the computer program product includes computer software instructions, and the computer software instructions can be loaded by a processor to implement the printing described in any one of the implementation manners of the first aspect above method of logging.
本申请实施例第七方面提供了一种业务系统,包括目标调用链,目标调用链中包含第一业务模块;第一业务模块用于执行如上述第一方面中任意一种实施方式的打印日志的方法。A seventh aspect of the embodiments of the present application provides a business system, including a target invocation chain, where the target invocation chain includes a first business module; the first business module is configured to execute the print log according to any one of the implementations of the first aspect above Methods.
在一种实现方式下,目标调用链中还包括第四业务模块,业务系统还包括日志管理模块;目标调用链用于处理客户端发送的特定类型业务请求,特定类型业务请求包括第一业务请求和第二业务请求;第一网络请求是第一业务模块在目标调用链处理第一业务请求的过程中接收到的。In an implementation manner, the target call chain further includes a fourth service module, and the service system further includes a log management module; the target call chain is used to process a specific type of service request sent by the client, and the specific type of service request includes the first service request and the second service request; the first network request is received by the first service module in the process of processing the first service request by the target call chain.
日志管理模块用于,获取在目标调用链处理第一业务请求的过程中,目标调用链中业务模块打印的日志;且基于目标调用链中业务模块打印的日志中未包含第四业务模块打印的日志,获取第四业务模块在目标调用链处理第二业务请求的过程中打印的日志,以对目标调用链处理第一业务请求的过程进行分析,第四业务模块在目标调用链处理第二业务请求的过程中打印的日志指示,在目标调用链处理第二业务请求的过程中目标调用链中不存在运行错误的业务模块。The log management module is used to obtain the log printed by the business module in the target call chain in the process of processing the first service request by the target call chain; and the log printed by the business module in the target call chain does not include the log printed by the fourth business module. log, to obtain the log printed by the fourth service module in the process of processing the second service request by the target invocation chain, to analyze the process of processing the first service request by the target invocation chain, and the fourth service module in the target invocation chain to process the second service The log printed in the process of the request indicates that there is no service module with an operation error in the target call chain in the process of processing the second service request by the target call chain.
采用第四业务模块在目标调用链处理第二业务请求的过程中打印的正确日志,对目标调用链处理第一业务请求的过程进行分析,以避免在对目标调用链处理第一业务请求的过程进行分析时,误认为在目标调用链处理第一业务请求的过程中,第四业务模块运行错误,从而提高日志分析的准确度。Use the correct log printed by the fourth service module in the process of processing the second service request by the target call chain to analyze the process of processing the first service request by the target call chain, so as to avoid the process of processing the first service request by the target call chain During the analysis, it is mistakenly believed that the fourth service module runs in error during the process of processing the first service request by the target call chain, thereby improving the accuracy of log analysis.
在一种实现方式下,在目标调用链已处理的特定类型业务请求的所有业务请求中,第二业务请求的请求时间早于且最接近第一业务请求的请求时间。In an implementation manner, among all the service requests of the specific type of service requests processed by the target call chain, the request time of the second service request is earlier than and closest to the request time of the first service request.
在目标调用链已处理的特定类型业务请求的所有业务请求中,第二业务请求的请求时间早于且最接近第一业务请求的请求时间,使得日志管理模块获取到的正确日志更接近于,第四业务模块在目标调用链处理第一业务请求的过程中打印的正确日志,从而提高分析目标调用链处理第一业务请求的过程的准确性,避免日志管理模块选择的正确日志与第四业务模块在目标调用链处理第一业务请求的过程中打印的正确日志相差较大,而影响对目标调用链处理第一业务请求的过程的分析。Among all the service requests of the specific type of service requests processed by the target call chain, the request time of the second service request is earlier than and closest to the request time of the first service request, so that the correct log obtained by the log management module is closer to, The fourth business module prints the correct log in the process of processing the first business request by the target call chain, thereby improving the accuracy of analyzing the process of the target call chain processing the first business request, and avoiding the correct log selected by the log management module and the fourth business request. The correct log printed by the module during the process of processing the first service request by the target call chain is quite different, which affects the analysis of the process of the target call chain processing the first service request.
附图说明Description of drawings
图1为本申请实施例中业务系统的架构示意图;1 is a schematic diagram of the architecture of a business system in an embodiment of the application;
图2为本申请实施例中调用链处理特定类网络请求的过程示意图;2 is a schematic diagram of a process of processing a specific type of network request by a call chain in an embodiment of the application;
图3(a)为本申请实施例中打印日志的方法的一个实施例示意图;3(a) is a schematic diagram of an embodiment of a method for printing a log in an embodiment of the present application;
图3(b)为本申请实施例中打印日志的方法的另一个实施例示意图;FIG. 3(b) is a schematic diagram of another embodiment of the method for printing a log in an embodiment of the present application;
图4为本申请实施例中第一业务模块处理第一网络请求的一个实施例示意图;FIG. 4 is a schematic diagram of an embodiment of processing a first network request by a first service module in an embodiment of the present application;
图5为本申请实施例中第一业务模块处理第一网络请求的另一个实施例示意图;5 is a schematic diagram of another embodiment of processing a first network request by a first service module in an embodiment of the present application;
图6为本申请实施例中集成有Tracer单元的第一业务模块的实施例示意图;6 is a schematic diagram of an embodiment of a first service module integrated with a Tracer unit in an embodiment of the application;
图7为本申请实施例提供的一种打印日志的装置的一个实施例示意图;7 is a schematic diagram of an embodiment of an apparatus for printing a log provided by an embodiment of the present application;
图8为本申请实施例中服务器的结构示意图;8 is a schematic structural diagram of a server in an embodiment of the present application;
图9为本申请实施例提供的一种业务系统的实施例示意图。FIG. 9 is a schematic diagram of an embodiment of a service system provided by an embodiment of the present application.
具体实施方式detailed description
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行详细描述。The technical solutions in the embodiments of the present application will be described in detail below with reference to the accompanying drawings in the embodiments of the present application.
本申请实施例提供了一种打印日志的方法、装置及系统,用于控制日志的打印,从而减少日志的打印数量,以避免打印日志而占用大量的资源。Embodiments of the present application provide a method, device, and system for printing logs, which are used to control the printing of logs, thereby reducing the number of logs to be printed, so as to avoid printing logs and occupying a large amount of resources.
本申请实施例可以应用于包括至少一个服务器的业务系统。每个服务器上可以部署至少一个业务模块。当需要在一个服务器上部署有多个业务模块时,可以在该服务器上部署多个虚拟机,每个虚拟机中安装有一个操作系统,该虚拟机又可以称为节点,然后在每个节点中部署一个或多个业务模块。The embodiments of the present application may be applied to a service system including at least one server. At least one business module can be deployed on each server. When multiple business modules need to be deployed on a server, multiple virtual machines can be deployed on the server, each virtual machine is installed with an operating system, the virtual machine can also be called a node, and then on each node Deploy one or more business modules in .
例如,请参阅图1,本申请实施例中业务系统的架构示意图。图1中的业务系统包括三个服务器,其中一个服务器上部署有一个业务模块A,一个服务器上部署有业务模块B和业务模块C,另一个服务器上部署有业务模块D和业务模块E;这5个业务模块构成一条调用链,用于处理来自客户端(例如可以是浏览器)的网络请求。For example, please refer to FIG. 1 , which is a schematic diagram of the architecture of a business system in an embodiment of the present application. The business system in Figure 1 includes three servers, one of which is deployed with a business module A, one server is deployed with business module B and business module C, and the other server is deployed with business module D and business module E; this is Five business modules form a call chain for processing network requests from clients (for example, browsers).
通常情况下,不同的调用链用于处理来自客户端的不同类型的网络请求,来自客户端的网络请求具体可以叫做业务请求,所以也可以理解为,每条调用链用于处理来自客户端的特定类型业务请求。本申请实施例对特定类型业务请求不做具体限定,例如具体可以是登录请求、支付请求或者账户查询请求等等。Usually, different call chains are used to process different types of network requests from clients, and network requests from clients can be specifically called service requests, so it can also be understood that each call chain is used to process specific types of services from clients ask. This embodiment of the present application does not specifically limit a specific type of service request, for example, it may be a login request, a payment request, or an account query request, and the like.
下面结合图2对调用链处理特定类型业务请求的过程进行说明。如图2所示,用户在客户端上操作,触发客户端向图1中的业务系统发送登录请求,其中该登录请求被业务模块A接收到;业务模块A向业务模块B发送登录认证请求;业务模块B在接收到登录认证请求后,向业务模块C发送认证请求;业务模块C在接收到认证请求后,向业务模块D发送获取用户信息的请求;业务模块D在接收到获取用户信息的请求后,向业务模块E发送获取用户信息的请求。The following describes the process of the call chain processing a specific type of service request with reference to FIG. 2 . As shown in Figure 2, the user operates on the client, triggering the client to send a login request to the business system in Figure 1, wherein the login request is received by the business module A; the business module A sends a login authentication request to the business module B; After receiving the login authentication request, the service module B sends an authentication request to the service module C; after receiving the authentication request, the service module C sends a request for obtaining user information to the service module D; the service module D receives the request for obtaining user information. After the request is made, a request for obtaining user information is sent to the service module E.
业务模块E在接收到获取用户信息的请求后,向业务模块D发送对于网络获取用户信息的请求的网络响应;业务模块D在接收到来自业务模块E的网络响应后,向业务模块C发送获取用户信息的请求的网络响应;业务模块C在接收到来自业务模块D的网络响应后,向业务模块B发送认证请求的网络响应;业务模块B在接收到业务模块C发送的网络响应后,向业务模块A发送对于登录认证请求的网络响应;最终,业务模块A在接收到来自业务模块B的网络响应后,向客户端发送对于登录请求的网络响应。After the service module E receives the request for obtaining user information, it sends a network response to the request for obtaining user information from the network to the service module D; after the service module D receives the network response from the service module E, it sends the service module C to obtain The network response to the request for user information; after receiving the network response from the service module D, the service module C sends a network response to the authentication request to the service module B; after receiving the network response sent by the service module C, the service module B sends the The service module A sends a network response to the login authentication request; finally, after receiving the network response from the service module B, the service module A sends a network response to the login request to the client.
可以理解的是,图2所示的调用链仅包含A-E这样5个业务模块,且这5个业务模块间的调用关系较为简单。其中,一个业务模块向另一个业务模块发送网络请求,并接收来自该另一个业务模块的对于该网络请求的网络响应的过程,称为业务模块的调用过程,而这两个业务模块之间的关系则称为调用关系。而在实际应用中,调用链中包含的业务模块的数量较多,并且调用关系可能较为复杂。例如,业务模块B在接收到业务模块A的登录认证请求后,除了调用业务模块C外,还可以调用其他业务模块。即一个业务模块可以与多个业务模块之间存在调用关系。It can be understood that the call chain shown in FIG. 2 only includes five business modules such as A-E, and the calling relationship between these five business modules is relatively simple. The process in which one service module sends a network request to another service module and receives a network response to the network request from the other service module is called the calling process of the service module. Relationships are called invocation relationships. In practical applications, the number of business modules included in the call chain is large, and the call relationship may be complicated. For example, after receiving the login authentication request from the business module A, the business module B can call other business modules in addition to the business module C. That is, a business module can have a calling relationship with multiple business modules.
因此,为了更准确地定位调用链出现问题的业务模块,则需要业务模块在被调用的过 程中打印各自的日志,最终通过分析调用链中各业务模块打印的日志,来定位出现问题的业务模块。Therefore, in order to more accurately locate the business module with problems in the call chain, it is necessary for the business modules to print their own logs during the calling process, and finally locate the problematic business module by analyzing the logs printed by each business module in the call chain. .
下面对业务模块打印日志的过程进行说明。打印日志是指业务模块将内存中记录的业务模块操作的数据保存至存储器中。打印日志包括打印入口日志和打印出口日志,具体地,业务模块打印入口日志是指业务模块将接收到的网络请求中的数据保存到存储器中;业务模块打印出口日志是指业务模块将发送的网络响应中的数据保存到存储器中。The following describes the process of printing the log by the service module. Printing the log means that the service module saves the operation data of the service module recorded in the memory to the memory. The print log includes the print entry log and the print exit log. Specifically, the business module printing the entry log means that the business module saves the data in the received network request to the memory; the business module prints the exit log means that the business module will send the network request. The data in the response is saved to memory.
其中,网络请求中的数据可以包括追踪标识TraceId、接收到网络请求的时间以及网络响应标识等;同样地,网络响应中的数据也可以包括追踪标识TraceId、接收到网络响应的时间以及网络响应标识等。Wherein, the data in the network request may include the trace identifier TraceId, the time when the network request was received, and the network response identifier, etc.; similarly, the data in the network response may also include the trace identifier TraceId, the time when the network response was received, and the network response identifier. Wait.
其中,TraceId是全局唯一的,用于标记客户端发出的每个网络请求,客户端发出的每个网络请求中都携带有不同的TraceId。例如,在图2所示的调用链中,业务模块A接收到来自客户端的多个网络请求,则每个网络请求中包含的TraceId都不同。并且,业务模块A在接收到网络请求后,会将网络请求中的TraceId添加至发送给业务模块B的网络请求中,而业务模块B也会在向业务模块A发送的网络响应中添加该TraceId。The TraceId is globally unique and is used to mark each network request sent by the client, and each network request sent by the client carries a different TraceId. For example, in the call chain shown in FIG. 2 , the service module A receives multiple network requests from the client, and the TraceId contained in each network request is different. In addition, after receiving the network request, business module A will add the TraceId in the network request to the network request sent to business module B, and business module B will also add the TraceId to the network response sent to business module A. .
因此,若客户端发出一个特定类型业务请求,则在调用链处理该特定类型业务请求的过程中,调用链中每个业务模块发送的网络请求、接收的网络请求、发送的网络响应以及接收的网络响应中都会携带用于标记特定类型业务请求的TraceId。Therefore, if the client sends a specific type of service request, in the process of processing the specific type of service request in the call chain, the network request sent by each service module in the call chain, the received network request, the sent network response and the received The network response will carry the TraceId used to mark a specific type of service request.
网络响应标识用于表示网络请求当前的状态,例如,若网络响应标识取值为200,则表示该网络请求当前的状态为成功;若网络响应标识取值为404,则表示该网络请求当前的状态为无网络响应。The network response identifier is used to indicate the current status of the network request. For example, if the value of the network response identifier is 200, it indicates that the current status of the network request is successful; if the value of the network response identifier is 404, it indicates that the current status of the network request is successful. The status is no network response.
可以理解的是,对于某一调用链,往往需要处理大量的特定类型业务请求,所以若对于每个特定类型业务请求,调用链中的各个业务模块均打印日志(包括入口日志和出口日志),那么调用链中的业务模块必然会打印大量的日志,从而会占用大量的内存、输入/输出(Input/Output,I/O)以及中央处理器(Central Processing Unit,CPU)等资源。It is understandable that for a certain call chain, it is often necessary to process a large number of specific types of business requests, so for each specific type of business request, each business module in the call chain prints logs (including entry logs and exit logs), Then the business modules in the call chain will inevitably print a lot of logs, which will occupy a lot of resources such as memory, Input/Output (I/O), and Central Processing Unit (CPU).
为此,本申请实施例提供了一种打印日志的方法,该方法能够识别出调用链中存在运行错误的业务模块这一情况,并在调用链中存在运行错误的业务模块的情况下打印日志,这样既不影响对出现问题的业务模块的定位,又能实现对日志打印的控制,从而可以减少日志打印数量,降低日志打印对资源的占用。To this end, an embodiment of the present application provides a method for printing logs, the method can identify the situation that there is a business module with an operating error in the call chain, and print the log when there is a business module with an operating error in the calling chain In this way, it does not affect the positioning of the business module in which the problem occurs, but also realizes the control of the log printing, thereby reducing the number of log printing and the resource occupation of the log printing.
具体地,请参阅图3(a),本申请实施例中打印日志的方法的实施例示意图。如图3(a)所示,本申请实施例提供了一种打印日志的方法的一个实施例,包括:Specifically, please refer to FIG. 3( a ), which is a schematic diagram of an embodiment of a method for printing a log in an embodiment of the present application. As shown in FIG. 3( a ), an embodiment of the present application provides an embodiment of a method for printing a log, including:
步骤101,第一业务模块接收第一网络请求,第一网络请求用于调用第一业务模块。Step 101, the first service module receives a first network request, and the first network request is used to invoke the first service module.
可以理解的是,调用链中的每个业务模块在被调用时,都会接收到网络请求;例如,图2所示的调用链中的各个业务模块都会接收到网络请求。It can be understood that each business module in the call chain will receive a network request when it is called; for example, each business module in the call chain shown in Figure 2 will receive a network request.
作为目标调用链包含的多个业务模块中的一个,第一业务模块在被调用的过程中同样会接收到第一网络请求,该第一网络请求可以来自于客户端,也可以来自于目标调用链中的其他业务模块;以图2所示的调用链为例,当第一业务模块为业务模块A时,第一网络请求则来自于客户端;当第一业务模块为业务模块B时,第一网络请求则来自于业务模块 A。As one of the multiple service modules included in the target call chain, the first service module will also receive a first network request during the process of being called. The first network request may come from the client or the target call other business modules in the chain; taking the call chain shown in Figure 2 as an example, when the first business module is business module A, the first network request comes from the client; when the first business module is business module B, The first network request comes from service module A.
基于前述说明可知,第一网络请求可以包括追踪标识TraceId、接收到网络请求的时间以及网络响应标识等。Based on the foregoing description, the first network request may include the trace identifier TraceId, the time when the network request was received, the network response identifier, and the like.
步骤102,基于第一业务模块在处理第一网络请求的过程中运行错误,或基于第一业务模块接收的来自第二业务模块的第一网络响应中携带有错误标识,第一业务模块打印日志。Step 102, the first service module prints a log based on an error in the operation of the first service module in the process of processing the first network request, or based on the fact that the first network response from the second service module received by the first service module carries an error identifier .
其中,第一网络响应是对于第二网络请求的,第二网络请求是第一业务模块处理第一网络请求的过程中为调用第二业务模块而发送的,第一业务模块和第二业务模块属于目标调用链,错误标识指示目标调用链中存在运行错误的业务模块。The first network response is for the second network request, and the second network request is sent by the first service module for invoking the second service module in the process of processing the first network request. The first service module and the second service module It belongs to the target call chain, and the error flag indicates that there is a business module running wrong in the target call chain.
需要说明的是,第一业务模块处理第一网络请求的过程包括两种情况,下面结合图4和图5对这两种情况进行介绍。It should be noted that, the process of processing the first network request by the first service module includes two cases, and the two cases are described below with reference to FIG. 4 and FIG. 5 .
第一种情况:如图4所示,第一业务模块在接收到第一网络请求后先进行第一次内部运行,经过第一次内部运行后,第一业务模块向第二业务模块发送第二网络请求,第二网络请求用于调用第二业务模块;此后,第一业务模块会接收来自第二业务模块的第一网络响应,第一网络响应指示调用第二业务模块的结果。在接收到第一网络响应后,第一业务模块可以进行第二次内部运行(例如可以对第一网络响应进行处理),经过第二次内部运行后,第一业务模块向第二业务模块发送对于第一网络请求的第二响应。Case 1: As shown in Figure 4, the first service module first performs the first internal operation after receiving the first network request. After the first internal operation, the first service module sends the second service module to the second service module. Two network requests, the second network request is used to call the second service module; after that, the first service module will receive the first network response from the second service module, and the first network response indicates the result of calling the second service module. After receiving the first network response, the first service module may perform a second internal operation (for example, may process the first network response), and after the second internal operation, the first service module sends a message to the second service module. A second response to the first network request.
其中,若第一业务模块为图2所示的调用链中的业务模块A、业务模块B、业务模块C和业务模块D中的一个,则第一业务模块处理第一网络请求的过程属于上述第一种情况。Wherein, if the first service module is one of service module A, service module B, service module C, and service module D in the call chain shown in FIG. 2 , the process of processing the first network request by the first service module belongs to the above-mentioned process. The first case.
在上述第一种情况下,若第一业务模块第一次运行错误或第一网络请求中携带有错误标识,此时的错误标识具体表示目标调用链中先于第一业务模块被调用的业务模块中存在运行错误的业务模块,第一业务模块会在第二网络请求中添加错误标识;同样地,若第二业务模块在接收到第一网络请求后第一次运行错误,或第二业务模块接收到的第二网络请求中携带有错误标识,则第二业务模块也会在向其他业务模块发送的网络请求中添加错误标识。例如,若业务模块B接收到的来自业务模块A的网络请求中携带有错误标识,则表示业务模块A运行错误;若业务模块C接收到的来自业务模块B的网络请求中携带有错误标识,则表示业务模块B运行错误或业务模块A运行错误。In the above-mentioned first case, if the first service module runs incorrectly for the first time or the first network request carries an error identifier, the error identifier at this time specifically represents the service invoked prior to the first service module in the target call chain There is a business module with an error in the module, and the first business module will add an error flag to the second network request; similarly, if the second business module runs wrong for the first time after receiving the first network request, or the second business If the second network request received by the module carries an error identifier, the second service module will also add the error identifier to the network requests sent to other service modules. For example, if the network request from service module A received by service module B carries an error identifier, it means that service module A is running in error; if the network request from service module B received by service module C carries an error identifier, It means that business module B is running incorrectly or business module A is running incorrectly.
在上述第一种情况下,第一业务模块可以在运行错误时打印日志,也可以在接收到的第一网络响应种携带有错误标识的情况下打印日志。其中,第一业务模块运行错误包括第一业务模块在接收到第一网络请求后第一次内部运行错误,也包括在接收到第一网络响应后第二次内部运行错误。In the above-mentioned first case, the first service module may print a log when there is an operation error, and may also print a log when the received first network response carries an error identifier. Wherein, the operation error of the first service module includes the first internal operation error of the first service module after receiving the first network request, and also includes the second internal operation error after receiving the first network response.
第二种情况:如图5所示,第一业务模块在接收到第一网络请求后内部运行,经过内部运行后,第一业务模块发送对于第一网络请求的第二响应,即第一业务模块未调用目标调用链中的业务模块。The second case: as shown in Figure 5, the first service module runs internally after receiving the first network request, and after the internal operation, the first service module sends a second response to the first network request, that is, the first service The module did not call the business module in the target call chain.
第二种情况也存在至少两个应用场景。其中一个应用场景可以是,第一业务模块为调用链中的最后一个业务模块,所以第一业务模块不需调用其他业务模块即可完成对第一网络请求的处理,例如,第一业务模块可以为图2所示的调用链中的业务模块E。另一个应 用场景可以是,第一业务模块内部运行错误或第一网络请求中携带错误标识,此时,第一业务模块无需调用其他业务模块,便直接发送对于第一网络请求的第二响应,以指示发送第一网络请求的客户端或业务模块目标调用链中存在运行错误的业务模块。There are also at least two application scenarios for the second case. One of the application scenarios may be that the first business module is the last business module in the calling chain, so the first business module can complete the processing of the first network request without calling other business modules. For example, the first business module may is the business module E in the call chain shown in FIG. 2 . Another application scenario may be that the first service module has an internal operation error or the first network request carries an error identifier. In this case, the first service module directly sends the second response to the first network request without calling other service modules. In order to indicate that there is a service module with running error in the target call chain of the client or service module that sends the first network request.
其中,若第一网络请求中携带错误标识,则表示第一网络请求中的数据存在错误,通常会导致第一业务模块内部运行错误,因此本申请实施例将第一网络请求中携带有错误标识的情况作为第一业务模块内部运行错误的一种特殊情况。Wherein, if the first network request carries an error identifier, it means that there is an error in the data in the first network request, which usually leads to an internal operation error of the first service module. Therefore, in this embodiment of the present application, the first network request carries an error identifier. The situation is a special case of the internal operation error of the first business module.
基于此,在上述第二种情况下,第一业务模块可以在运行错误时打印日志。其中,第一业务模块运行错误包括第一业务模块在接收到第一网络请求后内部运行错误。Based on this, in the second case above, the first service module may print a log when there is an error in operation. The operation error of the first service module includes an internal operation error of the first service module after receiving the first network request.
错误标识的形式可以有多种,本申请实施例对此不做具体限定。例如,可以在第一响应中添加一个新的字段,当该字段用于表示目标调用链中是否存在运行错误的业务模块;具体地,当该字段的值为true时,则表示目标调用链中存在运行错误的业务模块,当该字段的值为false时,则表示目标调用链中不存在运行错误的业务模块。There may be various forms of the error identification, which are not specifically limited in this embodiment of the present application. For example, a new field can be added to the first response, when this field is used to indicate whether there is a business module with an operation error in the target call chain; specifically, when the value of this field is true, it indicates that the target call chain is in There is a business module with an operating error. When the value of this field is false, it means that there is no business module with an operating error in the target call chain.
在本申请实施例中,识别目标调用链中存在运行错误的业务模块的情况下,打印日志,能够起到控制日志打印的作用,从而减少日志的打印数量,以避免打印日志而占用大量的资源;也不会因盲目减少日志打印数量而影响对出问题的业务模块的定位。In the embodiment of the present application, in the case of identifying a business module with an operating error in the target call chain, printing the log can play a role in controlling the printing of the log, thereby reducing the number of logs to be printed, so as to avoid printing the log and occupying a lot of resources ; It will not affect the location of the faulty business module due to blindly reducing the number of log prints.
可以理解的是,若某种原因导致目标调用链中某一业务模块运行错误,那么在一段时间该业务模块可能因该原因持续运行错误,所以在该段时间内,目标调用链中的各个业务模块都会持续打印日志;由于在该段时间内,导致业务模块运行错误的原因相同,所以仅通过一定量的日志便可以定位出现问题的业务模块,并确定业务模块运行错误的原因。It is understandable that if a certain business module in the target call chain runs incorrectly for some reason, the business module may continue to run incorrectly due to this reason for a period of time. The modules will continue to print logs; since the reasons for the errors in the operation of the business modules are the same during this period of time, only a certain amount of logs can be used to locate the business modules with problems and determine the reasons for the errors in the operation of the business modules.
因此,本申请实施例对第一业务模块在目标调用链中存在运行错误的业务模块的情况下打印的日志数量进行控制。作为一种可选的方式,预设第一周期内,第一业务模块在目标调用链中存在运行错误的业务模块的情况下,打印的日志数量小于第一预设数量。Therefore, the embodiment of the present application controls the number of logs printed by the first service module when there is a service module with an operating error in the target call chain. As an optional method, in the preset first cycle, when the first service module has a service module with an operating error in the target call chain, the number of logs printed is less than the first preset number.
其中,第一周期可以根据实际需要进行设定,例如可以为一分钟;第一预设数量也可以根据实际需要进行设定,例如可以设置为5、6、7和8等。The first period may be set according to actual needs, for example, one minute; the first preset number may also be set according to actual needs, for example, may be set to 5, 6, 7, and 8.
在本申请实施例中,控制第一业务模块在第一周期内,且在目标调用链中存在运行错误的业务模块的情况下打印的日志数量,从而防止在第一周期内,由于同一原因导致某一业务模块运行错误,以致于第一业务模块打印大量的日志;因此,本申请实施例能够在不对定位运行错误的业务模块造成影响的前提下,起到控制第一业务模块打印日志数量的作用。In the embodiment of the present application, the number of logs printed by the first business module in the first cycle and when there is a business module with an operating error in the target call chain is controlled, so as to prevent the first cycle from being caused by the same reason A certain business module runs incorrectly, so that the first business module prints a large number of logs; therefore, the embodiment of the present application can control the number of logs printed by the first business module without affecting the location of the wrong business module. effect.
需要说明的是,控制预设第一周期内第一业务模块打印的日志数量小于第一预设数量的方法有多种,本申请实施例对此不做具体限定。示例性地,在目标调用链中,由接收来自客户端的特定类型业务请求的业务模块对日志数量进行周期性地控制。具体地,在当前第一周期内,接收来自客户端的特定类型业务请求的业务模块在调用另一个业务模块的过程中,在向另一个业务模块发送的网络请求中添加剩余的错误日志数量;当该另一个业务模块需要调用其他业务模块时,也同样在发送给其他业务模块的网络请求中添加该剩余的错误日志数量,以此类推,目标调用链中的每个业务模块都会接收到剩余的错误日志数量。It should be noted that there are various methods for controlling the number of logs printed by the first service module in the preset first cycle to be less than the first preset number, which is not specifically limited in this embodiment of the present application. Exemplarily, in the target call chain, the number of logs is periodically controlled by a service module that receives a specific type of service request from a client. Specifically, in the current first cycle, the service module that receives the specific type of service request from the client adds the remaining number of error logs to the network request sent to the other service module in the process of calling another service module; when When the other business module needs to call other business modules, it also adds the remaining number of error logs to the network request sent to other business modules, and so on, each business module in the target call chain will receive the remaining number of error logs. Number of error logs.
在目标调用链中存在运行错误的业务模块的情况下,若剩余的错误日志数量大于0, 则目标调用链中的业务模块便可以打印日志。其中,在当前第一周期内,接收来自客户端的特定类型业务请求的业务模块,每接收到一个来自客户端的特定类型业务请求,便将剩余的错误日志数量减1,直至为0。在目标调用链中存在运行错误的业务模块的情况下,若剩余的错误日志数量等于0,则目标调用链中的业务模块不打印日志。In the case that there is a business module with an operating error in the target call chain, if the number of remaining error logs is greater than 0, the business module in the target call chain can print the log. Wherein, in the current first cycle, the service module that receives a specific type of service request from the client, every time it receives a specific type of service request from the client, decrements the remaining number of error logs by 1 until it becomes 0. In the case that there is a business module with an operating error in the target call chain, if the number of remaining error logs is equal to 0, the business module in the target call chain does not print the log.
在下一个第一周期到来时,接收来自客户端的特定类型业务请求的业务模块,会将剩余的错误日志数量更新为第一预设数量,从而实现对日志数量的周期性控制。When the next first cycle comes, the service module that receives the specific type of service request from the client will update the remaining number of error logs to the first preset number, thereby realizing periodic control of the number of logs.
以图2所示的调用链为例,业务模块A在接收到来自客户端的网络请求后,在向业务模块B发送的网络请求中添加剩余的错误日志数量,其中剩余的错误日志数量的初始值为第一预设数量,这里假设第一预设数量为5;相应地,业务模块B会接收到剩余的错误日志数量(为5),业务模块B可以根据该剩余的错误日志数量判断是否打印日志。具体地,在业务模块B运行错误或业务模块B接收到来自业务模块C的网络响应中携带有错误标识的情况下,由于剩余的错误日志数量为5,大于0,所以业务模块B打印日志。Taking the call chain shown in Figure 2 as an example, after receiving the network request from the client, service module A adds the remaining number of error logs to the network request sent to service module B, where the initial value of the remaining number of error logs is is the first preset number, and it is assumed here that the first preset number is 5; correspondingly, the service module B will receive the remaining number of error logs (5), and the service module B can determine whether to print according to the remaining number of error logs log. Specifically, when the service module B runs incorrectly or the service module B receives the network response from the service module C with an error identifier, since the number of remaining error logs is 5, which is greater than 0, the service module B prints the log.
同样地,在业务模块B调用业务模块C的过程中,业务模块B会在向业务模块C发送的网络请求中添加剩余的错误日志数量(为5),以使得业务模块C根据剩余的错误日志数量判断是否打印日志。其中,业务模块C判断是否打印日志的方法与业务模块B相同,具体可参阅前述业务模块B的判断过程进行理解。Similarly, when business module B calls business module C, business module B will add the remaining number of error logs (5) to the network request sent to business module C, so that business module C can Quantity determines whether to print the log. The method for the business module C to determine whether to print the log is the same as that for the business module B. For details, please refer to the aforementioned judgment process of the business module B for understanding.
业务模块A再次接收到来自客户端的网络请求后,则在向业务模块B发送的网络请求中添加的剩余的错误日志数量则会变为4。随着业务模块A接收到的来自客户端的网络请求的数量的增多,添加的剩余的错误日志数量则会依次减少。当剩余的错误日志数量减少至0时,即使业务模块B运行错误或业务模块B接收到来自业务模块C的网络响应中携带有错误标识,业务模块B也不打印日志。After the service module A receives the network request from the client again, the remaining number of error logs added to the network request sent to the service module B will become 4. As the number of network requests received from the client by the service module A increases, the number of remaining error logs added will decrease sequentially. When the number of remaining error logs is reduced to 0, even if the service module B runs incorrectly or the service module B receives an error identifier in the network response from the service module C, the service module B does not print the log.
业务模块A每隔一分钟(即更新剩余的错误日志数量的周期)则会将剩余的错误日志数量更新为第一预设数量。The service module A updates the remaining number of error logs to the first preset number every one minute (ie, the period for updating the remaining number of error logs).
基于前述说明可知,第一业务模块打印日志包括打印入口日志和打印出口日志,下面对打印日志的过程进行说明。Based on the foregoing description, it can be known that the first service module print log includes print entry log and print exit log, and the process of print log will be described below.
如图3(a)所示,在本申请实施例提供的打印日志的方法的另一个实施例中,在第一业务模块接收第一网络请求之后,方法还包括:As shown in FIG. 3( a ), in another embodiment of the method for printing a log provided by the embodiment of the present application, after the first service module receives the first network request, the method further includes:
步骤103,第一业务模块保存第一网络请求中的数据至内存。Step 103, the first service module saves the data in the first network request to the memory.
其中,步骤103是在执行步骤101之后执行。若第一业务模块向第二业务模块发送第二网络请求,则步骤103是在第一业务模块发送第二网络请求之前执行。Wherein, step 103 is executed after step 101 is executed. If the first service module sends the second network request to the second service module, step 103 is performed before the first service module sends the second network request.
在本申请实施例中,第一业务模块在接收到第一网络请求后,会将第一网络请求中的数据保存至内存,以防止第一网络请求中的数据被清除。In the embodiment of the present application, after receiving the first network request, the first service module will save the data in the first network request to the memory, so as to prevent the data in the first network request from being cleared.
其中,在将第一网络请求中的数据保存至内存前,可以先对第一网络请求中的数据进行整理,本申请实施例对第一网络请求中的数据的整理方法不做具体限定。Before saving the data in the first network request to the memory, the data in the first network request may be sorted first, and the embodiment of the present application does not specifically limit the sorting method of the data in the first network request.
步骤104,第一业务模块发送对于第一网络请求的第二网络响应,第二网络响应指示调用第一业务模块的结果。Step 104, the first service module sends a second network response to the first network request, and the second network response indicates the result of calling the first service module.
其中,步骤104是在执行完步骤102后执行。Wherein, step 104 is executed after step 102 is executed.
基于前述说明可知,第一业务模块在接收到第一网络请求后,可以通过内部运行对第一网络请求进行处理,根据处理的结果发送第二网络响应;第一业务模块也可以先进行第一次内部运行,然后向第二业务模块发送第二网络请求,并接收来自第二业务模块的第一网络响应,并根据第一网络响应进行第二次内部运行,以完成对第一网络请求的处理,最后根据处理的结果发送第二网络响应。Based on the foregoing description, after receiving the first network request, the first service module can process the first network request through internal operation, and send the second network response according to the processing result; the first service module can also perform the first The second internal operation is performed, and then the second network request is sent to the second service module, and the first network response from the second service module is received, and the second internal operation is performed according to the first network response to complete the response to the first network request. processing, and finally sending a second network response according to the processing result.
可以理解的是,若第一网络请求来自于客户端,则第一业务模块则向客户端发送第二网络响应;若第一网络请求来自于其他业务模块,则第一业务模块则向其他业务模块发送第二网络响应。It can be understood that, if the first network request comes from the client, the first service module sends a second network response to the client; if the first network request comes from other service modules, the first service module sends other services to the client. The module sends a second network response.
基于上述过程步骤102中,第一业务模块打印日志可以包括:Based on the above process step 102, the printing log of the first service module may include:
第一业务模块根据保存的第一网络请求中的数据打印入口日志。The first service module prints the entry log according to the stored data in the first network request.
其中,打印入口日志包括将保存的第一网络请求中的数据输出到存储器。Wherein, printing the entry log includes outputting the saved data in the first network request to the memory.
第一业务模块根据第二网络响应中的数据打印出口日志。The first service module prints the exit log according to the data in the second network response.
其中,打印出口日志包括将保存的第二网络响应中的数据输出到存储器。Wherein, printing the export log includes outputting the saved data in the second network response to the memory.
需要说明的是,打印入口日志和打印出口日志之间无先后顺序。It should be noted that there is no sequence between printing the entry log and printing the exit log.
在现有的打印日志的方法中,业务模块在接收到网络请求后,便打印入口日志,并在打印入口日志后向下一个业务模块发送网络请求以对下一个业务模块进行调用,此后,网络请求中的数据便会从内存中被清除。而在本申请实施例中,第一业务模块在接收到第一网络请求后,先不打印日志,而是将第一网络请求中的数据保存至内存;若第一业务模块在处理第一网络请求的过程中运行错误,或第一网络响应中携带有错误标识,第一业务模块才会根据保存的第一网络请求中的数据打印入口日志。In the existing method of printing logs, the business module prints the entry log after receiving the network request, and after printing the entry log, sends a network request to the next business module to call the next business module, after that, the network The data in the request is cleared from memory. In the embodiment of the present application, after receiving the first network request, the first service module does not print the log, but saves the data in the first network request to the memory; if the first service module is processing the first network If there is an error in the operation of the request, or the first network response carries an error identifier, the first service module will print the entry log according to the stored data in the first network request.
相比现有的打印日志的方法,在本申请实施例中,第一业务模块不是在向第二业务模块发送第二网络请求后清除第一网络请求中的数据,而是在打印入口日志和出口日志后,将内存中第一网络请求中的数据和第二网络响应中的数据清除。Compared with the existing method of printing logs, in this embodiment of the present application, the first service module does not clear the data in the first network request after sending the second network request to the second service module, but prints the entry log and the data in the first network request. After the log is exported, the data in the first network request and the data in the second network response in the memory are cleared.
在本申请实施例中,第一业务模块在接收到第一网络请求后,先不打印日志,而是将第一网络请求中的数据保存至内存;当第一业务模块在处理第一网络请求的过程中运行错误,或第一网络响应中携带有错误标识时,第一业务模块根据保存的第一网络请求中的数据打印入口日志,从而避免在未确定目标调用链中存在运行错误的业务模块的情况下打印入口日志,造成资源浪费。In the embodiment of the present application, after receiving the first network request, the first service module does not print the log first, but saves the data in the first network request to the memory; when the first service module is processing the first network request When there is an error in the operation of the process, or the first network response carries an error identifier, the first service module prints the entry log according to the data in the saved first network request, so as to avoid the operation error in the undetermined target call chain. In the case of a module, the entry log is printed, resulting in a waste of resources.
基于前述说明可知,第一网络请求可以来自于业务模块,也可以来自于客户端。下面对第一网络请求来自于业务模块的情况进行说明。Based on the foregoing description, it can be known that the first network request may come from a service module or a client. The following describes the case where the first network request comes from the service module.
在本申请实施例提供的打印日志的方法的另一个实施例中,第一网络请求来自于第三业务模块,第三业务模块属于目标调用链;第一业务模块发送对于第一网络请求的第二网络响应包括:In another embodiment of the method for printing a log provided by the embodiment of the present application, the first network request comes from a third service module, and the third service module belongs to the target call chain; the first service module sends the first network request for the first network request. Two network responses include:
基于第一业务模块运行错误或第一网络响应中携带有错误标识,第一业务模块向第三业务模块发送对于第一网络请求的携带有错误标识的第二网络响应,以使得第三业务模块打印日志。Based on the operation error of the first service module or the error identifier carried in the first network response, the first service module sends the second network response carrying the error identifier to the first network request to the third service module, so that the third service module Print log.
可以理解的是,第三业务模块在接收到携带有错误标识的第二网络响应后,会打印日 志,其中,第三业务模块打印日志的过程与第一业务模块打印日志的过程相同,故在此不做赘述。It can be understood that the third business module will print a log after receiving the second network response carrying the error identifier, wherein the process of printing the log by the third business module is the same as the process of printing the log by the first business module, so the This will not be repeated.
上文对第一业务模块运行错误,或第一业务模块接收的第一网络响应中携带有错误标识的情况下,第一业务模块打印日志的过程进行了说明,下面对第一业务模块未运行错误且接收到的网络响应中未携带有错误标识的情况下,第一业务模块打印日志的过程进行说明。The process of printing the log by the first service module in the case of an error in the operation of the first service module or the first network response received by the first service module carries an error identifier has been described above. In the case of an operation error and the received network response does not carry an error identifier, the process of printing the log by the first service module will be described.
如图3(a)所示,基于前述各个实施例,在本申请实施例提供的打印日志的方法的另一个实施例中,该方法还包括:As shown in FIG. 3( a ), based on the foregoing embodiments, in another embodiment of the method for printing a log provided by the embodiment of the present application, the method further includes:
步骤105,第一业务模块接收第三网络请求,第三网络请求用于调用第一业务模块。Step 105, the first service module receives a third network request, and the third network request is used to invoke the first service module.
其中,步骤105是在执行完步骤104后执行。Wherein, step 105 is executed after step 104 is executed.
需要说明的是,第三网络请求与第一网络请求类似,具体可参照第一网络请求的相关说明对第三网络请求进行理解。It should be noted that the third network request is similar to the first network request, and specifically, the third network request may be understood by referring to the relevant description of the first network request.
其中,第一业务模块在接收到第三网络请求后,会将第三网络请求中的数据保存至内存。Wherein, after receiving the third network request, the first service module will save the data in the third network request to the memory.
步骤106,基于第一业务模块在处理第三网络请求的过程中未运行错误,且接收到第三网络响应中不包含错误标识,第一业务模块不打印日志。Step 106 , based on the fact that the first service module does not have an error in the process of processing the third network request, and the received third network response does not contain an error identifier, the first service module does not print a log.
由于第一业务模块未运行错误,且接收到的第三网络响应中不包含错误标识,则表示目标调用链中不存在运行错误的业务模块;为了控制日志的打印数量,这种情况下,第一业务模块不打印日志。Since the first business module does not run in error, and the received third network response does not contain an error identifier, it means that there is no business module with an error in the target call chain; in order to control the number of logs printed, in this case, the first A business module does not print logs.
第一业务模块在确定自身未运行错误,且接收到的第三网络响应中不包含错误标识后,可以清除保存的第三网络请求中的数据。The first service module may clear the stored data in the third network request after determining that it does not run in error and the received third network response does not contain an error identifier.
在本申请实施例中,在第一业务模块未运行错误,且接收到的第三网络响应中不包含错误标识的情况下,第一业务模块不打印日志,减少了日志打印数量,且不影响定位运行错误的业务模块;并且,由于多数时间内目标调用链中都不存在运行错误的业务模块,所以本申请实施例能够极大地减少日志的打印数量,明显降低打印日志对资源的占用。In the embodiment of the present application, when the first service module does not run in error, and the received third network response does not contain an error identifier, the first service module does not print the log, which reduces the number of log prints and does not affect the Locate service modules that run incorrectly; and because there is no service module that runs incorrectly in the target call chain most of the time, the embodiment of the present application can greatly reduce the number of logs printed, and significantly reduce the resource occupation of printing logs.
可以理解的是,在定位运行错误的业务模块的过程中,可能需要在目标调用链中不存在运行错误的业务模块的情况下打印的日志作为参照,因此在目标调用链中不存在运行错误的业务模块的情况下,也可以打印部分日志;但为了避免打印大量的日志而占用资源,可以控制日志的打印数量。It is understandable that in the process of locating the faulty business module, the log printed when there is no faulty business module in the target call chain may be used as a reference, so there is no running fault in the target call chain. In the case of the business module, some logs can also be printed; however, in order to avoid printing a large number of logs and occupying resources, the number of logs to be printed can be controlled.
下面结合图3(b)对第一业务模块在目标调用链中不存在运行错误的业务模块的情况下打印日志的过程进行介绍。具体地,作为一种可选的实现方式,该方法还包括:The following describes the process of printing the log by the first service module when there is no service module with an operating error in the target call chain with reference to FIG. 3(b). Specifically, as an optional implementation manner, the method further includes:
步骤107,第一业务模块接收第三网络请求,第三网络请求用于调用第一业务模块。Step 107, the first service module receives a third network request, and the third network request is used to invoke the first service module.
需要说明的是,第三网络请求与第一网络请求是在目标调用链处理同一类型的业务请求的过程中接收到的,例如,第一网络请求为携带有错误标识的登录请求,而第三网络请求为未携带错误标识的登录请求;由于第三网络请求与第一网络请求类似,所以可参照第一网络请求的相关说明对第三网络请求进行理解。It should be noted that the third network request and the first network request are received during the process of processing the same type of service request by the target call chain. For example, the first network request is a login request with an error The network request is a login request without an error identifier; since the third network request is similar to the first network request, the third network request can be understood by referring to the relevant description of the first network request.
步骤108,基于预设第二周期内,第一业务模块在处理第三网络请求的过程中未运行 错误,且接收到的第三网络响应中不包含错误标识的情况下,第一业务模块已打印的日志数量小于第二预设数量,第一业务模块打印日志。可以理解的是,在预设第二周期内,若在处理第三网络请求的过程中未运行错误,且接收到的第三网络响应中不包含错误标识的情况下,若第一业务模块已打印的日志数量等于第二预设数量,则会停止打印日志。Step 108, based on the preset second period, the first service module has no error in the process of processing the third network request, and the received third network response does not contain an error identifier, the first service module has been When the number of printed logs is less than the second preset number, the first service module prints the logs. It can be understood that, within the preset second period, if there is no error during the processing of the third network request, and the received third network response does not contain an error identifier, if the first service module has When the number of printed logs is equal to the second preset number, the printing of logs will be stopped.
在本申请实施例中,在目标调用链中不存在运行错误的业务模块的情况下,第一业务模块打印日志,但在预设第二周期内,第一业务模块在上述情况下打印的日志数量小于第二预设数量,从而可以控制日志的打印数量。In the embodiment of the present application, in the case where there is no business module with an operating error in the target call chain, the first business module prints the log, but within the preset second cycle, the first business module prints the log in the above situation The number is smaller than the second preset number, so that the printing number of the log can be controlled.
其中,控制第一业务模块打印的日志数量小于第二预设数量的方法,与控制第一业务模块打印的日志数量小于第一预设数量的方法相同,具体可参照前述对控制第一业务模块打印的日志数量小于第一预设数量的方法的说明进行理解。The method of controlling the number of logs printed by the first business module to be less than the second preset number is the same as the method of controlling the number of logs printed by the first business module to be less than the first preset number. The description of the method in which the number of printed logs is less than the first preset number should be understood.
第二周期也可以根据实际需要进行设定,例如也可以为一分钟;第二预设数量也可以根据实际需要进行设定,例如可以设置为1。The second period can also be set according to actual needs, for example, it can be one minute; the second preset number can also be set according to actual needs, for example, it can be set to 1.
需要说明的是,在目标调用链中不存在运行错误的业务模块的情况下,第一业务模块可以通过步骤105和步骤106对日志打印进行控制,也可以通过步骤107和步骤108对日志打印进行控制。It should be noted that, in the case where there is no business module with an operating error in the target call chain, the first business module can control the log printing through steps 105 and 106, or can perform log printing through steps 107 and 108. control.
基于前述说明可知,目标调用链用于处理客户端发送的特定类型业务请求,而该特定类型业务请求的数量可以为多个;作为一种可选的方式,目标调用链属于目标业务系统,且用于处理客户端发送的特定类型业务请求,目标业务系统还包括日志管理模块,特定类型业务请求包括第一业务请求和第二业务请求,目标调用链还包括第四业务模块。Based on the foregoing description, it can be seen that the target call chain is used to process a specific type of service request sent by the client, and the number of the specific type of service request can be multiple; as an optional method, the target call chain belongs to the target service system, and For processing the specific type of service request sent by the client, the target service system further includes a log management module, the specific type of service request includes a first service request and a second service request, and the target call chain further includes a fourth service module.
第一网络请求是第一业务模块在目标调用链处理第一业务请求的过程中接收到的;可以理解的,第一网络请求可以是来自客户端的第一业务请求,也可以是来自其他业务模块的网络请求。The first network request is received by the first service module in the process of processing the first service request by the target call chain; it is understandable that the first network request may be the first service request from the client, or may be from other service modules network request.
应理解,通常会根据在目标调用链处理第一业务请求的过程中,目标调用链中各个业务模块打印的日志,来对目标调用链处理第一业务请求的过程进行分析,以定位运行错误的业务模块。在分析前,需要先获取在目标调用链处理第一业务请求的过程中,目标调用链中各个业务模块打印的日志。It should be understood that the process of processing the first service request by the target call chain is usually analyzed according to the logs printed by each service module in the target call chain in the process of processing the first service request by the target call chain, so as to locate the wrong operation. business module. Before the analysis, it is necessary to obtain the logs printed by each service module in the target call chain during the process of processing the first service request by the target call chain.
基于前述说明可知,TraceId是全局唯一的,用于标记客户端发出的每个网络请求,而目标调用链中各个业务模块打印的日志中通常包含TraceId;因此,可以根据TraceId获取在目标调用链处理第一业务请求的过程中,目标调用链中各个业务模块打印的日志。Based on the above description, TraceId is globally unique and is used to mark each network request sent by the client, and the logs printed by each business module in the target call chain usually contain TraceId; therefore, it can be obtained according to TraceId and processed in the target call chain During the process of the first service request, the target calls the logs printed by each service module in the chain.
基于上述说明,本申请实施例中打印日志的方法还包括:Based on the above description, the method for printing a log in the embodiment of the present application further includes:
日志管理模块获取在目标调用链处理第一业务请求的过程中,目标调用链中业务模块打印的日志。The log management module acquires the log printed by the service module in the target call chain during the process of processing the first service request by the target call chain.
需要说明的是,日志管理模块获取目标调用链中各个业务模块打印的日志,以组成完整的目标调用链的日志,所以通常情况下,日志管理模块获取到的业务模块打印的日志会包含第一业务模块打印的日志以及第四业务模块打印的日志。然而,存在至少两种原因可能导致,目标调用链中业务模块打印的日志中未包含第四业务模块打印的日志。It should be noted that the log management module obtains the logs printed by each business module in the target call chain to form a complete log of the target call chain. Therefore, under normal circumstances, the logs printed by the business module obtained by the log management module will include the first log. The log printed by the business module and the log printed by the fourth business module. However, there are at least two reasons that may cause that the log printed by the fourth business module is not included in the log printed by the business module in the target call chain.
第一种原因是,在目标调用链处理第一业务请求的过程中,第四业务模块未被调用。 例如,以图2所示的调用链为例,若业务模块C运行错误,则业务模块C可能直接向业务模块B发送网络响应,而不向业务模块D发送网络请求;因此业务模块D和业务模块E都不会被调用,那么日志管理模块获取的目标调用链中业务模块打印的日志则包含业务模块C打印的日志,而不包含业务模块D和业务模块E印的日志。The first reason is that in the process of processing the first service request by the target call chain, the fourth service module is not called. For example, taking the call chain shown in Figure 2 as an example, if the service module C runs incorrectly, the service module C may directly send a network response to the service module B without sending a network request to the service module D; therefore, the service module D and the service module Module E will not be called, then the logs printed by the business modules in the target call chain obtained by the log management module include the logs printed by business module C, but not the logs printed by business modules D and E.
第二种原因是,在目标调用链处理第一业务请求的过程中,第四业务模块未运行错误且接收到的网络响应中不包含错误标识。例如,以图2所示的调用链为例,业务模块D未运行错误,且接收到来自业务模块E的网络响应中不包含错误标识,则业务模块D不打印日志;然而业务模块C在接收到来自业务模块D的网络响应后运行错误,则业务模块C会打印日志。最终,日志管理模块获取的目标调用链中业务模块打印的日志则业务模块C打印的日志,而不包含业务模块D打印的日志。The second reason is that in the process of processing the first service request by the target call chain, the fourth service module does not run in error and the received network response does not contain an error identifier. For example, taking the call chain shown in FIG. 2 as an example, the service module D does not run in error, and the network response received from the service module E does not contain an error identifier, then the service module D does not print the log; however, the service module C receives After receiving the network response from the service module D, there is an error, then the service module C will print a log. Finally, the log printed by the business module in the target call chain obtained by the log management module is the log printed by the business module C, but does not include the log printed by the business module D.
基于目标调用链中业务模块打印的日志中未包含第四业务模块打印的日志,日志管理模块获取第四业务模块在目标调用链处理第二业务请求的过程中打印的日志,第四业务模块在目标调用链处理第二业务请求的过程中打印的日志指示在目标调用链处理第二业务请求的过程中目标调用链中不存在运行错误的业务模块,且用于对目标调用链处理第一业务请求的过程进行分析。Based on the fact that the log printed by the business module in the target call chain does not include the log printed by the fourth business module, the log management module obtains the log printed by the fourth business module in the process of processing the second business request by the target call chain, and the fourth business module is in The log printed in the process of processing the second service request by the target call chain indicates that there is no service module with an operating error in the target call chain during the process of processing the second service request by the target call chain, and is used to process the first service on the target call chain The requested process is analyzed.
基于前述说明可知,存在多种原因会导致目标调用链中业务模块打印的日志中未包含第四业务模块打印的日志,无论是上述第一种原因,还是上述第二种原因,都不是第四业务模块造成目标调用链中出现运行错误的业务模块。若采用第四业务模块在目标调用链中存在运行错误的业务模块的情况下打印的日志,对目标调用链处理第一业务请求的过程进行分析,则可能误认为在目标调用链处理第一业务请求的过程中,第四业务模块运行错误。Based on the foregoing description, it can be seen that there are various reasons that the log printed by the business module in the target call chain does not include the log printed by the fourth business module. Whether it is the first reason above or the second reason above, it is not the fourth reason. The business module caused the wrong business module to appear in the target call chain. If the log printed by the fourth service module when there is a service module with an error in the target call chain is used to analyze the process of the target call chain processing the first service request, it may be mistaken for the target call chain to process the first service During the request process, the fourth service module runs incorrectly.
因此,本申请实施例采用第四业务模块在目标调用链处理第二业务请求的过程中打印的日志,对目标调用链处理第一业务请求的过程进行分析,以避免影响对目标调用链处理第一业务请求的过程的分析结果。Therefore, the embodiment of the present application uses the log printed by the fourth service module in the process of processing the second service request by the target call chain to analyze the process of processing the first service request by the target call chain, so as to avoid affecting the processing of the second service request by the target call chain. The analysis result of the process of a business request.
可以理解的是,在目标调用链已处理的特定类型业务请求的所有业务请求中,存在多个业务请求在被处理的过程中,目标调用链中不存在运行错误的业务模块。It can be understood that, among all the service requests of the specific type of service requests processed by the target call chain, there are multiple service requests in the process of being processed, and there is no business module that runs in error in the target call chain.
然而,为了完善目标调用链,通常会对目标调用链中的业务模块进行调整,例如可以对目标调用链中的业务模块进行功能完善。基于此,目标调用链在处理不同的业务请求的过程中,由于业务模块发生了改变,即使目标调用链中都不存在运行错误的业务模块,那么该业务模块打印的日志也可能不同。所以,若使用目标调用链在处理一个的业务请求的过程中业务模块打印的日志,分析目标调用链处理另一个的业务请求的过程,则可能影响分析结果。However, in order to improve the target call chain, the business modules in the target call chain are usually adjusted, for example, the functions of the business modules in the target call chain can be improved. Based on this, in the process of processing different business requests in the target call chain, since the business module has changed, even if there is no business module with an error in the target call chain, the logs printed by the business module may be different. Therefore, if the log printed by the business module in the process of processing one service request of the target call chain is used to analyze the process of processing another service request by the target call chain, the analysis result may be affected.
因此,为了尽可能避免获取到的第四业务模块在目标调用链处理第二业务请求的过程中打印的日志,影响第一业务模块对目标调用链处理第一业务请求的过程的分析结果,在本申请实施例提供的打印日志的方法的另一个实施例中,在目标调用链已处理的特定类型业务请求的所有业务请求中,第二业务请求的请求时间早于且最接近第一业务请求的请求时间。Therefore, in order to avoid as much as possible the obtained log printed by the fourth service module in the process of processing the second service request by the target call chain, and affecting the analysis result of the first service module on the process of processing the first service request by the target call chain, in In another embodiment of the method for printing a log provided by the embodiment of the present application, among all the service requests of the specific type of service requests processed by the target call chain, the request time of the second service request is earlier than and closest to the first service request request time.
以图2所示的调用链为例,假设业务模块A先后接收到来自客户端的三个业务请求, 分别为业务请求M、业务请求N和业务请求K;在处理业务请求M和业务请求N的过程中,调用链中均不存在运行错误的业务模块,而在处理业务请求K的过程中,调用链中存在运行错误的业务模块。Taking the call chain shown in FIG. 2 as an example, it is assumed that the service module A successively receives three service requests from the client, namely service request M, service request N, and service request K; During the process, there is no business module running wrong in the call chain, but in the process of processing the business request K, there is a business module running wrong in the call chain.
若日志管理模块获取的在调用链处理业务请求K的过程中打印的日志中,不包含业务模块D打印的日志,则日志管理模块会选择在调用链处理业务请求N的过程中业务模块D打印的日志,对调用链处理业务请求K的过程进行分析,而不会选择在调用链处理业务请求M的过程中业务模块D打印的日志,对调用链处理业务请求K的过程进行分析。If the logs obtained by the log management module that are printed during the process of processing the business request K of the call chain do not include the log printed by the business module D, the log management module will select the log printed by the business module D during the process of processing the business request N of the call chain. The log of the call chain processing service request K is analyzed, and the log printed by the business module D during the process of the call chain processing the service request M is not selected, and the process of the call chain processing the service request K is analyzed.
在本申请实施例中,在目标调用链已处理的特定类型业务请求的所有业务请求中,第二业务请求的请求时间早于且最接近第一业务请求的请求时间,使得日志管理模块获取到的正确日志更接近于,第四业务模块在目标调用链处理第一业务请求的过程中打印的正确日志,使得对目标调用链处理第一业务请求的过程的分析更加准确,避免日志管理模块选择的正确日志与第四业务模块在目标调用链处理第一业务请求的过程中打印的正确日志相差较大,而影响对目标调用链处理第一业务请求的过程的分析。In this embodiment of the present application, among all service requests of a specific type of service requests processed by the target call chain, the request time of the second service request is earlier than and closest to the request time of the first service request, so that the log management module obtains the The correct log is closer to the correct log printed by the fourth business module in the process of processing the first business request by the target call chain, which makes the analysis of the process of the target call chain processing the first business request more accurate and avoids the selection of the log management module. The difference between the correct log and the correct log printed by the fourth service module in the process of processing the first service request by the target call chain is large, which affects the analysis of the process of processing the first service request by the target call chain.
基于前述说明可知,本申请实施例中的第一业务模块与现有的业务模块不同,本申请实施例中的第一业务模块不仅用于处理接收到网络请求,还用于控制日志的打印。第一业务模块在控制日志打印的过程中,可以执行以下操作中的至少一种。Based on the foregoing description, the first service module in the embodiment of the present application is different from the existing service module. The first service module in the embodiment of the present application is not only used for processing received network requests, but also for controlling the printing of logs. During the process of controlling the printing of the log, the first service module may perform at least one of the following operations.
例如,本申请实施例中的第一业务模块在第一网络响应中携带有错误标识或第一业务模块运行错误的情况下打印日志。具体过程可参阅前述实施例中的相关说明。For example, the first service module in the embodiment of the present application prints a log when the first network response carries an error identifier or the first service module runs in error. For the specific process, please refer to the relevant descriptions in the foregoing embodiments.
例如,本申请实施例中的第一业务模块控制在预设第一周期内,且在第一业务模块在目标调用链中存在运行错误的业务模块的情况下,打印的日志数量小于第一预设数量。具体控制过程可参阅前述实施例中的相关说明。For example, the first service module in the embodiment of the present application is controlled within a preset first period, and in the case that the first service module has a service module with an operating error in the target call chain, the number of logs printed is less than the first preset period. Set quantity. For the specific control process, please refer to the relevant descriptions in the foregoing embodiments.
例如,本申请实施例中的第一业务模块在第一网络响应中不包含错误标识且第一业务模块未运行错误的情况下不打印日志。For example, the first service module in the embodiment of the present application does not print a log when the first network response does not contain an error identifier and the first service module does not run with errors.
例如,本申请实施例中的第一业务模块在第一网络响应中不包含错误标识且第一业务模块未运行错误的情况下打印日志,并控制在预设第二周期内,且在第一业务模块在目标调用链中不存在运行错误的业务模块的情况下,第一业务模块打印的日志数量小于第二预设数量。具体控制过程可参阅前述实施例中的相关说明。For example, the first service module in the embodiment of the present application prints a log when the first network response does not contain an error identifier and the first service module does not run in error, and controls it within a preset second period, and the first When the business module does not have a business module with an operating error in the target call chain, the number of logs printed by the first business module is less than the second preset number. For the specific control process, please refer to the relevant descriptions in the foregoing embodiments.
为了使第一业务模块能够执行上述操作中的至少一种,示例性地,如图6所示,可以在图4所示的第一业务模块内集成一个追踪Tracer单元,同样地,也可以在图5所示的第一业务模块内集成该Tracer单元;由该Tracer单元负责执行上述操作中的至少一种,以实现对日志打印的控制。In order to enable the first service module to perform at least one of the above operations, exemplarily, as shown in FIG. 6 , a tracer unit may be integrated in the first service module shown in FIG. The Tracer unit is integrated in the first service module shown in FIG. 5 ; the Tracer unit is responsible for performing at least one of the above operations, so as to realize the control of log printing.
目标调用链中的其他业务模块与第一业务模块类似,也在集成上述Tracer单元,具体不做详述。Similar to the first business module, other business modules in the target call chain are also integrating the above-mentioned Tracer unit, which will not be described in detail.
为了更好地理解本申请实施例提供的打印日志的方法,下面提供了关于图3的一具体应用例。该应用例包括两种场景。In order to better understand the method for printing logs provided by the embodiments of the present application, a specific application example of FIG. 3 is provided below. This application example includes two scenarios.
第一种场景:The first scenario:
第一步,第三业务模块发送第一网络请求,第一业务模块接收该第一网络请求。In the first step, the third service module sends the first network request, and the first service module receives the first network request.
该第一网络请求中包含的参数如下:WTraceRemains=4,RTraceRemains=1,WrongFlag=fasle,Times=1577084066659,Response=200,TraceId=eac290b095464ae5b4ebc754266a015a。The parameters included in the first network request are as follows: WTraceRemains=4, RTraceRemains=1, WrongFlag=fasle, Times=1577084066659, Response=200, TraceId=eac290b095464ae5b4ebc754266a015a.
其中,WTraceRemains=4表示剩余的错误日志数量为4,RTraceRemains=1表示剩余的正确日志数量为1,WrongFlag=fasle表示调用链中不存在运行错误的业务模块,Times=1577084066659表示业务模块A接收到的网络请求的时间为1577084066659,Response=200是指网络响应标识取值为200,具体表示业务模块A接收到的网络请求当前的状态为成功,eac290b095464ae5b4ebc754266a015a是业务模块A接收到的网络请求的TraceId。Among them, WTraceRemains=4 means that the number of remaining error logs is 4, RTraceRemains=1 means that the number of remaining correct logs is 1, WrongFlag=fasle means that there is no business module with running errors in the call chain, Times=1577084066659 means that business module A receives The time of the network request is 1577084066659, and Response=200 means that the network response identifier value is 200, which specifically indicates that the current status of the network request received by the service module A is successful, and eac290b095464ae5b4ebc754266a015a is the TraceId of the network request received by the service module A.
第二步,第一业务模块将第一网络请求中的数据保存至内存,但先不打印入口日志。In the second step, the first service module saves the data in the first network request to the memory, but does not print the entry log first.
具体地,第一模块将WTraceRemains=4,WrongFlag=fasle,Times=1577084066659,Response=200以及TraceId=eac290b095464ae5b4ebc754266a015a保存至内存。Specifically, the first module saves WTraceRemains=4, WrongFlag=fasle, Times=1577084066659, Response=200 and TraceId=eac290b095464ae5b4ebc754266a015a to the memory.
第三步,第一业务模块通过内部运行,对第一网络请求进行处理。In the third step, the first service module processes the first network request through internal operation.
第四步,在内部运行后,为了调用第二业务模块,第一业务模块向第二业务模块发送第二网络请求。In the fourth step, after the internal operation, in order to invoke the second service module, the first service module sends a second network request to the second service module.
具体地,由于WrongFlag=fasle表示第一网络请求中不包含错误标识,所以若第一业务模块未运行错误,则第二网络请求包含WTraceRemains=4,WrongFlag=fasle,Times=1577084066659,Response=200,TraceId=eac290b095464ae5b4ebc754266a015a;若第一业务模块运行错误,则第二网络请求包含WTraceRemains=4,WrongFlag=true,Times=1577084066659,Response=200,TraceId=eac290b095464ae5b4ebc754266a015a,其中WrongFlag=true表示调用链中存在运行错误的业务模块。Specifically, since WrongFlag=fasle indicates that the first network request does not contain an error identifier, if the first service module does not run in error, the second network request contains WTraceRemains=4, WrongFlag=fasle, Times=1577084066659, Response=200, TraceId=eac290b095464ae5b4ebc754266a015a; if the first service module runs incorrectly, the second network request contains WTraceRemains=4, WrongFlag=true, Times=1577084066659, Response=200, TraceId=eac290b095464ae5b4ebc754266a015a, where WrongFlag=true indicates that there is an error in the call chain business module.
第二业务模块在接收到第二网络请求后,会对第二网络请求进行处理,然后向第一业务模块发送第一网络响应。After receiving the second network request, the second service module processes the second network request, and then sends the first network response to the first service module.
第五步,第一业务模块接收来自第二业务模块的第一网络响应。In the fifth step, the first service module receives the first network response from the second service module.
一种情况,第一网络响应中包含WTraceRemains=4,WrongFlag=fasle,Times=1577084066659,Response=200,TraceId=eac290b095464ae5b4ebc754266a015a。另一种情况,第一网络响应中包含WTraceRemains=4,WrongFlag=true,Times=1577084066659,Response=200,TraceId=eac290b095464ae5b4ebc754266a015a。In one case, the first network response includes WTraceRemains=4, WrongFlag=fasle, Times=1577084066659, Response=200, and TraceId=eac290b095464ae5b4ebc754266a015a. In another case, the first network response includes WTraceRemains=4, WrongFlag=true, Times=1577084066659, Response=200, and TraceId=eac290b095464ae5b4ebc754266a015a.
第六步,第一业务模块通过内部运行对第一网络响应进行处理。In the sixth step, the first service module processes the first network response through internal operation.
第七步,基于第一业务模块在处理第一网络请求的过程中运行错误,或基于第一业务模块接收的来自第二业务模块的第一网络响应中携带有错误标识,第一业务模块打印日志。Step 7: Based on the operation error of the first service module in the process of processing the first network request, or based on the fact that the first network response from the second service module received by the first service module carries an error identifier, the first service module prints log.
具体地,若第一业务模块内部运行错误,或第一网络响应中包含参数WrongFlag=true,则表示第一业务模块需要打印日志类型为错误日志。此时,又因为WTraceRemains=4,说明第一业务模块可以打印的错误日志的数量为4,所以第一业务模块根据保存的第一网络请求中的参数打印入口日志,根据第一网络响应中的参数打印出口日志。在打印完入口日志和出口日志后,第一业务模块会将第一网络请求中的参数和第二网络请求中的参数从内存中清除。Specifically, if the first service module has an internal operation error, or the first network response contains the parameter WrongFlag=true, it means that the first service module needs to print the log type as error log. At this time, because WTraceRemains=4, it means that the number of error logs that the first service module can print is 4, so the first service module prints the entry log according to the parameters in the saved first network request, and according to the first network response The parameter prints the exit log. After printing the entry log and the exit log, the first service module will clear the parameters in the first network request and the parameters in the second network request from the memory.
第八步,第一业务模块向第三业务模块发送对于第一网络请求的第二网络响应。In the eighth step, the first service module sends a second network response to the first network request to the third service module.
具体地,由于第一业务模块内部运行错误,或第一网络响应中包含参数WrongFlag=true,所以第二网络响应中包含WTraceRemains=4,WrongFlag=true,Times=1577084066659,Response=200,TraceId=eac290b095464ae5b4ebc754266a015a。Specifically, due to the internal operation error of the first service module or the parameter WrongFlag=true contained in the first network response, the second network response contains WTraceRemains=4, WrongFlag=true, Times=1577084066659, Response=200, TraceId=eac290b095464ae5b4ebc754266a015a .
第二种场景:Second scenario:
第一步,第三业务模块发送第三网络请求,第一业务模块接收该第三网络请求。In the first step, the third service module sends a third network request, and the first service module receives the third network request.
其中,第三网络请求中的参数与第一种场景中第一网络请求中的参数相同。The parameters in the third network request are the same as the parameters in the first network request in the first scenario.
同样地,第一业务模块将第三网络请求中的数据保存至内存,但先不打印入口日志;然后第一业务模块通过内部运行,对第三网络请求进行处理。在内部运行后,第一业务模块调用第二业务模块,在调用第二业务模块及后续业务模块的调用过程中,都未出现运行错误的业务模块。这种情况下,第一业务模块会接收到来自第二业务模块的第三网络响应,且第三网络响应中不包含错误标识。Similarly, the first service module saves the data in the third network request to the memory, but does not print the entry log first; then the first service module processes the third network request through internal operation. After the internal operation, the first business module calls the second business module, and in the calling process of calling the second business module and subsequent business modules, there is no business module with an operating error. In this case, the first service module will receive a third network response from the second service module, and the third network response does not contain an error identifier.
上述过程与第一种场景中的过程类似,具体参阅第一种场景中的说明进行理解。The above-mentioned process is similar to the process in the first scenario. For details, please refer to the description in the first scenario for understanding.
第二步,基于第一业务模块在处理第三网络请求的过程中未运行错误,且接收到的第三网络响应中不包含错误标识,第一业务模块不打印日志。In the second step, the first service module does not print a log based on the fact that the first service module does not have an error in the process of processing the third network request, and the received third network response does not contain an error identifier.
其中,第三网络响应中包含WTraceRemains=4,WrongFlag=fasle,Times=1577084066659,Response=200,TraceId=eac290b095464ae5b4ebc754266a015a。The third network response includes WTraceRemains=4, WrongFlag=fasle, Times=1577084066659, Response=200, and TraceId=eac290b095464ae5b4ebc754266a015a.
第三步,第一业务模块向第三业务模块发送对于第三网络请求的网络响应。In the third step, the first service module sends a network response to the third network request to the third service module.
具体地,基于第一业务模块内部运行未发生错误,且第一网络响应中包含参数WrongFlag=fasle,所以第二网络响应中包含WTraceRemains=4,WrongFlag=fasle,Times=1577084066659,Response=200,TraceId=eac290b095464ae5b4ebc754266a015a。请参阅图7,本申请实施例提供的一种打印日志的装置的一个实施例示意图,装置包括:Specifically, based on the internal operation of the first service module without errors, and the first network response contains the parameter WrongFlag=fasle, the second network response contains WTraceRemains=4, WrongFlag=fasle, Times=1577084066659, Response=200, TraceId =eac290b095464ae5b4ebc754266a015a. Please refer to FIG. 7 , which is a schematic diagram of an embodiment of an apparatus for printing a log provided by an embodiment of the present application. The apparatus includes:
接收单元301,用于接收第一网络请求;a receiving unit 301, configured to receive a first network request;
日志打印单元302,用于基于在处理第一网络请求的过程中运行错误,或基于接收的来自第二业务模块的对于第二网络请求的第一网络响应中携带有错误标识,打印日志,第二网络请求是处理第一网络请求的过程中为调用第二业务模块而发送的,第二业务模块属于目标调用链,错误标识指示目标调用链中存在运行错误的业务模块。The log printing unit 302 is configured to print a log based on an operation error in the process of processing the first network request, or based on the received first network response to the second network request from the second service module that carries an error identifier. The second network request is sent to call the second service module in the process of processing the first network request. The second service module belongs to the target call chain, and the error flag indicates that there is a service module in the target call chain with an operating error.
在一种实现方式下,预设第一周期内,第一业务模块在目标调用链中存在运行错误的业务模块的情况下,打印的日志数量小于第一预设数量。In an implementation manner, within the preset first cycle, when the first service module has a service module with an operating error in the target call chain, the number of logs printed is less than the first preset number.
在一种实现方式下,装置还包括:保存单元303,用于将第一网络请求中的数据保存至内存;发送单元,用于发送对于第一网络请求的第二网络响应,第二网络响应指示调用第一业务模块的结果;日志打印单元,用于根据保存的第一网络请求中的数据打印入口日志,且根据第二网络响应中的数据打印出口日志。In an implementation manner, the apparatus further includes: a saving unit 303, configured to save the data in the first network request to a memory; a sending unit, configured to send a second network response to the first network request, the second network response Indicates the result of calling the first service module; the log printing unit is configured to print the entry log according to the data in the saved first network request, and print the exit log according to the data in the second network response.
在一种实现方式下,第一网络请求来自于第三业务模块,第三业务模块属于目标调用链;装置还包括发送单元304,用于基于第一业务模块运行错误或第一网络响应中携带有错误标识,向第三业务模块发送对于第一网络请求的携带有错误标识的第二网络响应,以使得第三业务模块打印日志。In an implementation manner, the first network request comes from a third service module, and the third service module belongs to the target call chain; the apparatus further includes a sending unit 304, which is configured to be based on an operation error of the first service module or a carry in the first network response. If there is an error identifier, the second network response carrying the error identifier to the first network request is sent to the third service module, so that the third service module prints a log.
在一种实现方式下,接收单元301,还用于接收第三网络请求,第三网络请求用于调用第一业务模块;日志打印单元302,还用于基于第一业务模块在处理第三网络请求的过程中未运行错误,且接收到的第三网络响应中不包含错误标识,不打印日志。In an implementation manner, the receiving unit 301 is further configured to receive a third network request, and the third network request is used to invoke the first service module; the log printing unit 302 is further configured to process the third network based on the first service module There is no error during the request process, and the received third network response does not contain an error flag, and no log is printed.
在一种实现方式下,接收单元301,还用于接收第三网络请求,第三网络请求用于调用第一业务模块;日志打印单元302,还用于基于第一业务模块在处理第三网络请求的过程中未运行错误,且接收到的第三网络响应中不包含错误标识,打印日志;第一业务模块未运行错误,接收到第三网络响应中不包含错误标识,且在预设第二周期内,第一业务模块打印的日志数量小于第二预设数量。In an implementation manner, the receiving unit 301 is further configured to receive a third network request, and the third network request is used to invoke the first service module; the log printing unit 302 is further configured to process the third network based on the first service module There is no operation error in the process of the request, and the received third network response does not contain an error identifier, and the log is printed; the first business module does not operate with an error, the third network response received does not contain an error identifier, and the preset third network response does not contain an error identifier. Within two cycles, the number of logs printed by the first service module is less than the second preset number.
在一种实现方式下,目标调用链用于处理客户端发送的特定类型业务请求,特定类型业务请求包括第一业务请求;第一网络请求是第一业务模块在目标调用链处理第一业务请求的过程中接收到的。In an implementation manner, the target call chain is used to process a specific type of service request sent by the client, and the specific type of service request includes a first service request; the first network request is that the first service module processes the first service request in the target call chain received during the process.
在一种实现方式下,目标调用链属于目标业务系统,目标业务系统还包括日志管理模块,特定类型业务请求还包括第二业务请求,目标调用链还包括第四业务模块;In an implementation manner, the target call chain belongs to the target business system, the target business system further includes a log management module, the specific type of business request further includes a second business request, and the target call chain further includes a fourth business module;
日志管理模块包括:第一获取单元,用于获取在目标调用链处理第一业务请求的过程中,目标调用链中业务模块打印的日志;The log management module includes: a first obtaining unit, configured to obtain the log printed by the business module in the target call chain in the process of processing the first service request by the target call chain;
第二获取单元,用于基于目标调用链中业务模块打印的日志中未包含第四业务模块打印的日志,获取第四业务模块在目标调用链处理第二业务请求的过程中打印的日志,以对目标调用链处理第一业务请求的过程进行分析,第四业务模块在目标调用链处理第二业务请求的过程中打印的日志指示,在目标调用链处理第二业务请求的过程中目标调用链中不存在运行错误的业务模块。The second obtaining unit is configured to obtain the log printed by the fourth service module in the process of processing the second service request in the target call chain based on that the log printed by the service module in the target call chain does not include the log printed by the fourth service module, to Analyze the process of the target call chain processing the first service request, the log indication printed by the fourth service module in the process of processing the second service request by the target call chain, and the target call chain in the process of processing the second service request by the target call chain. There are no business modules that are running incorrectly in .
在一种实现方式下,在目标调用链已处理的特定类型业务请求的所有业务请求中,第二业务请求的请求时间早于且最接近第一业务请求的请求时间。In an implementation manner, among all the service requests of the specific type of service requests processed by the target call chain, the request time of the second service request is earlier than and closest to the request time of the first service request.
请参阅图8,图8为本申请实施例中服务器的结构示意图。Please refer to FIG. 8 , which is a schematic structural diagram of a server in an embodiment of the present application.
本申请实施例中服务器一个实施例可以包括一个或一个以上处理器401,存储器402,通信接口403。One embodiment of the server in this embodiment of the present application may include one or more processors 401 , a memory 402 , and a communication interface 403 .
存储器402可以是短暂存储或持久存储。更进一步地,处理器401可以配置为与存储器402通信,在控制设备上执行存储器402中的一系列指令操作。The memory 402 may be ephemeral storage or persistent storage. Further, the processor 401 may be configured to communicate with the memory 402 to execute a series of instruction operations in the memory 402 on the control device.
本实施例中,处理器401可以执行前述各个实施例中方法的步骤,具体此处不再赘述。In this embodiment, the processor 401 may execute the steps of the methods in the foregoing embodiments, and details are not described herein again.
示例性地,处理器401可以执行以下步骤:Exemplarily, the processor 401 may perform the following steps:
接收第一网络请求,第一网络请求用于调用第一业务模块;receiving a first network request, where the first network request is used to invoke the first service module;
基于第一业务模块在处理第一网络请求的过程中运行错误,或基于第一业务模块接收的来自第二业务模块的对于第二网络请求的第一网络响应中携带有错误标识,打印日志,第二网络请求是第一业务模块处理第一网络请求的过程中为调用第二业务模块而发送的,第一业务模块和第二业务模块属于目标调用链,错误标识指示目标调用链中存在运行错误的业务模块。Print a log based on an error in the process of processing the first network request by the first business module, or based on the fact that the first network response to the second network request received by the first business module from the second business module carries an error identifier, The second network request is sent by the first service module to call the second service module in the process of processing the first network request. The first service module and the second service module belong to the target call chain, and the error flag indicates that there is a running operation in the target call chain. Wrong business module.
在本申请实施例中,处理器401中的具体功能模块划分可以与前述图7中所描述的功能模块的划分方式类似,此处不再赘述。In this embodiment of the present application, the division of specific functional modules in the processor 401 may be similar to the division of the functional modules described in FIG. 7 , which is not repeated here.
本申请实施例还提供一种芯片或者芯片系统,该芯片或者芯片系统包括至少一个处理器和通信接口,通信接口和至少一个处理器通过线路互联,至少一个处理器用于运行计算机程序或指令,以执行前述各个实施例中方法的步骤,具体此处不再赘述。The embodiments of the present application further provide a chip or a chip system, the chip or chip system includes at least one processor and a communication interface, the communication interface and the at least one processor are interconnected by a line, and the at least one processor is used to run a computer program or instruction to The steps of the methods in the foregoing embodiments are performed, and details are not described herein again.
其中,芯片中的通信接口可以为输入/输出接口、管脚或电路等。Wherein, the communication interface in the chip may be an input/output interface, a pin, a circuit, or the like.
本申请实施例还提供了芯片或者芯片系统的第一种实施方式,本申请中上述描述的芯片或者芯片系统还包括至少一个存储器,该至少一个存储器中存储有指令。该存储器可以为芯片内部的存储单元,例如,寄存器、缓存等,也可以是该芯片的存储单元(例如,只读存储器、随机存取存储器等)。The embodiment of the present application also provides a first implementation manner of a chip or a chip system. The chip or chip system described above in the present application further includes at least one memory, and instructions are stored in the at least one memory. The memory may be a storage unit inside the chip, such as a register, a cache, etc., or a storage unit of the chip (eg, a read-only memory, a random access memory, etc.).
本申请实施例还提供了一种计算机存储介质,该计算机存储介质用于储存为上述服务器所用的计算机软件指令,其包括用于执行为服务器所设计的程序。Embodiments of the present application also provide a computer storage medium, where the computer storage medium is used for storing computer software instructions used by the above-mentioned server, which includes a program for executing a program designed for the server.
该服务器可以如前述图7所描述的打印日志的装置。The server may be the device for printing logs as described in the aforementioned FIG. 7 .
本申请实施例还提供了一种计算机程序产品,该计算机程序产品包括计算机软件指令,该计算机软件指令可通过处理器进行加载来实现前述各个实施例所示的方法中的流程。Embodiments of the present application also provide a computer program product, where the computer program product includes computer software instructions, and the computer software instructions can be loaded by a processor to implement the processes in the methods shown in the foregoing embodiments.
请参阅图9,本申请实施例提供的一种业务系统的实施例示意图。如图9所示,本申请实施例提供了一种业务系统,包括目标调用链,目标调用链中包含第一业务模块100;第一业务模块100用于执行如前述各个实施例中的打印日志的方法。Please refer to FIG. 9 , which is a schematic diagram of an embodiment of a service system provided by an embodiment of the present application. As shown in FIG. 9 , an embodiment of the present application provides a business system, including a target call chain, and the target call chain includes a first business module 100; the first business module 100 is used to execute the print log in the foregoing embodiments Methods.
在一种实现方式下,目标调用链中还包括第四业务模块200,业务系统还包括日志管理模块300;目标调用链用于处理客户端发送的特定类型业务请求,特定类型业务请求包括第一业务请求和第二业务请求;第一网络请求是第一业务模块100在目标调用链处理第一业务请求的过程中接收到的。In an implementation manner, the target call chain further includes a fourth business module 200, and the business system further includes a log management module 300; the target call chain is used to process a specific type of service request sent by the client, and the specific type of service request includes the first The service request and the second service request; the first network request is received by the first service module 100 in the process of processing the first service request by the target call chain.
日志管理模块300用于,获取在目标调用链处理第一业务请求的过程中,目标调用链中业务模块打印的日志;且基于目标调用链中业务模块打印的日志中未包含第四业务模块200打印的日志,获取第四业务模块200在目标调用链处理第二业务请求的过程中打印的日志,以对目标调用链处理第一业务请求的过程进行分析,第四业务模块200在目标调用链处理第二业务请求的过程中打印的日志指示,在目标调用链处理第二业务请求的过程中目标调用链中不存在运行错误的业务模块。The log management module 300 is used to obtain the log printed by the business module in the target call chain in the process of processing the first service request by the target call chain; and the log printed based on the business module in the target call chain does not include the fourth business module 200 The log printed, obtains the log printed by the fourth service module 200 in the process of processing the second service request by the target call chain, so as to analyze the process of processing the first service request by the target call chain, and the fourth service module 200 is in the target call chain. The log printed in the process of processing the second service request indicates that there is no service module with an operating error in the target call chain in the process of processing the second service request by the target call chain.
在一种实现方式下,在目标调用链已处理的特定类型业务请求的所有业务请求中,第二业务请求的请求时间早于且最接近第一业务请求的请求时间。In an implementation manner, among all the service requests of the specific type of service requests processed by the target call chain, the request time of the second service request is earlier than and closest to the request time of the first service request.
需要说明的是日志管理模块300的功能和具体实现,可参照前述实施例中对日志管理模块300的相关说明进行理解。It should be noted that the function and specific implementation of the log management module 300 can be understood by referring to the relevant description of the log management module 300 in the foregoing embodiments.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system, device and unit described above may refer to the corresponding process in the foregoing method embodiments, which will not be repeated here.
在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间 接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not implemented. On the other hand, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, which may be electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated units may be implemented in the form of hardware, or may be implemented in the form of software functional units.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。The integrated unit, if implemented in the form of a software functional unit and sold or used as an independent product, may be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the present application can be embodied in the form of software products in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, and the computer software products are stored in a storage medium , including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, Read-Only Memory (ROM, Read-Only Memory), Random Access Memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program codes .

Claims (17)

  1. 一种打印日志的方法,其特征在于,所述方法包括:A method for printing a log, the method comprising:
    第一业务模块接收第一网络请求,所述第一网络请求用于调用所述第一业务模块;The first service module receives a first network request, and the first network request is used to invoke the first service module;
    基于所述第一业务模块在处理所述第一网络请求的过程中运行错误,或基于所述第一业务模块接收的来自第二业务模块的第一网络响应中携带有错误标识,所述第一业务模块打印日志,其中,所述第一网络响应是对于第二网络请求的,所述第二网络请求是所述第一业务模块处理所述第一网络请求的过程中为调用第二业务模块而发送的,所述第一业务模块和所述第二业务模块属于目标调用链,所述错误标识指示所述目标调用链中存在运行错误的业务模块。Based on the operation error of the first service module in the process of processing the first network request, or based on the fact that the first network response received by the first service module from the second service module carries an error identifier, the first network response A service module prints a log, wherein the first network response is to a second network request, and the second network request is a process of invoking a second service in the process of processing the first network request by the first service module The first service module and the second service module belong to the target call chain, and the error identifier indicates that there is a service module with an operation error in the target call chain.
  2. 根据权利要求1所述的方法,其特征在于,预设第一周期内,所述第一业务模块在所述目标调用链中存在运行错误的业务模块的情况下,打印的日志数量小于第一预设数量。The method according to claim 1, wherein, in a preset first period, the first service module prints less logs than the first service module when there is a service module with an operation error in the target call chain. Preset quantity.
  3. 根据权利要求1或2所述的方法,其特征在于,在所述第一业务模块接收第一网络请求之后,所述方法还包括:The method according to claim 1 or 2, wherein after the first service module receives the first network request, the method further comprises:
    所述第一业务模块将所述第一网络请求中的数据保存至内存;The first service module saves the data in the first network request to the memory;
    所述第一业务模块发送对于所述第一网络请求的第二网络响应,所述第二网络响应指示调用所述第一业务模块的结果;sending, by the first service module, a second network response to the first network request, the second network response indicating a result of calling the first service module;
    所述第一业务模块打印日志包括:The first business module print log includes:
    所述第一业务模块根据保存的所述第一网络请求中的数据打印入口日志;The first service module prints an entry log according to the stored data in the first network request;
    所述第一业务模块根据所述第二网络响应中的数据打印出口日志。The first service module prints an exit log according to the data in the second network response.
  4. 根据权利要求3所述的方法,其特征在于,所述第一网络请求来自于第三业务模块,所述第三业务模块属于所述目标调用链;The method according to claim 3, wherein the first network request comes from a third service module, and the third service module belongs to the target call chain;
    所述第一业务模块发送对于所述第一网络请求的第二网络响应包括:The second network response sent by the first service module to the first network request includes:
    基于所述第一业务模块运行错误或所述第一网络响应中携带有所述错误标识,所述第一业务模块向所述第三业务模块发送对于所述第一网络请求的携带有所述错误标识的第二网络响应,以使得所述第三业务模块打印日志。Based on an error in the operation of the first service module or the error identifier is carried in the first network response, the first service module sends to the third service module a request for the first network that carries the error identifier. The second network response of the error identification causes the third service module to print a log.
  5. 根据权利要求1至4中任意一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1 to 4, wherein the method further comprises:
    第一业务模块接收第三网络请求,所述第三网络请求用于调用所述第一业务模块;the first service module receives a third network request, where the third network request is used to invoke the first service module;
    基于所述第一业务模块在处理所述第三网络请求的过程中未运行错误,且接收到的第三网络响应中不包含所述错误标识,所述第一业务模块不打印日志。Based on the fact that the first service module does not have an error in the process of processing the third network request, and the received third network response does not contain the error identifier, the first service module does not print a log.
  6. 根据权利要求1至4中任意一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1 to 4, wherein the method further comprises:
    所述第一业务模块接收第三网络请求,所述第三网络请求用于调用所述第一业务模块;the first service module receives a third network request, where the third network request is used to invoke the first service module;
    基于预设第二周期内,所述第一业务模块在处理所述第三网络请求的过程中未运行错误,且接收到的第三网络响应中不包含所述错误标识的情况下,所述第一业务模块已打印的日志数量小于第二预设数量,所述第一业务模块打印日志。Based on the fact that within the preset second period, the first service module does not have an error in processing the third network request, and the received third network response does not contain the error identifier, the The number of logs printed by the first business module is less than the second preset number, and the first business module prints the logs.
  7. 根据权利要求1至6中任意一项所述的方法,其特征在于,所述目标调用链属于目标业务系统,且用于处理客户端发送的特定类型业务请求,所述目标业务系统还包括日志管理模块,所述特定类型业务请求包括第一业务请求和第二业务请求,所述目标调用链还 包括第四业务模块;The method according to any one of claims 1 to 6, wherein the target call chain belongs to a target service system and is used to process a specific type of service request sent by a client, and the target service system further includes a log a management module, the specific type of service request includes a first service request and a second service request, and the target call chain further includes a fourth service module;
    所述第一网络请求是所述第一业务模块在所述目标调用链处理所述第一业务请求的过程中接收到的;The first network request is received by the first service module in the process of processing the first service request by the target call chain;
    特定类型业务请求所述方法还包括:The method for requesting a specific type of service further includes:
    所述日志管理模块获取在所述目标调用链处理所述第一业务请求的过程中,所述目标调用链中业务模块打印的日志;The log management module acquires the log printed by the service module in the target call chain in the process of processing the first service request by the target call chain;
    基于所述目标调用链中业务模块打印的日志中未包含所述第四业务模块打印的日志,所述日志管理模块获取所述第四业务模块在所述目标调用链处理所述第二业务请求的过程中打印的日志,以对所述目标调用链处理第一业务请求的过程进行分析,所述第四业务模块在所述目标调用链处理第二业务请求的过程中打印的日志指示,在所述目标调用链处理所述第二业务请求的过程中所述目标调用链中不存在运行错误的业务模块。Based on the fact that the log printed by the business module in the target call chain does not include the log printed by the fourth business module, the log management module obtains that the fourth business module processes the second business request in the target call chain The log printed in the process of processing the first service request by the target call chain is to analyze the process of processing the first service request by the target call chain, and the log printed by the fourth service module in the process of processing the second service request by the target call chain indicates that In the process of processing the second service request by the target invocation chain, there is no service module in the target invocation chain that runs in error.
  8. 根据权利要求7所述的方法,其特征在于,在所述目标调用链已处理的所述特定类型业务请求的所有业务请求中,所述第二业务请求的请求时间早于且最接近所述第一业务请求的请求时间。The method according to claim 7, wherein among all the service requests of the specific type of service requests processed by the target call chain, the request time of the second service request is earlier than and closest to the The request time of the first service request.
  9. 一种打印日志的装置,其特征在于,所述装置包括:A device for printing logs, characterized in that the device comprises:
    接收单元,用于接收第一网络请求;a receiving unit, configured to receive the first network request;
    日志打印单元,用于基于在处理所述第一网络请求的过程中运行错误,或基于接收的来自第二业务模块的对于所述第二网络请求的第一网络响应中携带有错误标识,打印日志,所述第二网络请求是处理所述第一网络请求的过程中为调用第二业务模块而发送的,所述第二业务模块属于目标调用链,所述错误标识指示所述目标调用链中存在运行错误的业务模块。A log printing unit, configured to print based on an operation error in the process of processing the first network request, or based on the received first network response to the second network request from the second service module that carries an error identifier, printing log, the second network request is sent to call the second service module in the process of processing the first network request, the second service module belongs to the target call chain, and the error flag indicates the target call chain There is a business module that is running incorrectly in .
  10. 根据权利要求9所述的装置,其特征在于,预设第一周期内,所述第一业务模块在所述目标调用链中存在运行错误的业务模块的情况下,打印的日志数量小于第一预设数量。The device according to claim 9, wherein, in a preset first period, in the case that there is a business module with an operation error in the target call chain, the number of logs printed by the first service module is less than the number of logs printed by the first service module. Preset quantity.
  11. 根据权利要求9或10所述的装置,其特征在于,所述装置还包括:The device according to claim 9 or 10, wherein the device further comprises:
    保存单元,用于将所述第一网络请求中的数据保存至内存;a saving unit, configured to save the data in the first network request to a memory;
    发送单元,用于发送对于所述第一网络请求的第二网络响应,所述第二网络响应指示调用所述第一业务模块的结果;a sending unit, configured to send a second network response to the first network request, where the second network response indicates a result of calling the first service module;
    所述日志打印单元,用于根据保存的所述第一网络请求中的数据打印入口日志,且根据所述第二网络响应中的数据打印出口日志。The log printing unit is configured to print an entry log according to the stored data in the first network request, and print an exit log according to the data in the second network response.
  12. 根据权利要求11所述的装置,其特征在于,所述第一网络请求来自于第三业务模块,所述第三业务模块属于所述目标调用链;The apparatus according to claim 11, wherein the first network request comes from a third service module, and the third service module belongs to the target call chain;
    所述发送单元,还用于基于所述第一业务模块运行错误或所述第一网络响应中携带有错误标识,向所述第三业务模块发送对于所述第一网络请求的携带有所述错误标识的第二网络响应,以使得所述第三业务模块打印日志。The sending unit is further configured to send, to the third service module, based on the operation error of the first service module or an error identifier carried in the first network response, for the first network request carrying the The second network response of the erroneous identification causes the third service module to print a log.
  13. 一种服务器,其特征在于,包括:至少一个处理器和存储器,存储器存储有可在处理器上运行的计算机执行指令,当所述计算机执行指令被所述处理器执行时,所述服务 器执行如上述权利要求1-8中任意一项所述的方法。A server, characterized in that it includes: at least one processor and a memory, the memory stores computer-executable instructions that can be executed on the processor, and when the computer-executable instructions are executed by the processor, the server executes an instruction such as The method of any of the preceding claims 1-8.
  14. 一种存储一个或多个计算机执行指令的计算机可读存储介质,其特征在于,当所述计算机执行指令被处理器执行时,所述处理器执行如上述权利要求1-8中任意一项所述的方法。A computer-readable storage medium storing one or more computer-executable instructions, characterized in that, when the computer-executable instructions are executed by a processor, the processor executes the method described in any one of the preceding claims 1-8. method described.
  15. 一种业务系统,其特征在于,包括目标调用链,所述目标调用链中包含第一业务模块;A business system, characterized in that it includes a target invocation chain, and the target invocation chain includes a first business module;
    所述第一业务模块用于执行如上述权利要求1-8中任意一项所述的方法。The first service module is configured to execute the method according to any one of the preceding claims 1-8.
  16. 根据权利要求15所述的业务系统,其特征在于,所述目标调用链中还包括第四业务模块,所述业务系统还包括日志管理模块;The business system according to claim 15, wherein the target call chain further includes a fourth business module, and the business system further includes a log management module;
    所述目标调用链用于处理客户端发送的特定类型业务请求,所述特定类型业务请求包括第一业务请求和第二业务请求;The target call chain is used to process a specific type of service request sent by the client, and the specific type of service request includes a first service request and a second service request;
    所述第一网络请求是所述第一业务模块在所述目标调用链处理所述第一业务请求的过程中接收到的;The first network request is received by the first service module in the process of processing the first service request by the target call chain;
    所述日志管理模块用于,获取在所述目标调用链处理所述第一业务请求的过程中,所述目标调用链中业务模块打印的日志;The log management module is configured to acquire the log printed by the service module in the target call chain in the process of processing the first service request by the target call chain;
    且基于所述目标调用链中业务模块打印的日志中未包含所述第四业务模块打印的日志,获取所述第四业务模块在所述目标调用链处理第二业务请求的过程中打印的日志,以对所述目标调用链处理第一业务请求的过程进行分析,所述第四业务模块在所述目标调用链处理第二业务请求的过程中打印的日志指示,在所述目标调用链处理所述第二业务请求的过程中所述目标调用链中不存在运行错误的业务模块。And based on that the log printed by the business module in the target call chain does not include the log printed by the fourth business module, obtain the log printed by the fourth business module in the process of processing the second business request in the target call chain , to analyze the process of processing the first service request by the target call chain, and the log indication printed by the fourth service module in the process of processing the second service request by the target call chain is processed in the target call chain. During the process of the second service request, there is no service module with an operating error in the target call chain.
  17. 根据权利要求15所述的业务系统,其特征在于,在所述目标调用链已处理的所述特定类型业务请求的所有业务请求中,所述第二业务请求的请求时间早于且最接近所述第一业务请求的请求时间。The service system according to claim 15, wherein among all service requests of the specific type of service requests processed by the target call chain, the request time of the second service request is earlier than and closest to all service requests. Describe the request time of the first service request.
PCT/CN2021/108370 2020-07-31 2021-07-26 Log printing method, device and system WO2022022446A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010762131.9A CN114064384A (en) 2020-07-31 2020-07-31 Method, device and system for printing log
CN202010762131.9 2020-07-31

Publications (1)

Publication Number Publication Date
WO2022022446A1 true WO2022022446A1 (en) 2022-02-03

Family

ID=80037566

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/108370 WO2022022446A1 (en) 2020-07-31 2021-07-26 Log printing method, device and system

Country Status (2)

Country Link
CN (1) CN114064384A (en)
WO (1) WO2022022446A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114780333A (en) * 2022-04-07 2022-07-22 北京沃东天骏信息技术有限公司 Log printing control method and device

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117707439B (en) * 2023-08-22 2025-08-29 荣耀终端股份有限公司 Log printing method and related device

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140007119A1 (en) * 2012-06-29 2014-01-02 International Business Machines Corporation Dynamically Adjusting a Log Level of a Transaction
CN109471845A (en) * 2018-10-25 2019-03-15 深圳壹账通智能科技有限公司 Log management method, server, and computer-readable storage medium
CN110287053A (en) * 2019-06-27 2019-09-27 四川新网银行股份有限公司 The method that distributed system is uniformly processed extremely
CN110858130A (en) * 2018-08-22 2020-03-03 网宿科技股份有限公司 Log printing method and system and server
CN111341445A (en) * 2020-02-05 2020-06-26 网宿科技股份有限公司 Health detection method and health detection system of microservice call chain
CN111459760A (en) * 2020-04-01 2020-07-28 交通银行股份有限公司太平洋信用卡中心 Micro-service monitoring method and device and computer storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104007942A (en) * 2014-05-30 2014-08-27 乐视致新电子科技(天津)有限公司 Method and device for printing control of logs
CN106502874B (en) * 2016-10-26 2019-05-10 南京途牛科技有限公司 A call chain tracking method
US20190034259A1 (en) * 2017-07-25 2019-01-31 Kyocera Document Solutions Inc. Systems and Methods for Implementing a Thread Trace Log
CN107870850A (en) * 2017-08-25 2018-04-03 成都萌想科技有限责任公司 A kind of efficient the Internet, applications log system
CN110764980A (en) * 2019-09-06 2020-02-07 华为技术有限公司 Log processing method and device
CN110806966A (en) * 2019-11-08 2020-02-18 哈工大机器人湖州国际创新研究院 Log management method and device, electronic equipment and computer storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140007119A1 (en) * 2012-06-29 2014-01-02 International Business Machines Corporation Dynamically Adjusting a Log Level of a Transaction
CN110858130A (en) * 2018-08-22 2020-03-03 网宿科技股份有限公司 Log printing method and system and server
CN109471845A (en) * 2018-10-25 2019-03-15 深圳壹账通智能科技有限公司 Log management method, server, and computer-readable storage medium
CN110287053A (en) * 2019-06-27 2019-09-27 四川新网银行股份有限公司 The method that distributed system is uniformly processed extremely
CN111341445A (en) * 2020-02-05 2020-06-26 网宿科技股份有限公司 Health detection method and health detection system of microservice call chain
CN111459760A (en) * 2020-04-01 2020-07-28 交通银行股份有限公司太平洋信用卡中心 Micro-service monitoring method and device and computer storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114780333A (en) * 2022-04-07 2022-07-22 北京沃东天骏信息技术有限公司 Log printing control method and device

Also Published As

Publication number Publication date
CN114064384A (en) 2022-02-18

Similar Documents

Publication Publication Date Title
US12200082B2 (en) Microservice call method and apparatus, device, and medium
CN111176858A (en) A data request processing method and device
CN112306881A (en) Simulation data generation method, device, equipment and storage medium
WO2022022446A1 (en) Log printing method, device and system
US7996840B2 (en) Method, system, and apparatus for scheduling pattern based web services
US7533383B2 (en) Method, system, and apparatus for scheduling pattern based web services
CN113157411B (en) Celery-based reliable configurable task system and device
EP2634699B1 (en) Application monitoring
CN112685252A (en) Micro-service monitoring method, device, equipment and storage medium
US7289989B2 (en) Pattern based web services
CN112433709A (en) JSON-based data processing method, device, equipment and medium
CN114371982A (en) Simulation test method, device, equipment and readable storage medium
CN114398179B (en) Method and device for acquiring tracking identifier, server and storage medium
CN113900939A (en) Test environment access method, apparatus, readable storage medium and computer device
US10846156B2 (en) Methods, devices and computer program products for managing software function
US10992531B2 (en) Reactive non-blocking input and output for target device communication
CN110609822B (en) Data stream processing method, device and computer program product
CN117632445A (en) Request processing method and device, task execution method and device
CN117251361A (en) Method, device, equipment and storage medium for testing system stability
CN116340111A (en) Linux socket monitoring event monitoring method and device
CN113342540B (en) Terminal user fee-paying starting method, system, computer equipment and storage medium
CN115033397A (en) Interface calling method, apparatus, device and storage medium
CN112671561A (en) Network card configuration method and equipment of cloud host
CN113626295A (en) Pressure measurement data processing method and system and computer readable storage medium
WO2023029955A1 (en) Method for printing dynamic log, and electronic device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21849718

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21849718

Country of ref document: EP

Kind code of ref document: A1