CN114138510A - Operation log generation method and related device - Google Patents

Operation log generation method and related device Download PDF

Info

Publication number
CN114138510A
CN114138510A CN202111409625.XA CN202111409625A CN114138510A CN 114138510 A CN114138510 A CN 114138510A CN 202111409625 A CN202111409625 A CN 202111409625A CN 114138510 A CN114138510 A CN 114138510A
Authority
CN
China
Prior art keywords
information
module
log
operation log
micro
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202111409625.XA
Other languages
Chinese (zh)
Inventor
刘骏佳
陈建宏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Douku Software Technology Co Ltd
Original Assignee
Hangzhou Douku Software Technology Co Ltd
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 Hangzhou Douku Software Technology Co Ltd filed Critical Hangzhou Douku Software Technology Co Ltd
Priority to CN202111409625.XA priority Critical patent/CN114138510A/en
Publication of CN114138510A publication Critical patent/CN114138510A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1805Append-only file systems, e.g. using logs or journals to store data
    • G06F16/1815Journaling file systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the application provides an operation log generation method and a related device, which are applied to an operation log generation module of a micro-service system, wherein the micro-service system comprises a plurality of micro-service modules, the operation log generation module and an operation log acquisition module, and the method comprises the following steps: determining whether a local thread of a first micro-service module comprises a first operation number; if the first operation number is included, extracting the first operation number from the local thread; generating a first operation log of the first micro-service module according to the first operation number; and sending the first operation log to the operation log acquisition module. Thus, the operation log of a series of micro services corresponding to one operation of the user comprises a corresponding first operation number. The subsequent query efficiency of the operation log can be improved, so that a user can quickly obtain an operation record corresponding to a complete operation process.

Description

