CN113760562A - Link tracking method, device, system, server and storage medium - Google Patents

Link tracking method, device, system, server and storage medium Download PDF

Info

Publication number
CN113760562A
CN113760562A CN202011062658.7A CN202011062658A CN113760562A CN 113760562 A CN113760562 A CN 113760562A CN 202011062658 A CN202011062658 A CN 202011062658A CN 113760562 A CN113760562 A CN 113760562A
Authority
CN
China
Prior art keywords
server
data request
request
client
data
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
CN202011062658.7A
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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information 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 Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202011062658.7A priority Critical patent/CN113760562A/en
Publication of CN113760562A publication Critical patent/CN113760562A/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
    • 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/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural

Abstract

The invention discloses a link tracking method, a device, a system, a server and a storage medium. The method is applied to the current server and comprises the following steps: receiving a first data request sent by a client or a previous server; acquiring a request identifier corresponding to a data request sent by a client, and generating log information containing the request identifier in a first data request response process; if the next server to be called exists in the first data request response process, determining a second data request containing the request identifier based on an interface interaction mode corresponding to the next server, and sending the second data request to the next server, so that the next server generates log information containing the request identifier in the second data request response process, and therefore the log information containing the same request identifier is generated in each server, link tracking at a log level is achieved, a link tracking framework is simplified, development efficiency is improved, and development cost is reduced.

Description

Link tracking method, device, system, server and storage medium
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to a link tracking method, a device, a system, a server and a storage medium.
Background
With the rapid development of computer technology, a plurality of servers can be independently developed to provide data services for clients, and the servers can acquire data in other servers in a manner of calling other servers, so that the reusability of the servers is improved.
In the process of responding to the data request sent by the client, calls of a plurality of servers may be involved, so that the call chain is long, and therefore link tracking needs to be carried out on the data request, so that the node with the data request exception can be quickly located.
Currently, link Tracing is usually performed based on some open-source components, such as Spring Cloud Sleuth, Zipkin, Dapper, training Analysis, etc. The functions realized by the components are many, such as time-consuming statistics, graphical interfaces, interface performance monitoring and the like, so that the development resources are also many. Specifically, tools such as a message queue and the like are required to realize log data acquisition or data reporting, data in a specified format is required to be stored and packaged by storage media such as an ES database and an Hbase database, and a separate server is required to be deployed.
However, in the process of implementing the present invention, the inventor finds that at least the following problems exist in the prior art:
when the existing switch component is used for link tracking, an additional server needs to be deployed for collecting, converting and storing log data, so that a link tracking framework is complex, the development efficiency is reduced, and the development cost, such as the server cost, the operation and maintenance cost, the resource cost and the like, is also improved.
Disclosure of Invention
The invention provides a link tracking method, a device, a system, a server and a storage medium, which are used for simplifying a link tracking framework, improving the development efficiency and reducing the development cost.
In a first aspect, an embodiment of the present invention provides a link tracking method applied to a current server, including:
receiving a first data request sent by a client or a previous server;
acquiring a request identifier corresponding to a data request sent by the client, and generating log information containing the request identifier in a first data request response process, wherein the data request sent by the client corresponds to the request identifier one to one;
if the next server to be called exists in the first data request response process, determining a second data request containing the request identifier based on an interface interaction mode corresponding to the next server, and sending the second data request to the next server, so that the next server generates log information containing the request identifier in the second data request response process;
the log information generated by each server is used for: and performing link tracking on the response process of the data request sent by the client based on the request identification.
In a second aspect, an embodiment of the present invention further provides a link tracking apparatus, which is disposed in a current server, and includes:
the request receiving module is used for receiving a first data request sent by a client or a previous server;
the log information generating module is used for acquiring a request identifier corresponding to a data request sent by the client and generating log information containing the request identifier in a first data request response process, wherein the data request sent by the client corresponds to the request identifier one by one;
a request sending module, configured to, when a next server to be called exists in a first data request response process, determine, based on an interface interaction mode corresponding to the next server, a second data request including the request identifier, and send the second data request to the next server, so that the next server generates log information including the request identifier in a second data request response process;
the log information generated by each server is used for: and performing link tracking on the response process of the data request sent by the client based on the request identification.
In a third aspect, an embodiment of the present invention further provides a link tracking system, where the system includes: a client and a plurality of servers, wherein,
the client is used for sending a data request to a server used for receiving the data request in the plurality of servers;
each of said servers is adapted to implement a link tracing method as provided by any of the embodiments of the invention.
In a fourth aspect, an embodiment of the present invention further provides a server, where the server includes:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement a link tracing method as provided by any of the embodiments of the invention.
In a fifth aspect, the embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the link tracking method provided in any embodiment of the present invention.
The embodiment of the invention has the following advantages or beneficial effects:
each server called in the process of responding to the data request sent by the client serves as a current server, the first data request sent by the client or the previous server is received through the current server, the unique request identifier corresponding to the data request sent by the client is obtained, and log information containing the request identifier is generated in the first data request responding process. If the next server to be called exists in the first data request response process, the second data request containing the request identifier is determined based on an interface interaction mode corresponding to the next server, and the second data request is sent to the next server, so that the next server can also generate log information containing the request identifier in the second data request response process, the request identifier is transmitted to the next server, the log information containing the same request identifier is generated in each server, link tracking can be performed on the response process of the data request sent by the client based on the request identifier in all the generated log information, and link tracking at the log level is achieved. Because each server only needs to generate log information containing the same request identifier, operations such as data acquisition, format conversion, storage and the like are not needed, the link tracking framework is greatly simplified, the development efficiency is improved, the link tracking framework can be directly deployed in the server for responding to the data request, an additional server is not needed, and the development cost is greatly reduced.
Drawings
In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, a brief description is given below of the drawings used in describing the embodiments. It should be clear that the described figures are only views of some of the embodiments of the invention to be described, not all, and that for a person skilled in the art, other figures can be derived from these figures without inventive effort.
Fig. 1 is a flowchart illustrating a link tracking method according to an embodiment of the present invention;
fig. 2A is a schematic flowchart of a link tracking method according to a second embodiment of the present invention;
fig. 2B is an example of a transfer process of a request identifier in the HTTP mode according to a second embodiment of the present invention;
fig. 2C is an example of a transmission process of a request identifier in an RPC mode according to a second embodiment of the present invention;
fig. 3A is a schematic flowchart of a link tracking method according to a third embodiment of the present invention;
fig. 3B is an example of a data request response procedure according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of a link tracking apparatus according to a fourth embodiment of the present invention;
fig. 5 is a schematic structural diagram of a link tracking system according to a fifth embodiment of the present invention;
fig. 6 is a schematic structural diagram of a server according to a sixth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a flowchart illustrating a link tracing method according to an embodiment of the present invention, which is applicable to a case of performing link tracing on a response process of a data request, and especially applicable to a link tracing scenario in a distributed environment. The method may be performed by a link tracing apparatus provided in the current server, which may be implemented by hardware and/or software, integrated in the server for responding to data requests.
Before describing the link tracking method provided by the present embodiment, a description of the current server is required. The invocation of multiple servers may be involved in responding to data requests sent by a client, so that each server to be invoked may be the current server. For example, the current server may refer to a server which is in communication connection with the client and is used for receiving and processing a data request sent by the client; or may refer to a server, which is in communication connection with the previous server and is used for receiving and processing the data request sent by the previous server. The current server may also call the next server in the process of processing the data request, so as to obtain the response data in the next server.
Illustratively, the current server may include: the client side comprises a first server or a second server, wherein the first server can refer to a server which is used for responding to data requests sent by the client side in a user service layer, and the second server can refer to a server which is used for responding to data requests sent by other servers in other processing layers except the user service layer.
The user service layer may refer to a server layer interfacing with the client and configured to receive and respond to data requests sent by the client. The user service layer can comprise a plurality of first servers which are distributed and deployed, and each first server can receive and respond to the data request sent by the client so as to improve the processing performance. When a client sends a data request, a certain first server in a user service layer can respond to the data request, so that link tracking needs to be carried out on the data request, so that the first server for responding to the data request can be quickly located from a plurality of first servers, and the response condition of the data request in the first server is known.
Wherein, the other processing layer besides the user service layer may refer to a server layer interfacing with the server for receiving and responding to the data request sent by the server. The number of other processing layers than the user service layer may be plural. For example, other processing layers may include, but are not limited to, a gateway management layer and a business processing layer. Servers in any two processing layers may call each other to provide data services. The first server can call the second server in other processing layers in the process of responding to the data request sent by the client so as to obtain the response data in the second server. The second server may also invoke a second server located in a different processing layer during processing of the data request sent by the first server, thereby generating a server call chain. The embodiment may involve the invocation of the second server in one or more other processing layers in the process of responding to the data request sent by the client, so that the invoked second server may be one or more. Each of the other processing layers may include a plurality of second servers deployed in a distributed manner, each of the second servers being capable of receiving and responding to data requests sent by other servers in order to improve processing performance. When a certain server sends a data request to a certain other processing layer, a certain second server in the processing layer can respond to the data request, so that link tracking needs to be performed on the data request, so that a second server used for responding to the data request can be quickly located from a plurality of second servers in the processing layer, and the response condition of the data request in the second server is known.
The following describes a link tracking method provided in this embodiment, and as shown in fig. 1, the method specifically includes the following steps:
s110, receiving a first data request sent by a client or a last server.
The client may refer to a device that generates a corresponding data request based on a user operation. The previous server may refer to a server in a processing layer previous to the current processing layer where the current server is located, that is, a server for calling the current server to obtain response data in the current server. The sending object of the second data request in this embodiment may be determined based on the current server. For example, if the current server is a first server, the received first data request is generated and sent by the client, and if the current server is a second server, the received first data request is generated and sent by the last server.
Illustratively, S110 may include: if the current server is a first server, receiving a first data request sent by a client; if the current server is a second server, receiving a first data request sent by the previous server; the previous server may refer to a server in a processing layer above a current processing layer corresponding to the current server, for responding to the data request. For example, if the current server is the second server called by the first server, the last server of the current server is the first server.
In particular, the process of responding to a data request sent by a client involves the invocation of multiple servers, and the invocation process of each server is similar. For example, when a first server is called, that is, when the current server is the first server, the first server receives a first data request sent by the client, so that response processing of the first data request is performed in the first server. When the second or subsequent server is called, that is, when the current server is the second server, the second server receives the first data request sent by the last server, so as to perform response processing of the second data request in the second server.
S120, acquiring a request identifier corresponding to a data request sent by a client, and generating log information containing the request identifier in a first data request response process, wherein the data request sent by the client corresponds to the request identifier one to one.
The request identifier may be used to uniquely identify the data request sent by the client, so as to distinguish different data requests sent by the client. For example, the request identification may be a log thread number for the log generation thread. The first data request response procedure may refer to a service processing procedure for the first data request. The log information may include, but is not limited to: the server processes data such as success of data request response, data response process, and time used by data response.
Specifically, when the current server receives the first data request, the request identifier corresponding to the data request sent by the client may be acquired, and log information including the data request is generated in a service processing process of the first data request, so that the generated log information is subjected to screening query based on the data request, and a response condition of the data request sent by the client in the current server is acquired based on the queried log information. Illustratively, when the current server is a first server, the received first data request is a data request sent by the client, so as to generate a request identifier corresponding to the data request, and generate log information containing the request identifier in a first data request response process. When the current server is the second server, the request identifier corresponding to the data request sent by the client may be obtained based on the received first data request, so that log information including the same request identifier is also generated in the second data request response process.
It can be understood that each server involved in the process of responding to the data request sent by the client may generate log information including a request identifier corresponding to the data request sent by the client in the first data request responding process, so that for the same data request sent by the client, the log information generated by each called server includes the same request identifier.
S130, if a next server to be called exists in the first data request response process, determining a second data request containing a request identifier based on an interface interaction mode corresponding to the next server, and sending the second data request to the next server so that the next server generates log information containing the request identifier in the second data request response process; the log information generated by each server is used for: and performing link tracking on the response process of the data request sent by the client based on the request identification.
The interface interaction mode may refer to a data interaction manner between a current server and a next server. For example, the interface interaction mode may include an HTTP (HyperText Transfer Protocol) mode and an RPC (Remote Procedure Call) mode. The different interface interaction modes follow different transmission protocols, such as the HTTP mode is based on the HTTP protocol, and the PRC mode is based on the TCP protocol or the HTTP2 protocol. The second data request may refer to a data request generated by the current server in the first data request response process so as to acquire data in the next server based on the data request. The next server may refer to a server for responding to the second data request in a processing layer next to a current processing layer in which the current server is located.
It should be noted that the request identifier corresponding to another data request generated by a different server based on the data request sent by the client is identical to the request identifier corresponding to the data request sent by the client. That is, the request identifier corresponding to the second data request is the same as the request identifier corresponding to the data request sent by the client.
Specifically, the current server may detect whether data in another server is needed in the process of responding to the first data request, and if so, the server where the needed data is located is used as a next server, and a second data request including a request identifier is generated based on the needed data and the interface interaction mode, and the second data request is sent to the next server, so that the next server may obtain the request identifier, and generate log information including the request identifier in the process of responding to the second data request, thereby implementing the transfer of the request identifier. Illustratively, the next server may be regarded as the current server, that is, the second data request is regarded as the first data request, and the operations of steps S110-S120 are performed in return, so that the next server generates log information containing the same request identifier. Similarly, in a cyclic manner, log information containing the same request identifier can be generated in each server called in the process of responding to the data request sent by the client. If it is detected that the next server to be called does not exist in the first data request response process, that is, the response process of the data request sent by the client is ended, at this time, the loop is stopped, and the called data in each second server is returned one by one based on the calling order of the second servers, so that the first server can obtain complete response data corresponding to the data request sent by the client, and the complete response data is returned to the client, thereby completing the whole response process of the data request.
It should be noted that, after each server responds to each data request sent by the client, each server may generate log information including the same request identifier for each data request sent by the client, so that it is possible to quickly know, based on the request identifier, to which data request the log information is generated. And based on the request identifier corresponding to the data request to be queried, querying can be performed in all generated log information to obtain the log information containing the request identifier, so that the whole response condition of the data request can be known based on the queried log information, the full link tracking at the log level is realized, and the node with the abnormal data request can be quickly positioned.
In the technical scheme of this embodiment, each server called in the process of responding to a data request sent by a client is used as a current server, a first data request sent by the client or a previous server is received by the current server, a unique request identifier corresponding to the data request sent by the client is acquired, and log information containing the request identifier is generated in the first data request responding process. If the next server to be called exists in the first data request response process, the second data request containing the request identifier is determined based on an interface interaction mode corresponding to the next server, and the second data request is sent to the next server, so that the next server can also generate log information containing the request identifier in the second data request response process, the request identifier is transmitted to the next server, the log information containing the same request identifier is generated in each server, link tracking can be performed on the response process of the data request sent by the client based on the request identifier in all the generated log information, and link tracking at the log level is achieved. Because each server only needs to generate log information containing the same request identifier, operations such as data acquisition, format conversion, storage and the like are not needed, the link tracking framework is greatly simplified, the development efficiency is improved, the link tracking framework can be directly deployed in the server for responding to the data request, an additional server is not needed, and the development cost is greatly reduced.
Example two
Fig. 2A is a schematic flow chart of a link tracking method according to a second embodiment of the present invention, and in this embodiment, further optimization is performed on "obtaining a request identifier corresponding to a data request sent by a client" on the basis of the first embodiment. Wherein explanations of the same or similar terms as those of the above-described embodiments are omitted. Referring to fig. 2A, the link tracking method provided in this embodiment specifically includes the following steps:
s210, receiving a first data request sent by a client or a previous server.
S220, if the current server is the first server, distributing a corresponding request identifier for the data request sent by the client; and if the current server is a second server, acquiring a request identifier corresponding to the data request sent by the client based on an interface interaction mode corresponding to the second server.
Specifically, if the current server is the first server, it indicates that the unique request identifier corresponding to the data request sent by the client does not exist currently, and at this time, the first data request sent by the client may be received, and a unique request identifier is actively allocated to the first data request sent by the client to identify the data request. If the current server is the second server, it indicates that the first server has currently allocated the unique request identifier corresponding to the data request sent by the client, and the previous server has transferred the allocated request identifier, at this time, the first data request sent by the previous server may be received, and the transferred request identifier is obtained based on the interface interaction mode between the previous server and the current server, so as to obtain the request identifier corresponding to the data request sent by the client, and further make the request identifiers included in the log information generated in each server consistent. In this embodiment, the request identifier of the previous server is transmitted to the next server, so that all the request identifiers in the servers are unified, log-level tracking of a full link is realized, and a node with an abnormal data request is quickly located.
For example, the step S220 of acquiring a request identifier corresponding to the data request sent by the client based on the interface interaction mode corresponding to the second server may include: if the interface interaction mode corresponding to the second server is the HTTP mode, acquiring a request identifier corresponding to the data request sent by the client from a request header of the first data request; and if the interface interaction mode corresponding to the second server is the RPC mode, acquiring a request identifier corresponding to the data request sent by the client from a context container of the RPC mode.
Specifically, if the interface interaction mode between the second server and the previous server is the HTTP mode, the previous server may set the request identifier in the request header of the first data request to transmit, so that the first data request may be analyzed, and the request identifier corresponding to the data request sent by the client is obtained from the request header of the first data request. As shown in fig. 2B, the second server with the interface interaction mode being the HTTP mode corresponds to the current server in fig. 2B. If the interface interaction mode between the second server and the previous server is the RPC mode, the request identifier may be set in the context container of the RPC mode for transmission, so that the request identifier corresponding to the data request sent by the client may be obtained from the context container of the RPC mode, as shown in fig. 2C, where the second server with the interface interaction mode being the RPC mode corresponds to the current server in fig. 2C.
And S230, generating log information containing request identifications in the first data request response process, wherein the data requests sent by the client correspond to the request identifications one by one.
S240, if the next server to be called exists in the first data request response process, determining a second data request containing the request identifier based on an interface interaction mode corresponding to the next server, and sending the second data request to the next server so that the next server generates log information containing the request identifier in the second data request response process; the log information generated by each server is used for: and performing link tracking on the response process of the data request sent by the client based on the request identification.
For example, as shown in fig. 2B and 2C, the determining the second data request including the request identifier based on the interface interaction mode corresponding to the next server in step S240 may include: if the interface interaction mode corresponding to the next server is the HTTP mode, adding the request identifier into a request header of a second data request to obtain the second data request containing the request identifier; and if the interface interaction mode corresponding to the second server is the RPC mode, storing the request identifier in a context container of the RPC mode, and acquiring a second data request containing the request identifier.
The context container of the RPC mode may be an explicit parameter so as to explicitly transmit the request identifier, or an implicit parameter so as to implicitly transmit the request identifier, so that the service processing thread does not perceive the transfer operation of the request identifier, and the service development is facilitated. According to the embodiment, the request identifications are respectively transmitted in the HTTP mode and the RPC mode, so that the same request identification can be transmitted in different interface interaction modes, the accuracy of link tracking is guaranteed, and the application range of an application scene is also improved.
It should be noted that the interface interaction modes between the client and the first server, between the first server and the second server, and between any two second servers may be the same or different, and are set based on the service requirements. Generally, the interface interaction mode between the client and the first server may be set to an HTTP mode. The interface interaction mode between the first server and the second server and between any two second servers can be set to be RPC mode.
According to the technical scheme of the embodiment, when the current server is the first server, corresponding request identification is distributed for a data request sent by a client; when the current server is the second server, the request identifier corresponding to the data request sent by the client is obtained based on the interface interaction mode corresponding to the second server, so that the request identifier corresponding to the data request sent by the client can be transmitted in different servers, each server generates log information containing the same request identifier, and the accuracy of link tracking is further ensured.
EXAMPLE III
Fig. 3A is a schematic flow chart of a link tracking method according to a third embodiment of the present invention, and in this embodiment, based on the foregoing embodiments, further optimization is performed on "obtaining a request identifier corresponding to a data request sent by a client. On the basis, the generation process of the log information is further described in detail. Wherein explanations of the same or similar terms as those of the above-described embodiments are omitted. Referring to fig. 3A, the link tracking method provided in this embodiment specifically includes the following steps:
s310, receiving a first data request sent by a client or a last server.
S320, acquiring a request identifier corresponding to the data request sent by the client through the access filter in the current server.
Specifically, fig. 3B shows an example of a data response procedure. As shown in fig. 3B, if the current server is the first server, a thread for generating log information is started through an access filter in the first server, and a unique request identifier is assigned to a data request sent by the client. If the current server is a second server, such as a second server a or a second server B, the request identifier allocated to the data request sent by the client is obtained from the received first data request through an access filter in the second server.
S330, storing the request identification into a current MDC mapping debugging context container corresponding to the current server.
The mdc (mapped Diagnostic context) mapping debugging context can be used as a mechanism for generating log information under the condition of multithreading. Each thread for generating log information may correspond to an MDC mapped debug context container, so that the container is used to store the request identifier corresponding to the thread. The request identity included in the MDC container may be accessed by code executing in the same thread, and the child thread of the current thread inherits the request identity in the MDC container in its parent thread. The MDC container may be regarded as a storage space of the MDC, and is used for storing a request identifier corresponding to a data request of a client. Each server corresponds to an MDC container.
Specifically, as shown in fig. 3B, when acquiring a request identifier corresponding to a data request sent by a client, a current server (such as a first server, a second server a, or a second server B), the current server may store the request identifier in a corresponding MDC container, so that a thread for generating log information may obtain the request identifier from the container.
S340, based on an MDC log generation mechanism, generating log information containing a request identifier in a first data request response process according to the request identifier stored in the current MDC mapping debugging context container, wherein the data requests sent by the client correspond to the request identifier one to one.
The first data request response procedure may refer to the service processing procedure in fig. 3B. The MDC log generation mechanism may refer to generating a log based on a request identifier in an MDC container, so that all log information output by each server carries the request identifier. Specifically, the thread used by the current server to generate the log information may obtain the request identifier from the MDC container, and add the request identifier to the log information, so that the log information including the request identifier may be quickly output, thereby improving log generation efficiency and ensuring accuracy of link tracking.
S350, if the next server to be called exists in the first data request responding process, determining a second data request containing the request identifier based on an interface interaction mode corresponding to the next server, and sending the second data request to the next server so that the next server generates log information containing the request identifier in the second data request responding process; the log information generated by each server is used for: and performing link tracking on the response process of the data request sent by the client based on the request identification.
Specifically, as shown in fig. 3B, when the current server has a next server to be called in the first data request response process, for example, the first server needs to call the second server a, or the second server a needs to call the second server B, the current server may obtain the request identifier from the MDC container, so that the request identifier may be transmitted to the next server, that is, the MDC container may implement storing and reading of the request identifier. The present embodiment stores the request identifier in the MDC container, so that the current thread can obtain the request identifier in real time, thereby ensuring the accuracy of link tracking.
According to the technical scheme of the embodiment, the request identifier corresponding to the data request sent by the client is obtained through the access filter in the current server, the request identifier is stored in the current MDC mapping debugging context container corresponding to the current server, and log information containing the same request identifier is generated in the first data request response process based on an MDC log generation mechanism, so that the accuracy of link tracking can be ensured.
Example four
Fig. 4 is a schematic structural diagram of a link tracking device according to a fourth embodiment of the present invention, which is applicable to a case of performing link tracking on a response process of a data request, and especially applicable to a link tracking scenario in a distributed environment. The device sets up in current server, specifically includes: a request receiving module 410, a log information generating module 420 and a request transmitting module 430.
The request receiving module 410 is configured to receive a first data request sent by a client or a previous server; a log information generating module 420, configured to obtain a request identifier corresponding to a data request sent by a client, and generate log information including the request identifier in a first data request response process, where the data request sent by the client corresponds to the request identifier one to one; the request sending module 430 is configured to, when a next server to be called exists in a first data request response process, determine a second data request including a request identifier based on an interface interaction mode corresponding to the next server, and send the second data request to the next server, so that the next server generates log information including the request identifier in a second data request response process; the log information generated by each server is used for: and performing link tracking on the response process of the data request sent by the client based on the request identification.
Optionally, the current server includes: the client side comprises a first server and a second server, wherein the first server is used for responding to data requests sent by the client side in a user service layer, and the second server is used for responding to data requests sent by other servers in other processing layers except the user service layer.
Optionally, the request receiving module 410 is further configured to: when the current server is a first server, receiving a first data request sent by a client; when the current server is a second server, receiving a first data request sent by the previous server; the previous server is a server used for responding to the data request in a previous processing layer of a current processing layer corresponding to the current server.
Optionally, the log information generating module 420 is further configured to: when the current server is a first server, distributing corresponding request identification for a data request sent by a client; and when the current server is a second server, acquiring a request identifier corresponding to the data request sent by the client based on an interface interaction mode corresponding to the second server.
Optionally, the log information generating module 420 is further configured to: when the interface interaction mode corresponding to the second server is the HTTP mode, acquiring a request identifier corresponding to the data request sent by the client from a request header of the first data request; and when the interface interaction mode corresponding to the second server is the RPC mode, acquiring a request identifier corresponding to the data request sent by the client from a context container of the RPC mode.
Optionally, the log information generating module 420 is further configured to: and acquiring a request identifier corresponding to the data request sent by the client through an access filter in the current server.
Optionally, the log information generating module 420 is further configured to: after a request identifier corresponding to a data request sent by the client is obtained, storing the request identifier into a current MDC mapping debugging context container corresponding to a current server; based on an MDC log generation mechanism, according to a request identifier stored in a current MDC mapping debugging context container, generating log information containing the request identifier in a first data request response process.
Optionally, the request sending module 430 is further configured to: when the interface interaction mode corresponding to the next server is the HTTP mode, adding the request identifier to a request header of a second data request to obtain the second data request containing the request identifier; and when the interface interaction mode corresponding to the second server is the RPC mode, storing the request identifier in a context container of the RPC mode, and obtaining a second data request containing the request identifier.
The link tracking device provided by the embodiment of the invention can execute the link tracking method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects for executing the link tracking method.
It should be noted that, the modules included in the system are merely divided according to functional logic, but are not limited to the above division as long as the corresponding functions can be implemented; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the embodiment of the invention.
EXAMPLE five
Fig. 5 is a schematic structural diagram of a link tracking system according to a fifth embodiment of the present invention. The system can be realized by software and/or hardware, is generally integrated in a computer device, and can realize the link tracing of the response process of the data request by executing the link tracing method of the computer device. As shown in fig. 5, the system includes: a client 510 and a plurality of servers 520. Client 510 is configured to send a data request to a server among plurality of servers 520 that is configured to receive the data request; each server 520 is configured to implement a link tracing method as provided by embodiments of the present invention.
As shown in fig. 5, the server may include a first server or a second server, where the first server refers to a server in the user service layer for responding to a data request sent by a client, and the second server refers to a server in a processing layer other than the user service layer for responding to a data request sent by another server.
The specific link tracking procedure provided by this embodiment may be: the first server receives a first data request sent by a client, acquires a request identifier corresponding to the data request sent by the client, and generates log information containing the request identifier in a first data request response process. If the first server has a next server to be called (for example, a second server a) in the first data request response process, determining a second data request including the request identifier based on an interface interaction mode corresponding to the second server a, and sending the second data request to the second server a, where the second server a receives the second data request sent by the first server and generates log information including the same request identifier in the second data request response process in the same processing manner as described above until the current server does not call other servers in the data request response process, so that each server sequentially called in the data request response process sent by the client can generate log information including the same request identifier, and therefore, the data request sent by the client can be subjected to full-link tracking based on the request identifier in all the generated log information, thereby enabling link tracing at the log level.
According to the link tracking system provided by the embodiment of the invention, each server called in the process of responding to the data request sent by the client can generate the log information containing the same request identifier, so that the link tracking can be performed on the response process of the data request sent by the client based on the request identifier in all the generated log information, and the full link tracking at the log level is realized. And because each server only needs to generate log information containing the same request identifier, operations such as data acquisition, format conversion, storage and the like are not needed, the link tracking framework is greatly simplified, the development efficiency is improved, the link tracking framework can be directly deployed in the server for responding to the data request, an additional server is not needed, and the development cost is greatly reduced.
EXAMPLE six
Fig. 6 is a schematic structural diagram of a server according to a sixth embodiment of the present invention. FIG. 6 illustrates a block diagram of an exemplary server 60 suitable for use in implementing embodiments of the present invention. The server 60 shown in fig. 6 is only an example, and should not bring any limitation to the function and the scope of use of the embodiment of the present invention.
As shown in FIG. 6, the server 60 is in the form of a general purpose computing device. The components of server 60 may include, but are not limited to: one or more processors or processing units 601, a system memory 602, and a bus 603 that couples various system components including the system memory 602 and the processing unit 601.
Bus 603 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
The server 60 typically includes a variety of computer system readable media. Such media may be any available media that is accessible by device 60 and includes both volatile and nonvolatile media, removable and non-removable media.
The system memory 602 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)604 and/or cache memory 605. The server 60 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 406 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 6, commonly referred to as a "hard drive"). Although not shown in FIG. 6, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 603 by one or more data media interfaces. Memory 602 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 608 having a set (at least one) of program modules 607 may be stored, for example, in memory 602, such program modules 607 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. The program modules 607 generally perform the functions and/or methods of the described embodiments of the invention.
The server 60 may also communicate with one or more external devices 609 (e.g., keyboard, pointing device, display 610, etc.), with one or more devices that enable a user to interact with the server 60, and/or with any devices (e.g., network card, modem, etc.) that enable the server 60 to communicate with one or more other computing devices. Such communication may occur via an input/output (I/O) interface 611. Also, the server 60 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN) and/or a public network, such as the Internet) via a network adapter 612. As shown, the network adapter 612 communicates with the other modules of the server 60 via the bus 603. It should be appreciated that although not shown in FIG. 6, other hardware and/or software modules may be used in conjunction with the server 60, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
The processing unit 601 executes various functional applications and data processing by running a program stored in the system memory 602, for example, to implement the steps of the link tracking method provided by the embodiment of the present invention, the method includes:
receiving a first data request sent by a client or a previous server;
acquiring a request identifier corresponding to a data request sent by a client, and generating log information containing the request identifier in a first data request response process, wherein the data request sent by the client corresponds to the request identifier one to one;
if the next server to be called exists in the first data request response process, determining a second data request containing the request identifier based on an interface interaction mode corresponding to the next server, and sending the second data request to the next server so that the next server generates log information containing the request identifier in the second data request response process;
the log information generated by each server is used for: and performing link tracking on the response process of the data request sent by the client based on the request identification.
Of course, those skilled in the art will understand that the processor may also implement the technical solution of the link tracking method provided in any embodiment of the present invention.
EXAMPLE seven
The present embodiment provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the link tracing method as provided in any of the embodiments of the present invention, the method comprising:
receiving a first data request sent by a client or a previous server;
acquiring a request identifier corresponding to a data request sent by a client, and generating log information containing the request identifier in a first data request response process, wherein the data request sent by the client corresponds to the request identifier one to one;
if the next server to be called exists in the first data request response process, determining a second data request containing the request identifier based on an interface interaction mode corresponding to the next server, and sending the second data request to the next server so that the next server generates log information containing the request identifier in the second data request response process;
the log information generated by each server is used for: and performing link tracking on the response process of the data request sent by the client based on the request identification.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for embodiments of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (12)