Operation log generation method and related device
Technical Field
The application belongs to the field of data processing, and particularly relates to an operation log generation method and a related device.
Background
The operation log is a file for recording various important information in the system operation process, and is created and recorded by each process in the system operation process. The operation log can record the running process and abnormal information of the system, and provides detailed information for rapidly positioning problems occurring in the running process of the system and program debugging problems in the development process.
Disclosure of Invention
The embodiment of the application provides an operation log generation method and a related device, so as to improve the efficiency of inquiring the operation log under a micro service system.
In a first aspect, an embodiment of the present application provides an operation log generating method, which is applied to an operation log generating module of a micro service system, where the micro service system includes a plurality of micro service modules, the operation log generating module, and an operation log collecting module, and the method includes:
determining whether a local thread of a first micro-service module comprises a first operation number, wherein the first operation number is an operation number of one operation of a second micro-service module, the first operation number is used for indicating a remote service call (RPC) request, and the RPC request is used for indicating a call relation of the second micro-service module to the first micro-service module;
if the first operation number is included, extracting the first operation number from the local thread;
generating a first operation log of the first micro-service module according to the first operation number;
and sending the first operation log to the operation log acquisition module.
In a second aspect, an embodiment of the present application provides an operation log generating method, which is applied to an operation log collecting module of a micro service system, where the micro service system includes a plurality of micro service modules, an operation log generating module, and the operation log collecting module, and the method includes:
the method comprises the steps of obtaining a first operation log of a first micro service module from an operation log generation module, wherein the first operation log carries a first operation number, the first operation number is an operation number of one operation of a second micro service module, the first operation number is used for indicating a remote service call (RPC) request, the RPC request is used for indicating a call relation of the second micro service module to the first micro service module, or the first operation log carries a second operation number, and the second operation number is an operation number of one operation of the first micro service module;
and storing the operation information included in the first operation log in a database.
In a third aspect, an embodiment of the present application provides an operation log generating device, which is applied to an operation log generating module of a micro service system, where the micro service system includes a plurality of micro service modules, the operation log generating module, and an operation log collecting module, and the device includes: the remote service calling method comprises a determining unit, a judging unit and a judging unit, wherein the determining unit is used for determining whether a local thread of a first micro-service module comprises a first operation number, the first operation number is an operation number of one operation aiming at a second micro-service module, the first operation number is used for indicating a remote service to call an RPC request, and the RPC request is used for indicating a calling relation of the second micro-service module aiming at the first micro-service module; an extracting unit, configured to extract the first operation number from the local thread if the first operation number is included; the generating unit is used for generating a first operation log of the first micro-service module according to the first operation number; and the sending unit is used for sending the first operation log to the operation log acquisition module.
In a fourth aspect, an embodiment of the present application provides an operation log generating apparatus, which is applied to an operation log collecting module of a micro-service system, where the micro-service system includes a plurality of micro-service modules, an operation log generating module, and the operation log collecting module, and the apparatus includes: the remote service call method comprises an acquisition unit, a log generation unit and a remote service call processing unit, wherein the acquisition unit is used for acquiring a first operation log of a first micro service module from the operation log generation module, the first operation log carries a first operation number, the first operation number is an operation number of one operation aiming at a second micro service module, the first operation number is used for indicating a remote service call (RPC) request, the RPC request is used for indicating a call relation of the second micro service module aiming at the first micro service module, or the first operation log carries a second operation number, and the second operation number is an operation number of one operation aiming at the first micro service module; and the storage unit is used for storing the operation information included by the first operation log in a database.
In a fifth aspect, an embodiment of the present application provides an electronic device, including a processor, a memory, a communication interface, and one or more programs, stored in the memory and configured to be executed by the processor, the programs including instructions for performing the steps in the first or second aspects of the embodiments of the present application.
In a sixth aspect, an embodiment of the present application provides a computer storage medium, which is characterized by storing a computer program for electronic data exchange, wherein the computer program causes a computer to perform some or all of the steps described in the first aspect or the second aspect of the present embodiment.
In a seventh aspect, this application embodiment provides a computer program product, where the computer program product includes a non-transitory computer-readable storage medium storing a computer program, where the computer program is operable to cause a computer to perform some or all of the steps as described in the first aspect or the second aspect of this application embodiment. The computer program product may be a software installation package.
It can be seen that, in the embodiment of the present application, the operation log generating module first determines whether the local thread of the first micro service module includes the first operation number, and if the local thread of the first micro service module includes the first operation number, extracts the first operation number from the local thread, then generates the first operation log of the first micro service module according to the first operation number, and finally sends the first operation log to the operation log collecting module. Therefore, the operation logs of a series of micro services corresponding to one operation of the user comprise a corresponding first operation number, and it can be seen that because the operation log of each micro service sent to the operation log acquisition module carries the operation number of the most upstream micro service corresponding to the operation log, the user can generate a series of operation logs with the same operation number for a certain operation of one micro service, so that the subsequent query efficiency of the operation logs can be improved, and the user can quickly obtain an operation record corresponding to a complete operation flow.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1a is a schematic structural diagram of a microservice system according to an embodiment of the present application;
fig. 1b is a schematic structural diagram of an electronic device according to an embodiment of the present application;
FIG. 1c is a block diagram of a microservice system provided by an embodiment of the present application;
fig. 2a is a schematic flowchart of an operation log generation method according to an embodiment of the present application;
fig. 2b is a schematic diagram of an operation log collection time sequence provided in an embodiment of the present application;
FIG. 2c is a schematic diagram of an operation log generation manner provided by an embodiment of the present application;
FIG. 2d is a schematic diagram of another operation log generation method provided in this embodiment of the present application
FIG. 2e is a schematic diagram illustrating an operation log storing process according to an embodiment of the present application;
fig. 3 is a block diagram of functional units of an operation log generation apparatus according to an embodiment of the present application;
fig. 4 is a block diagram of functional units of another operation log generation apparatus provided in an embodiment of the present application;
fig. 5 is a block diagram of functional units of another operation log generation apparatus provided in an embodiment of the present application;
fig. 6 is a block diagram of functional units of another operation log generation apparatus according to an embodiment of the present application.
Detailed Description
In order to make the technical solutions of the present application better understood, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The terms "first," "second," and the like in the description and claims of the present application and in the above-described drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
Current oplogging schemes tend to be done only within a single service, but with the development of technology, microservice architectures are becoming more popular. Currently, a user clicking on a button may require a number of microservices downstream to process in sequence, each microservice may have operated on the database. Therefore, when querying the operation log collected by the current method, the user cannot quickly and accurately determine which operation log the user specifically aims at.
In view of the foregoing problems, embodiments of the present application provide an operation log generation method and a related apparatus, and the following describes embodiments of the present application in detail with reference to the accompanying drawings.
Referring to fig. 1a, fig. 1a is a schematic diagram of an architecture of a microservice system according to an embodiment of the present disclosure. The microservice system 10 includes a plurality of microservice modules 101, an operation log generating module 102 and an operation log collecting module 103, where the operation log generating module 102 may respectively obtain operation information from each microservice module 101, generate an operation log for the microservice module 101 according to the obtained operation information, and send the generated operation log to the operation log collecting module 103, and the operation log collecting module 103 is configured to store the collected operation log in a database.
The micro service modules 101, the operation log generation module 102, and the operation log collection module 103 may be located in the same electronic device, or may be located in different electronic devices, respectively, where the structure of the electronic device is shown in fig. 1b, and fig. 1b is a schematic structural diagram of an electronic device provided in an embodiment of the present application. The electronic device 110 comprises an application processor 120, a memory 130, a communication interface 140, and one or more programs 131, wherein the one or more programs 131 are stored in the memory 130 and configured to be executed by the application processor 120, and the one or more programs 131 comprise instructions for performing any of the steps of the method embodiments described below. In a specific implementation, the application processor 120 is configured to perform any one of the steps performed by the electronic device in the method embodiments described below, and when performing data transmission such as sending, optionally invokes the communication interface 140 to complete the corresponding operation.
Referring to fig. 1c, fig. 1c is a block diagram of a microservice system according to an embodiment of the present disclosure. As shown, the microservice system includes an access layer, a service layer, a middleware layer, and an infrastructure layer. The access layer comprises an operation foreground and an operation log generation module, the service layer comprises an operation log operation module and an operation log collection module, the middleware layer comprises a message queue module, and the infrastructure layer comprises a database and a Remote service Call (RPC). In the log collection process, firstly, the operation foreground generates operation information according to user operation, the operation log generation module can obtain corresponding operation information according to a buried point in the operation foreground, then, the operation log generation module generates an operation log according to the operation information, sends the operation log to the operation log collection module through the message queue module, and writes the operation log into a database by the operation log collection module. The operation log management service module reads the operation log from the database, sends the operation log to the back end of the service management background through the RPC, and then sends the operation log to the front end of the service management background through the back end of the service management background. It can be seen that, in terms of the overall architecture, the generation of the operation log is mainly divided into an operation log generation module for generating the operation log, an operation log acquisition module for acquiring the operation log, an operation log after parameter verification and data structure conversion, and an operation log acquisition module for writing the operation log into a database, and an operation log management module for providing multi-dimensional query and difference capabilities of the operation log, exposing an RPC interface to the outside, and providing an operation log overdue processing capability, and deleting services such as the overdue log and the like in a form of a timing task.
Referring to fig. 2a, fig. 2a is a schematic flowchart illustrating an operation log generating method according to an embodiment of the present disclosure. As shown in the figure, the operation log generation method includes the following steps:
in step 201, the operation log generation module determines whether the thread local variable of the first micro service module includes a first operation number.
The first operation number is an operation number of one operation aiming at the second micro service module, the first operation number is used for indicating a remote service call (RPC) request, and the RPC request is used for indicating a call relation of the second micro service module aiming at the first micro service module. When the operation personnel of the service performs the operation of adding, deleting and modifying in the management background, the micro service modules involved in the operation send additional operation logs through the operation log generation module besides the main logic. The method comprises the steps that an upstream micro service module generates an operation number through a Universal Unique IDentifier (UUID) algorithm, RPC calls among the micro service modules are packaged, the upstream operation number is transmitted to a downstream part in each call, and meanwhile, after the downstream micro service module receives a request, the operation number is written into a thread local variable (threaded local), so that the operation number can be obtained from the threaded local when an operation log is sent. the variable filled in the threaded local belongs to the current thread, and is isolated to other threads, that is, when the object is transferred across layers, the threaded local can be used to avoid multiple times of transfer and break the constraint between the layers. Therefore, the second micro service module is an upstream micro service module of the first micro service module, and when the second micro service module requests to schedule the first micro service module through the RPC, the second micro service module simultaneously sends the operation number of the current operation of the second micro service module to the first micro service module.
Step 202, if the first operation number is included, the operation log generation module extracts the first operation number from the thread local variable.
If the first micro service module includes the first operation number, it means that the second micro service module calls the first micro service module through the RPC request.
Step 203, the operation log generating module generates a first operation log of the first micro service module according to the first operation number.
The first operation log is an operation log carrying a first operation number. If the micro service module is downstream of the second micro service module, the operation log of the corresponding operation of the same time includes the first operation number.
Step 204, the operation log generation module sends the first operation log to the operation log collection module;
in step 205, the operation log collection module obtains a first operation log from a first microservice module of the operation log generation module.
Wherein, first operation log carries first operation number, first operation number is the operation number to the one-time operation of second little service module, first operation number is used for instructing remote service and calls the RPC request, the RPC request is used for instructing the little service module of second to aim at the calling relation of first little service module, perhaps first operation log carries second operation number, second operation number is for the operation number of the one-time operation of first little service module.
In step 206, the operation log collection module stores the operation information included in the first operation log in a database.
The operation log acquisition module can be used for writing the acquired parameters into the database after checking and data structure conversion, and can multiply the operation series of a series of other micro service modules corresponding to the second micro service module by a complete operation record according to the first operation number, so that a user can conveniently search the operation record through the database.
It can be seen that, in this example, the operation log generating module first determines whether the local thread of the first micro service module includes the first operation number, and if the local thread of the first micro service module includes the first operation number, extracts the first operation number from the local thread, then generates the first operation log of the first micro service module according to the first operation number, and finally sends the first operation log to the operation log collecting module. Therefore, in the embodiment of the application, because each micro-service operation log sent to the operation log acquisition module carries the operation number of the most upstream micro-service corresponding to the operation log, a series of operation logs with the same operation number can be generated by a user for a certain operation of one micro-service, so that the subsequent query efficiency of the operation logs can be improved, and the user can quickly obtain an operation record corresponding to a complete operation process.
In one possible example, the method further comprises: if the first operation number is not included, generating a second operation number aiming at one operation of the first micro service module; generating the first operation log of the first micro-service module according to the second operation number; and sending the first operation log to the operation log acquisition module.
If the first operation number is not found in the thread local variable, it can be determined that the first micro service module is not called by other micro service modules, and at this time, the first micro service module is the most upstream micro service module, so that a second operation number corresponding to one operation of the first micro service module can be generated according to the UUID algorithm, and a first operation log corresponding to the first micro service module can be generated according to the second operation number. If the first micro service module calls another micro service module, the first micro service module transfers the second operation number to the other micro service module according to the RPC.
As can be seen, in this example, if the first microserver module does not have the first operation number, the second operation number is generated for the first microserver module, so that the operation log of each microserver module carries an operation number for indicating each operation, which is convenient for a user to query an operation record.
In one possible example, the microservice system further includes a message queue module, and the sending the first operation log to the operation log collection module includes: and sending the first operation log to the message queue module.
The operation log generating module may wrap the first operation log carrying the first operation number into a Message Queue (mq) Message to be sent, and then the operation log collecting module consumes the operation log in the Message Queue module. As shown in fig. 2b, the operation log collection time sequence at this time is that the operation user performs the service operation on the operation platform, and then the operation record is generated by the service operation platform. And the operation log generating module generates an operation log according to the operation record message of the service operation platform and then sends the operation log to the message queue module. The operation log collection module can asynchronously consume the operation logs from the message queue module and store the obtained operation logs in the database.
Therefore, in the embodiment, the asynchronous mq message is adopted to send the collection operation logs, so that the flexibility and the stability of the system can be improved.
In one possible example, the generating a first operation log of the first microservice module according to the first operation number includes: acquiring embedded point information from the first micro service module to obtain a plurality of operation information, wherein the plurality of operation information comprises first operation information used for indicating operation parameters and second operation information used for indicating operation contents; and generating a first operation log of the first micro service module according to the first operation information, the second operation information and the first operation number.
The operation information of the operation log may include two components, i.e., first operation information and second operation information. The second operation information may be referred to as info information including secondary information such as entries, return values, interface addresses, operation remarks, etc., and the first operation information may be referred to as body information including main information such as contents of data before and after an operation, and states of data, etc. Since the operation records can be generated at a plurality of buried points for any service operation, one operation log can be generated by a plurality of buried point information, and the operation information corresponding to each buried point information can be different, for example, one buried point information corresponds to the first operation information, and another buried point information corresponds to the second operation information.
Therefore, in the example, the operation log is generated by the multiple pieces of embedded point information and the first operation number together, so that the generated operation log is more accurate, and a user can conveniently inquire the operation log subsequently.
In one possible example, the obtaining of the burial point information from the first micro service module obtains a plurality of operation information, including: acquiring primary embedded point information from the first micro-service module according to the first operation number to obtain first operation information and second operation information; the generating a first operation log of the first micro service module according to the first operation information, the second operation information and the first operation number includes: and generating the first operation log according to the first operation information, the second operation information and the first operation number.
The method can acquire the embedded point information once and simultaneously acquire all information for generating the operation log in a single-step acquisition mode, namely, a complete log can be generated according to a plurality of operation information acquired by the embedded point information acquired once.
Therefore, in this example, the operation information required for generating a complete log is acquired only by acquiring the embedded point information once, and the generation efficiency of the operation log can be improved.
In one possible example, the obtaining of the burial point information from the first micro service module obtains a plurality of operation information, including: acquiring the embedded point information from the first micro service module for multiple times according to the first operation number to obtain one piece of first operation information and multiple pieces of second operation sub information, wherein the second operation information comprises the second operation sub information; the generating a first operation log of the first micro service module according to the first operation information, the second operation information and the first operation number includes: and generating the first operation log according to the first operation information, the second operation sub information and the first operation number.
The first operation information and the second operation information are required to be simultaneously included in a complete operation log, and when the embedded point information is acquired once, only a part of information included in the operation log can be acquired, that is, the operation information can be acquired step by step, for example, the second operation information can be acquired once or for multiple times, and the first operation information can be acquired for another time. For example, as shown in fig. 2c, fig. 2c is a schematic diagram of an operation log generation method provided in an embodiment of the present application, it can be seen that three times of buried point information are obtained, the first obtained buried point information is second operation sub information used for indicating an operation parameter, and may include information such as a request method name and a request value, the second obtained buried point information is first operation information used for indicating operation content, and may include information such as a product id, operation content, and an operator, and the third obtained buried point information is also second operation sub information used for indicating an operation parameter, and may include information such as a return value and an execution result. The acquired plurality of second operation sub information may constitute complete second operation information. Namely, the operation log generation module can converge the multiple acquired embedded point information into a complete operation log. It should be noted that the operation numbers corresponding to the multiple times of obtained embedded point information are all the first operation numbers, that is, the operation information corresponding to the multiple times of embedded point information is the operation information generated by the current operation of the first micro service module.
Therefore, in this example, the embedded point information can be obtained for multiple times, and then the embedded point information obtained for multiple times is gathered into a complete operation log, so that the flexibility of generating the operation log can be improved.
In a possible example, the embedded point information is obtained from the first micro service module for multiple times to obtain M pieces of first operation information and N pieces of second operation sub information, where the M pieces of first operation information all correspond to the same second operation information, and the second operation information includes a plurality of pieces of second operation sub information; the generating a first operation log of the first micro service module according to the first operation information, the second operation information and the first operation number includes: generating M second operation logs according to the M pieces of first operation information, the N pieces of second operation sub information and an operation number corresponding to each piece of first operation information; and determining that the second operation logs including the first operation number in the M second operation logs are the first operation logs.
The micro-service module can generate a plurality of second operation parameters corresponding to the common first operation parameter according to a plurality of operations, namely the plurality of second operation parameters have common request values, return values and other data. The N pieces of second operation sub information form one piece of second operation information, and the M pieces of first operation information are operation information generated by different operations of the first micro service module respectively. As shown in fig. 2d, the multiple obtained embedded point information may include two pieces of second operation sub information and three pieces of first operation information, where the three pieces of first operation information correspond to the same second operation information, so that one operation log may be generated according to one piece of first operation information and two pieces of second operation sub information, and in the same way, three complete operation logs may be generated according to the three pieces of first operation information. That is, the buried point information with the common request value, the return value and other data is mapped into a plurality of complete operation logs.
Therefore, in the embodiment, the embedded point information can be obtained step by step in batches, a plurality of complete operation logs can be generated, and the efficiency and the flexibility of log generation can be improved.
In one possible example, the microservice system further includes a message queue module, the obtaining a first oplog from a first microservice module of the oplog generation module includes: and acquiring the first operation log from the message queue module.
The operation log collection module can asynchronously consume the operation logs from the message queue module.
Therefore, in this example, the operation log acquisition module acquires the first operation log from the message queue module, so that the flexibility of operation log acquisition and storage is improved.
In one possible example, the storing the operation information included in the first operation log in a database includes: determining an information type of operation information included in the first operation log; and storing the operation information sub-table included in the first operation log in the database according to the information type.
The operation type of the operation information may include a first type and a second type, where the first type corresponds to the first operation information, and the second type corresponds to the second operation information, that is, the first type may be a body type, and the second type may be an info type. When the operation log is stored, one table may be recorded for an operation with the operation type of the first type, and one table may be recorded for an operation with the operation type of the second type.
Therefore, in the embodiment, the operation information is stored in the sub-table according to different operation types, so that subsequent query and operation log management can be facilitated.
In one possible example, the sub-tabulating the operation information included in the first operation log according to the information type and storing the operation information in a database includes: determining whether the operation information with the operation type being a preset type is operation information corresponding to a preset service; if yes, storing preset operation information in the database according to an independent data table, wherein the field of the preset operation information is larger than the preset field.
And storing the operation information in a sub-table according to the service corresponding to the specific operation data. Particularly, when the operation type of the operation information is the second operation type, it may be further determined whether the operation information is operation information corresponding to a preset service, and if so, the corresponding preset operation information in the operation information is stored in a re-distribution table. The preset operation information may be operation information in which a content field before and after the operation is larger than a preset field. As shown in fig. 2e, fig. 2e is a schematic view of an operation log storage process provided in an embodiment of the present application, after the operation log collection module consumes an operation log from mq, it may be determined first whether the service (biz) allows logging, and if so, whether the message type is of the second type, i.e., whether the message type is an info type, if so, the operation information is inserted into the "biz _ info" table, and if not, determining whether the message type is body type, if yes, then determining whether biz is sub-table service, that is, whether the service corresponding to the operation information is a preset service or not, if not, all fields of the operation information are stored in a "biz _ body" table, if so, the contents before and after the operation are stored in the "biz _ detail" table, and the other fields are stored in the "biz _ body" table.
Therefore, in this example, the operation information with a larger field content in the preset service is separately stored in one data table, which is convenient for subsequent query and management of the operation log.
Consistent with the foregoing embodiment, please refer to fig. 3, fig. 3 is a block diagram of functional units of an operation log generation apparatus provided in an embodiment of the present application, where the operation log generation apparatus 30 is applied to an operation log generation module of a micro service system, the micro service system includes a plurality of micro service modules, the operation log generation module, and an operation log collection module, and the apparatus 30 includes: a determining unit 301, configured to determine whether a thread local variable of a first micro service module includes a first operation number, where the first operation number is an operation number of one operation for a second micro service module, the first operation number is used to indicate a remote service call (RPC) request, and the RPC request is used to indicate a call relation of the second micro service module for the first micro service module; an extracting unit 302, configured to extract the first operation number from the thread local variable if the first operation number is included; a generating unit 303, configured to generate a first operation log of the first microservice module according to the first operation number; a sending unit 304, configured to send the first operation log to the operation log collection module.
In one possible example, the apparatus 30 is further configured to: if the first operation number is not included, generating a second operation number aiming at one operation of the first micro service module; generating the first operation log of the first micro-service module according to the second operation number; and sending the first operation log to the operation log acquisition module.
In a possible example, in a case that the microservice system further includes a message queue module, and in the aspect of sending the first operation log to the operation log collecting module, the sending unit 304 is specifically configured to: sending the first operation log to the message queue module
In a possible example, in the aspect of generating the first operation log of the first microservice module according to the first operation number, the generating unit 303 is specifically configured to: acquiring embedded point information from the first micro service module to obtain a plurality of operation information, wherein the plurality of operation information comprises first operation information used for indicating operation content and second operation information used for indicating operation parameters; and generating a first operation log of the first micro service module according to the first operation information, the second operation information and the first operation number.
In a possible example, in the aspect of obtaining the buried point information from the first micro service module to obtain a plurality of operation information, the generating unit 303 is specifically configured to: acquiring primary embedded point information from the first micro-service module according to the first operation number to obtain first operation information and second operation information; the generating a first operation log of the first micro service module according to the first operation information, the second operation information and the first operation number includes: and generating the first operation log according to the first operation information, the second operation information and the first operation number.
In a possible example, in the aspect of obtaining the buried point information from the first micro service module to obtain a plurality of operation information, the generating unit 303 is specifically configured to: acquiring the embedded point information from the first micro service module for multiple times according to the first operation number to obtain one piece of first operation information and multiple pieces of second operation sub information, wherein the second operation information comprises the second operation sub information; the generating a first operation log of the first micro service module according to the first operation information, the second operation information and the first operation number includes: and generating the first operation log according to the first operation information, the second operation sub information and the first operation number.
In a possible example, in the aspect of obtaining the buried point information from the first micro service module to obtain a plurality of operation information, the generating unit 303 is specifically configured to: acquiring the embedded point information from the first micro service module for multiple times to obtain M pieces of first operation information and N pieces of second operation sub information, wherein the M pieces of first operation information correspond to the same second operation information, and the second operation information comprises a plurality of pieces of second operation sub information; the generating a first operation log of the first micro service module according to the first operation information, the second operation information and the first operation number includes: generating M second operation logs according to the M pieces of first operation information, the N pieces of second operation sub information and an operation number corresponding to each piece of first operation information; and determining that the second operation logs including the first operation number in the M second operation logs are the first operation logs.
It can be understood that, since the method embodiment and the apparatus embodiment are different presentation forms of the same technical concept, the content of the method embodiment portion in the present application should be synchronously adapted to the apparatus embodiment portion, and is not described herein again.
In the case of using an integrated unit, as shown in fig. 4, fig. 4 is a block diagram of a functional unit of another operation log generation apparatus provided in an embodiment of the present application. In fig. 4, the operation log generation apparatus 400 includes: a processing module 412 and a communication module 411. The processing module 412 is used to control and manage actions of the operation log generation apparatus, for example, to perform the steps of the determination unit 301, the extraction unit 302, the generation unit 303, and the transmission unit 304, and/or other processes for performing the techniques described herein. The communication module 411 is used for interaction between the operation log generation apparatus and other devices. As shown in fig. 4, the operation log generating device may further include a storage module 413, and the storage module 413 is used for storing program codes and data of the operation log generating device.
The Processing module 412 may be a Processor or a controller, and may be, for example, a Central Processing Unit (CPU), a general-purpose Processor, a Digital Signal Processor (DSP), an ASIC, an FPGA or other programmable logic device, a transistor logic device, a hardware component, or any combination thereof. Which may implement or perform the various illustrative logical blocks, modules, and circuits described in connection with the disclosure. The processor may also be a combination of computing functions, e.g., comprising one or more microprocessors, DSPs, and microprocessors, among others. The communication module 411 may be a transceiver, an RF circuit or a communication interface, etc. The storage module 413 may be a memory.
All relevant contents of each scene related to the method embodiment may be referred to the functional description of the corresponding functional module, and are not described herein again. The operation log generating apparatus 400 may perform the operation log generating method shown in fig. 2 a.
Consistent with the foregoing embodiment, please refer to fig. 5, where fig. 5 is a block diagram of functional units of an operation log generating apparatus provided in an embodiment of the present application, where the operation log generating apparatus 50 is applied to an operation log collecting module of a micro service system, the micro service system includes a plurality of micro service modules, an operation log generating module, and the operation log collecting module, and the apparatus 50 includes: an obtaining unit 501, configured to obtain a first operation log of a first micro service module from the operation log generation module, where the first operation log carries a first operation number, the first operation number is an operation number of one operation of a second micro service module, the first operation number is used to indicate a remote service call (RPC) request, and the RPC request is used to indicate a call relation of the second micro service module to the first micro service module, or the first operation log carries a second operation number, and the second operation number is an operation number of one operation of the first micro service module; a storage unit 502, configured to store the operation information included in the first operation log in a database.
In a possible example, in a case that the microservice system further includes a message queue module, and in terms of acquiring the first operation log from the first microservice module of the operation log generating module, the acquiring unit 501 is specifically configured to: and acquiring the first operation log from the message queue module.
In a possible example, in terms of storing the operation information included in the first operation log in a database, the storage unit 502 is specifically configured to: determining an information type of operation information included in the first operation log; and storing the operation information sub-table included in the first operation log in the database according to the information type.
In a possible example, in terms of the storing the operation information included in the first operation log in a database according to the information type in a table, the storage unit 502 is specifically configured to: determining whether the operation information with the operation type being a preset type is operation information corresponding to a preset service; if yes, storing preset operation information in the database according to an independent data table, wherein the field of the preset operation information is larger than the preset field.
It can be understood that, since the method embodiment and the apparatus embodiment are different presentation forms of the same technical concept, the content of the method embodiment portion in the present application should be synchronously adapted to the apparatus embodiment portion, and is not described herein again.
In the case of using an integrated unit, as shown in fig. 6, fig. 6 is a block diagram of a functional unit of another operation log generation apparatus provided in an embodiment of the present application. In fig. 6, the operation log generation apparatus 600 includes: a processing module 612 and a communication module 611. The processing module 612 is used for controlling and managing actions of the operation log generation apparatus, for example, executing steps of the acquisition unit 501 and the storage unit 502, and/or other processes for executing the techniques described herein. The communication module 611 is used for interaction between the operation log generation apparatus and other devices. As shown in fig. 6, the operation log generating device may further include a storage module 613, and the storage module 613 is used for storing program codes and data of the operation log generating device.
The Processing module 612 may be a Processor or a controller, and may be, for example, a Central Processing Unit (CPU), a general-purpose Processor, a Digital Signal Processor (DSP), an ASIC, an FPGA or other programmable logic device, a transistor logic device, a hardware component, or any combination thereof. Which may implement or perform the various illustrative logical blocks, modules, and circuits described in connection with the disclosure. The processor may also be a combination of computing functions, e.g., comprising one or more microprocessors, DSPs, and microprocessors, among others. The communication module 611 may be a transceiver, an RF circuit or a communication interface, etc. The storage module 613 may be a memory.
All relevant contents of each scene related to the method embodiment may be referred to the functional description of the corresponding functional module, and are not described herein again. The operation log generating device 600 can execute the operation log generating method shown in fig. 2 a.
The above embodiments may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, the above-described embodiments may be implemented in whole or in part in the form of a computer program product. The computer program product comprises one or more computer instructions or computer programs. The procedures or functions according to the embodiments of the present application are wholly or partially generated when the computer instructions or the computer program are loaded or executed on a computer. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire or wirelessly. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains one or more collections of available media. The usable medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium. The semiconductor medium may be a solid state disk.
Embodiments of the present application also provide a computer storage medium, where the computer storage medium stores a computer program for electronic data exchange, the computer program enabling a computer to execute part or all of the steps of any one of the methods described in the above method embodiments, and the computer includes an electronic device.
Embodiments of the present application also provide a computer program product comprising a non-transitory computer readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps of any of the methods as described in the above method embodiments. The computer program product may be a software installation package, the computer comprising an electronic device.
It should be understood that, in the various embodiments of the present application, the sequence numbers of the above-mentioned processes do not mean the execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
In the several embodiments provided in the present application, it should be understood that the disclosed method, apparatus and system may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative; for example, the division of the unit is only a logic function division, and there may be another division manner in actual implementation; for example, various elements or components may be combined or may be integrated into another system, or some features may be omitted, or not implemented. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be physically included alone, or two or more units may be integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
The integrated unit implemented in the form of a software functional unit may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute some steps of the methods according to the embodiments of the present invention. And the aforementioned storage medium includes: u disk, removable hard disk, magnetic disk, optical disk, volatile memory or non-volatile memory. The non-volatile memory may be a read-only memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an electrically Erasable EPROM (EEPROM), or a flash memory. Volatile memory can be Random Access Memory (RAM), which acts as external cache memory. By way of example, but not limitation, many forms of Random Access Memory (RAM) are available, such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), Enhanced SDRAM (ESDRAM), synchlink DRAM (SLDRAM), and direct bus RAM (DR RAM). And the like, which may store program code.
Although the present invention is disclosed above, the present invention is not limited thereto. Various changes and modifications can be easily made by those skilled in the art without departing from the spirit and scope of the present invention, and it is within the scope of the present invention to include different functions, combination of implementation steps, software and hardware implementations.

Claims (15)

1. An operation log generation method is applied to an operation log generation module of a micro service system, wherein the micro service system comprises a plurality of micro service modules, the operation log generation module and an operation log collection module, and the method comprises the following steps:
determining whether a thread local variable of a first micro service module comprises a first operation number, wherein the first operation number is an operation number of one operation of a second micro service module, the first operation number is used for indicating a remote service call (RPC) request, and the RPC request is used for indicating a call relation of the second micro service module to the first micro service module;
if the first operation number is included, extracting the first operation number from the thread local variable;
generating a first operation log of the first micro-service module according to the first operation number;
and sending the first operation log to the operation log acquisition module.
2. The method of claim 1, further comprising:
if the first operation number is not included, generating a second operation number aiming at one operation of the first micro service module;
generating the first operation log of the first micro-service module according to the second operation number;
and sending the first operation log to the operation log acquisition module.
3. The method of claim 1 or 2, wherein the microservice system further comprises a message queue module, and wherein sending the first oplog to the oplog collection module comprises:
and sending the first operation log to the message queue module.
4. The method of claim 1, wherein the generating a first operation log of the first microservice module according to the first operation number comprises:
acquiring embedded point information from the first micro service module to obtain a plurality of operation information, wherein the plurality of operation information comprises first operation information used for indicating operation content and second operation information used for indicating operation parameters;
and generating a first operation log of the first micro service module according to the first operation information, the second operation information and the first operation number.
5. The method of claim 4, wherein obtaining the site information from the first microservice module to obtain a plurality of operational information comprises:
acquiring primary embedded point information from the first micro-service module according to the first operation number to obtain first operation information and second operation information;
the generating a first operation log of the first micro service module according to the first operation information, the second operation information and the first operation number includes:
and generating the first operation log according to the first operation information, the second operation information and the first operation number.
6. The method of claim 4, wherein obtaining the site information from the first microservice module to obtain a plurality of operational information comprises:
acquiring the embedded point information from the first micro service module for multiple times according to the first operation number to obtain one piece of first operation information and multiple pieces of second operation sub information, wherein the second operation information comprises the second operation sub information;
the generating a first operation log of the first micro service module according to the first operation information, the second operation information and the first operation number includes:
and generating the first operation log according to the first operation information, the second operation sub information and the first operation number.
7. The method of claim 4, wherein obtaining the site information from the first microservice module to obtain a plurality of operational information comprises:
acquiring the embedded point information from the first micro service module for multiple times to obtain M pieces of first operation information and N pieces of second operation sub information, wherein the M pieces of first operation information correspond to the same second operation information, and the second operation information comprises a plurality of pieces of second operation sub information;
the generating a first operation log of the first micro service module according to the first operation information, the second operation information and the first operation number includes:
generating M second operation logs according to the M pieces of first operation information, the N pieces of second operation sub information and an operation number corresponding to each piece of first operation information;
and determining that the second operation logs including the first operation number in the M second operation logs are the first operation logs.
8. An operation log generation method is applied to an operation log collection module of a micro service system, wherein the micro service system comprises a plurality of micro service modules, an operation log generation module and the operation log collection module, and the method comprises the following steps:
the method comprises the steps of obtaining a first operation log of a first micro service module from an operation log generation module, wherein the first operation log carries a first operation number, the first operation number is an operation number of one operation of a second micro service module, the first operation number is used for indicating a remote service call (RPC) request, the RPC request is used for indicating a call relation of the second micro service module to the first micro service module, or the first operation log carries a second operation number, and the second operation number is an operation number of one operation of the first micro service module;
and storing the operation information included in the first operation log in a database.
9. The method of claim 8, wherein the microservice system further comprises a message queue module, and wherein obtaining the first oplog from the first microservice module of the oplog generation module comprises:
and acquiring the first operation log from the message queue module.
10. The method according to claim 8 or 9, wherein the storing the operation information included in the first operation log in a database comprises:
determining an information type of operation information included in the first operation log;
and storing the operation information sub-table included in the first operation log in the database according to the information type.
11. The method of claim 10, wherein the storing the operation information included in the first operation log in a database according to the information type includes:
determining whether the operation information with the operation type being a preset type is operation information corresponding to a preset service;
if yes, storing preset operation information in the database according to an independent data table, wherein the field of the preset operation information is larger than the preset field.
12. An operation log generating device applied to an operation log generating module of a micro service system, wherein the micro service system comprises a plurality of micro service modules, the operation log generating module and an operation log collecting module, and the device comprises:
the remote service calling method comprises a determining unit, a judging unit and a processing unit, wherein the determining unit is used for determining whether a thread local variable of a first micro-service module comprises a first operation number, the first operation number is an operation number of one operation aiming at a second micro-service module, the first operation number is used for indicating a remote service to call an RPC request, and the RPC request is used for indicating a calling relation of the second micro-service module aiming at the first micro-service module;
the extracting unit is used for extracting the first operation number from the thread local variable if the first operation number is included;
the generating unit is used for generating a first operation log of the first micro-service module according to the first operation number;
and the sending unit is used for sending the first operation log to the operation log acquisition module.
13. An operation log generating device applied to an operation log collecting module of a micro service system, the micro service system comprising a plurality of micro service modules, an operation log generating module and the operation log collecting module, the device comprising:
the remote service call method comprises an acquisition unit, a log generation unit and a remote service call processing unit, wherein the acquisition unit is used for acquiring a first operation log of a first micro service module from the operation log generation module, the first operation log carries a first operation number, the first operation number is an operation number of one operation aiming at a second micro service module, the first operation number is used for indicating a remote service call (RPC) request, the RPC request is used for indicating a call relation of the second micro service module aiming at the first micro service module, or the first operation log carries a second operation number, and the second operation number is an operation number of one operation aiming at the first micro service module;
and the storage unit is used for storing the operation information included by the first operation log in a database.
14. A microservice system, comprising a processor, a memory, and one or more programs stored in the memory and configured to be executed by the processor, the programs comprising instructions for performing the steps in the method of any of claims 1-7 or any of claims 8-11.
15. A computer-readable storage medium, characterized in that a computer program for electronic data exchange is stored, wherein the computer program causes a computer to perform the method according to any one of claims 1-7 or 8-11.
CN202111409625.XA 2021-11-24 2021-11-24 Operation log generation method and related device Pending CN114138510A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111409625.XA CN114138510A (en) 2021-11-24 2021-11-24 Operation log generation method and related device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111409625.XA CN114138510A (en) 2021-11-24 2021-11-24 Operation log generation method and related device