1. A link tracing method is applied to a current server and comprises the following steps:
receiving a first data request sent by a client or a previous server;
acquiring a request identifier corresponding to a data request sent by the client, and generating log information containing the request identifier in a first data request response process, wherein the data request sent by the client corresponds to the request identifier one to one;
if the next server to be called exists in the first data request response process, determining a second data request containing the request identifier based on an interface interaction mode corresponding to the next server, and sending the second data request to the next server, so that the next server generates log information containing the request identifier in the second data request response process;
the log information generated by each server is used for: and performing link tracking on the response process of the data request sent by the client based on the request identification.
2. The method of claim 1, wherein the current server comprises: the client side comprises a first server and a second server, wherein the first server is used for responding to data requests sent by the client side in a user service layer, and the second server is used for responding to data requests sent by other servers in other processing layers except the user service layer.
3. The method of claim 2, wherein receiving the first data request sent by the client or the last server comprises:
if the current server is a first server, receiving a first data request sent by a client;
if the current server is a second server, receiving a first data request sent by the previous server;
the previous server is a server used for responding to the data request in a previous processing layer of a current processing layer corresponding to the current server.
4. The method of claim 2, wherein obtaining the request identifier corresponding to the data request sent by the client comprises:
if the current server is a first server, distributing a corresponding request identifier for a data request sent by a client;
and if the current server is a second server, acquiring a request identifier corresponding to the data request sent by the client based on an interface interaction mode corresponding to the second server.
5. The method according to claim 4, wherein obtaining a request identifier corresponding to the data request sent by the client based on the interface interaction mode corresponding to the second server includes:
if the interface interaction mode corresponding to the second server is the HTTP mode, acquiring a request identifier corresponding to the data request sent by the client from a request header of the first data request;
and if the interface interaction mode corresponding to the second server is an RPC mode, acquiring a request identifier corresponding to the data request sent by the client from a context container of the RPC mode.
6. The method of claim 1, wherein obtaining the request identifier corresponding to the data request sent by the client comprises:
and acquiring a request identifier corresponding to the data request sent by the client through an access filter in the current server.
7. The method according to claim 1, further comprising, after obtaining a request identifier corresponding to the data request sent by the client, the following steps:
storing the request identifier into a current MDC mapping debugging context container corresponding to the current server;
the generating log information containing the request identifier in the first data request response process comprises:
and based on an MDC log generation mechanism, generating log information containing the request identifier in a first data request response process according to the request identifier stored in the current MDC mapping debugging context container.
8. The method according to any of claims 1-7, wherein determining the second data request including the request identifier based on the interface interaction pattern corresponding to the next server comprises:
if the interface interaction mode corresponding to the next server is an HTTP mode, adding the request identifier to a request header of a second data request to obtain the second data request containing the request identifier;
and if the interface interaction mode corresponding to the second server is an RPC mode, storing the request identifier in a context container of the RPC mode, and acquiring a second data request containing the request identifier.
9. A link tracking device, disposed on a current server, comprising:
the request receiving module is used for receiving a first data request sent by a client or a previous server;
the log information generating module is used for acquiring a request identifier corresponding to a data request sent by the client and generating log information containing the request identifier in a first data request response process, wherein the data request sent by the client corresponds to the request identifier one by one;
a request sending module, configured to, when a next server to be called exists in a first data request response process, determine, based on an interface interaction mode corresponding to the next server, a second data request including the request identifier, and send the second data request to the next server, so that the next server generates log information including the request identifier in a second data request response process;
the log information generated by each server is used for: and performing link tracking on the response process of the data request sent by the client based on the request identification.
10. A link tracking system, the system comprising: a client and a plurality of servers, wherein,
the client is used for sending a data request to a server used for receiving the data request in the plurality of servers;
each of said servers being adapted to implement the link tracing method according to any one of claims 1-8.
11. A server, characterized in that the server comprises:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement the link tracing method as recited in any of claims 1-8.
12. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the link tracing method according to any one of claims 1 to 8.
CN202011062658.7A 2020-09-30 2020-09-30 Link tracking method, device, system, server and storage medium Pending CN113760562A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011062658.7A CN113760562A (en) 2020-09-30 2020-09-30 Link tracking method, device, system, server and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011062658.7A CN113760562A (en) 2020-09-30 2020-09-30 Link tracking method, device, system, server and storage medium

Publications (1)

Publication Number Publication Date
CN113760562A true CN113760562A (en) 2021-12-07

Family

ID=78785790

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011062658.7A Pending CN113760562A (en) 2020-09-30 2020-09-30 Link tracking method, device, system, server and storage medium

Country Status (1)

Country Link
CN (1) CN113760562A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114003472A (en) * 2022-01-04 2022-02-01 连连(杭州)信息技术有限公司 Data processing method and device, electronic equipment and storage medium
CN115022410A (en) * 2022-05-27 2022-09-06 北京有竹居网络技术有限公司 Network request tracking method, device and equipment

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114003472A (en) * 2022-01-04 2022-02-01 连连(杭州)信息技术有限公司 Data processing method and device, electronic equipment and storage medium
CN114003472B (en) * 2022-01-04 2022-04-12 连连(杭州)信息技术有限公司 Data processing method and device, electronic equipment and storage medium
CN115022410A (en) * 2022-05-27 2022-09-06 北京有竹居网络技术有限公司 Network request tracking method, device and equipment

Similar Documents

Publication Publication Date Title
CN111083225B (en) Data processing method and device in Internet of things platform and Internet of things platform
US11159411B2 (en) Distributed testing service
US7673029B2 (en) Grid automation bus to integrate management frameworks for dynamic grid management
CN111913818B (en) Method for determining dependency relationship between services and related device
CN110069358A (en) Call chain trace analysis method, apparatus, electronic equipment and storage medium
US11294740B2 (en) Event to serverless function workflow instance mapping mechanism
CN111737022A (en) Interface calling method, system, equipment and medium based on micro-service
CN113760562A (en) Link tracking method, device, system, server and storage medium
CN112256406B (en) Operation flow platformization scheduling method
CN114398179B (en) Method and device for acquiring tracking identifier, server and storage medium
CN112448969A (en) Link tracking method, device, system, equipment and readable storage medium
CN114490268A (en) Full link monitoring method, device, equipment, storage medium and program product
CN114745295A (en) Data acquisition method, device, equipment and readable storage medium
CN114221995B (en) Service calling method and device and electronic equipment
CN112417016B (en) Data exchange method, system, equipment and storage medium
US10402307B2 (en) System and method for providing runtime tracing for a web-based client accessing a transactional middleware platform using an extension interface
CN112765246A (en) Task processing method and device, electronic equipment and storage medium
CN114567571B (en) Performance test method, device, electronic equipment and computer readable storage medium
CN114513553A (en) Data processing method and device, electronic equipment and storage medium
CN112685252A (en) Micro-service monitoring method, device, equipment and storage medium
CN115129708A (en) Data processing method, data processing device, storage medium and electronic equipment
CN113741912A (en) Model management system, method, device and equipment
CN117632445B (en) Request processing method and device, task execution method and device
WO2019164428A1 (en) Method and first node for managing transmission of probe messages
CN115396525B (en) Data interaction method and device based on service template mapping

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