Publications (1)

Publication Number Publication Date
CN114138510A true CN114138510A (en) 2022-03-04

Family

ID=80391586

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111409625.XA Pending CN114138510A (en) 2021-11-24 2021-11-24 Operation log generation method and related device

Country Status (1)

Country Link
CN (1) CN114138510A (en)

Similar Documents

Publication Publication Date Title
CN110008045B (en) Method, device and equipment for aggregating microservices and storage medium
WO2021189954A1 (en) Log data processing method and apparatus, computer device, and storage medium
CN111767143A (en) Transaction data processing method, device, equipment and system
WO2019001074A1 (en) Remote process calling method and apparatus, and computer device
CN112448969B (en) Link tracking method, device, system, equipment and readable storage medium
CN107870989A (en) webpage generating method and terminal device
US11115913B2 (en) Wireless communication core network and method for analyzing user equipment mobility in the same
CN112511591A (en) Method, device, equipment and medium for realizing hospital interface data interaction
CN111767144A (en) Transaction routing determination method, device, equipment and system for transaction data
CN106339267A (en) Object query method and server side
WO2016107120A1 (en) Application programming interface calling method and device
CN115408193A (en) Method and device for processing error codes among multiple modules
CN110457132B (en) Method and device for creating functional object and terminal equipment
CN109725887B (en) Data interaction method and device based on message research and development framework and terminal equipment
CN118093219A (en) Message processing method, device, equipment and storage medium
CN112733510A (en) Financial certificate generation method, device, equipment and computer readable storage medium
CN117194068A (en) Cross-process data transmission method, system, equipment and storage medium
CN112491943A (en) Data request method, device, storage medium and electronic equipment
CN114138510A (en) Operation log generation method and related device
CN111124627A (en) Method, device, terminal and storage medium for determining application program caller
CN112416875B (en) Log management method, device, computer equipment and storage medium
CN115168440A (en) Data read-write method, distributed storage system, device, equipment and storage medium
CN105610908B (en) A kind of samba service implementing method and system based on Android device
CN113032820A (en) File storage method, access method, device, equipment and storage medium
CN111367634A (en) Information processing method, information processing device and terminal equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination