A network request tracking method, device and equipment

By saving the corresponding relationship between the request identification and the execution unit identification in the distributed tracing system, the problem of poor reliability of request identification transmission is solved, and efficient call chain tracking and concise code maintenance are achieved.

CN115022410BActive Publication Date: 2024-10-01BEIJING YOUZHUJU NETWORK TECH CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202210591031.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-27
Publication Date
2024-10-01
Estimated Expiration
2042-05-27

AI Technical Summary

Technical Problem

In a distributed tracing system, the request identifier of a network request is easily missed during the delivery process, resulting in poor reliability and requiring users to manually write delivery code in each sub-method, affecting code maintenance.

Method used

By receiving network requests, obtain the request identification, determine the corresponding execution unit, save the correspondence between the request identification and the execution unit identification, and when the execution unit calls the target server, obtain and send the request identification from the corresponding relationship to avoid layer-by-layer Pass the request ID.

Benefits of technology

It improves the reliability of request identification transmission, reduces the request identification omission rate, improves the accuracy of call chain tracking and the maintainability of services, simplifies the code, and reduces troubleshooting time and research and development costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115022410B_ABST
    Figure CN115022410B_ABST
Patent Text Reader

Abstract

The present application discloses a network request tracking method, device and equipment, which receive a network request and obtain a request identifier of the network request. Then, determine the execution unit corresponding to the network request, and obtain the execution unit identifier of the execution unit. Save the correspondence between the request identifier and the execution unit identifier. In response to the execution unit calling the target server, obtain the request identifier corresponding to the execution unit identifier of the execution unit from the saved correspondence, and send the request identifier to the target server. It can be seen that by pre-saving the correspondence between the execution unit identifier and the request identifier, when the execution unit needs to obtain the request identifier, it can directly obtain the required request identifier from the correspondence according to the execution unit identifier. In this way, each sub-method of the service does not need to pass the request identifier layer by layer, which can enhance the reliability of the request identifier transmission.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a network request tracking method, device and equipment. Background Art

[0002] With the continuous development of application development technology, micro-server architecture has emerged, which can be used for application development, deployment and operation and maintenance. Distributed tracing system is an important part of micro-server architecture, which can obtain the call relationship between services, locate errors and debug online problems.

[0003] In the distributed tracing system, a request identifier is set for the network request. Starting from the initiation of the network request, the request identifier is passed in the process of layer-by-layer dependency services and response tracking. Finally, logs are collected, error information is printed, and the time taken to obtain responses is obtained based on the request identifier. In this way, the network request can be traced based on the request identifier.

[0004] At present, after receiving a network request and a request identifier, the device will assemble the request identifier into a context object during the process of transmitting the request identifier, and use the context object to transparently transmit the request identifier in each sub-method of each service of the device. However, in this process, the user needs to manually write the transmission process of the context object containing the request identifier into the code of each sub-method. In this way, it is easy for the request identifier to be missed, and the reliability is poor. Summary of the invention

[0005] In view of this, embodiments of the present application provide a network request tracking method, apparatus, and device, which can improve the reliability of request identifiers for transmitting network requests.

[0006] To solve the above problems, the technical solutions provided in the embodiments of the present application are as follows:

[0007] In a first aspect, an embodiment of the present application provides a network request tracking method, the method comprising:

[0008] Receiving a network request and obtaining a request identifier of the network request;

[0009] Determine the execution unit corresponding to the network request, and obtain the execution unit identifier of the execution unit;

[0010] Saving the correspondence between the request identifier and the execution unit identifier;

[0011] In response to the execution unit calling the target server, obtaining a request identifier corresponding to the execution unit identifier of the execution unit from the corresponding relationship;

[0012] The request identifier is sent to the target server.

[0013] In a second aspect, an embodiment of the present application provides a network request tracking device, the device comprising:

[0014] A first acquisition unit, configured to receive a network request and acquire a request identifier of the network request;

[0015] A second acquisition unit, used to determine the execution unit corresponding to the network request, and acquire the execution unit identifier of the execution unit;

[0016] A storage unit, used for storing the corresponding relationship between the request identifier and the execution unit identifier;

[0017] a third acquisition unit, configured to acquire, in response to the execution unit calling the target server, a request identifier corresponding to the execution unit identifier of the execution unit from the corresponding relationship;

[0018] A sending unit is used to send the request identifier to the target server.

[0019] In a third aspect, an embodiment of the present application provides an electronic device, comprising: one or more processors; a memory; and one or more computer programs; wherein the one or more computer programs are stored in the memory; and characterized in that when the one or more processors execute the one or more computer programs, the electronic device implements the network request tracking method as described above.

[0020] In a fourth aspect, an embodiment of the present application provides a computer storage medium, including computer instructions, which, when executed on an electronic device, enables the electronic device to execute the network request tracking method as described above.

[0021] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the network request tracking method as described above.

[0022] It can be seen that the embodiments of the present application have the following beneficial effects:

[0023] The embodiments of the present application provide a network request tracking method, device and equipment, which receive a network request and obtain a request identifier of the network request. Then, determine the execution unit corresponding to the network request, and obtain the execution unit identifier of the execution unit. Save the correspondence between the request identifier and the execution unit identifier. When the execution unit calls the target server, in response to the execution unit calling the target server, obtain the request identifier corresponding to the execution unit identifier of the execution unit from the saved correspondence, and send the request identifier to the target server. It can be seen that in the embodiments of the present application, the correspondence between the execution unit identifier and the request identifier is saved in advance. When the execution unit needs to obtain the request identifier, the required request identifier can be directly obtained from the correspondence according to the execution unit identifier. In this way, the request identifier does not need to be passed layer by layer in each sub-method of the service, which can enhance the reliability of the request identifier transmission. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 A schematic diagram of transmitting a request identifier of a network request in the related art;

[0025] Figure 2 A schematic diagram of an exemplary application scenario provided for an embodiment of the present application;

[0026] Figure 3 A flowchart of a network request tracking method provided in an embodiment of the present application;

[0027] Figure 4 A schematic diagram of transmitting a request identifier of another network request provided in an embodiment of the present application;

[0028] Figure 5 A schematic diagram of transmitting a request identifier of another network request provided in an embodiment of the present application;

[0029] Figure 6 A schematic diagram of the structure of a network request tracking device provided in an embodiment of the present application;

[0030] Figure 7 A schematic diagram of the basic structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0031] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the embodiments of the present application are further described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0032] In order to facilitate the understanding and explanation of the technical solutions provided by the embodiments of the present application, the background technology involved in the embodiments of the present application is first introduced.

[0033] With the continuous development of application development technology, micro-server architecture has emerged, which can be used for application development, deployment and operation and maintenance. Distributed tracing system is an important part of micro-server architecture, which can obtain the call relationship between services, locate errors, analyze call links and debug online problems.

[0034] In a distributed tracing system, a request identifier for a network request is set. Starting from the initiation of the network request, the request identifier is passed in the process of layer-by-layer dependency on services and tracking responses. The request identifier can mark the order in which the service calls the network request and the nested relationship between services. Finally, the logs are collected, error information is printed, and the time consumed to obtain the response is calculated based on the request identifier. In this way, the network request can be traced based on the request identifier, and then the error can be quickly located, the call relationship can be obtained, and the call link can be analyzed.

[0035] See also Figure 1 , Figure 1 A schematic diagram of transmitting a request identifier of a network request in the related art. Figure 1 The following shows the transmission process of request identifiers in the current related methods. Figure 1 As shown, a device, such as a server Service Y, can receive a network request and a request identifier trace-id from a server Service X. Then, in the process of transmitting the trace-id, Service Y will assemble the trace-id into the context object context, and use the context to transparently transmit the trace-id in each sub-method of the service (such as Service Y). Among them, the execution unit is used to implement each sub-method of each service. For example, Figure 1 In function-a, function-b, function-a1, function-a2 and other sub-methods, ctx (i.e. context object context) is used to pass trace-id. When sub-method function-a1 needs to call server Service Z, sub-method function-a2 needs to call server Service U, or sub-method function-b needs to call database DB, context can be used to pass trace-id to the corresponding server or database.

[0036] However, in this process, users need to manually write code to pass the context containing trace-id in each sub-method. In this way, if a sub-method does not write the code to pass the context, it is easy for trace-id to be missed, which leads to poor reliability. In addition, passing trace-id, an additional parameter that is irrelevant to the business of the sub-method, in each sub-method is not conducive to code maintenance.

[0037] Based on this, the embodiment of the present application provides a network request tracking method, device and equipment, which receives a network request and obtains the request identifier of the network request. Then, determine the execution unit corresponding to the network request, and obtain the execution unit identifier of the execution unit. Save the correspondence between the request identifier and the execution unit identifier. When the execution unit calls the target server, in response to the execution unit calling the target server, obtain the request identifier corresponding to the execution unit identifier of the execution unit from the saved correspondence, and send the request identifier to the target server. It can be seen that in the embodiment of the present application, the correspondence between the execution unit identifier and the request identifier is saved in advance. When the execution unit needs to obtain the request identifier, it can directly obtain the required request identifier from the correspondence according to the execution unit identifier. In this way, the request identifier does not need to be passed layer by layer in each sub-method of the service, which can enhance the reliability of the request identifier transmission.

[0038] In order to facilitate understanding of the network request tracking method provided in the embodiment of the present application, Figure 2 See the example scenario shown. Figure 2 As shown, this figure is a schematic diagram of the framework of an exemplary application scenario provided by an embodiment of the present application. The method can be applied to the current server 201, for example, the current server 201 is Service Y.

[0039] In actual application, the current server 201 can receive a network request from a client or other server, and can obtain a request identifier of the network request. Further, the current server 201 determines the execution unit corresponding to the network request, obtains the execution unit identifier of the execution unit, and saves the corresponding relationship between the request identifier and the execution unit identifier. Among them, the execution unit is used to execute the network request.

[0040] If the execution unit in the current server 201 needs to call the target server 202 (for example, Service Z) to realize the transfer of the request identifier, the current server 201 responds to the execution unit calling the target server, obtains the corresponding request identifier from the corresponding relationship according to the execution unit identifier, and then sends the request identifier to the target server to realize the transfer of the request identifier and complete the tracking of the network request.

[0041] Those skilled in the art will understand that Figure 2 The framework diagram shown is only an example in which the embodiments of the present application can be implemented. The scope of application of the embodiments of the present application is not limited by any aspect of the framework.

[0042] To facilitate understanding of the present application, a network request tracking method provided in an embodiment of the present application is described below with reference to the accompanying drawings.

[0043] See also Figure 3 As shown, this figure is a flow chart of a network request tracking method provided by an embodiment of the present application, and the method can be applied to the current server described in the above embodiment, for example, the current server is Service Y. Figure 3 As shown, the method may include S301-S305:

[0044] S301: Receive a network request and obtain a request identifier of the network request.

[0045] The current server can receive a network request sent from a client or other server or other device. For example, the current server Service Y can receive a network request from a server Service X. The network request carries a request identifier of the network request. After the current server receives the network request, it can obtain the request identifier of the network request. In an embodiment of the present application, the request identifier of the network request can be represented by a trace-id.

[0046] In the embodiment of the present application, there is at least one network request, and the present application does not limit the specific number of network requests. Figure 4 , Figure 4 A schematic diagram of transmitting another request identifier of a network request provided in an embodiment of the present application. Figure 4 As shown, Service Y receives three network requests, namely network request 1, network request 2 and network request 3, and the corresponding request identifiers are represented by trace-id1, trace-id2 and trace-id3 respectively.

[0047] S302: Determine the execution unit corresponding to the network request, and obtain the execution unit identifier of the execution unit.

[0048] After the current server receives the network request, it starts to perform call tracking in each sub-service of the current server. In specific implementation, the current server will assign an execution unit to each network request, and the execution unit is used to execute / process the network request. It can be understood that if the current server receives multiple network requests, an execution unit is assigned to each network request. Some of the multiple network requests may be the same, or may be different. Accordingly, the execution unit corresponding to the network request may execute the same network request, or may execute different network requests.

[0049] like Figure 4As shown, after Service Y receives network request 1, network request 2 and network request 3, it allocates execution unit T1, execution unit T2 and execution unit T3 to the three network requests respectively. T1, T2 and T3 are the execution unit identifiers of the corresponding execution units.

[0050] S303: Save the correspondence between the request identifier and the execution unit identifier.

[0051] After obtaining the request identifier of the network request and the execution unit identifier of the execution unit used to process the network request, the current server saves the corresponding relationship between the request identifier and the execution unit identifier. For example, when the request identifier of network request 1 is trace-id1, and the execution unit identifier of the execution unit processing network request 1 is T1, the saved corresponding relationship is T1->trace-id1. Similarly, the corresponding relationship T2->trace-id2 and the corresponding relationship T3->trace-id3 can also be saved.

[0052] It can be understood that the correspondence between the storage request identifier and the execution unit identifier provided in the embodiment of the present application is implemented based on the execution unit (or so-called computing execution unit) allocated to the network request.

[0053] Usually, in single-threaded mode, there is only one copy of the variables for the entire program life cycle, corresponding to one execution unit. In multi-threaded mode, some variables need to support private functions for each thread, and the private variables of each thread are placed in a storage area dedicated to each thread. TLS (Thread Local Storage) can be understood as the private variables of each thread in multi-threaded mode, specifically private global variables (or global objects). In multi-threaded mode, each thread in the multi-threaded mode can use TLS to allocate a location for storing thread-specific data.

[0054] Based on the above content, in a possible implementation manner, the embodiment of the present application provides a specific implementation manner of saving the correspondence between the request identifier and the execution unit identifier, including:

[0055] In the thread local storage, the correspondence between the request identifier and the execution unit identifier is saved.

[0056] It can be understood that, in the thread local storage, saving the correspondence between the request identifier and the execution unit identifier is a way of storing the correspondence based on the execution unit.

[0057] Since different programming languages ​​use different storage methods, the storage correspondence method based on TLS (or similar to TLS) is only an example, and the embodiments of the present application are not limited to storage based on threads. In one possible implementation, Node.js is stored based on the event loop, and the currently executed Async Id can be obtained and stored through Async_hooks. In another possible implementation, Golang is stored based on Goroutine scheduling, and the current Goroutine Id can be obtained and stored through Runtime. It can be understood that no matter what specific storage method is used, it is essentially based on the storage of the corresponding relationship implemented by the execution unit, that is, the corresponding relationship is the relationship between the request identifier and the execution unit identifier.

[0058] As an optional example, the network request tracking method further includes initializing a global object of a Map structure. Based on this, in a possible implementation, the embodiment of the present application further provides a specific implementation method for saving the correspondence between the request identifier and the execution unit identifier, including:

[0059] Write the correspondence between the request identifier and the execution unit identifier into the global object.

[0060] That is, the correspondence between the request identifier and the execution unit identifier is written into the global object of the Map structure, so that each execution unit can obtain the stored correspondence from the corresponding global object of the Map structure.

[0061] Based on the above description of TLS and global objects of Map structure, in a possible implementation, the embodiment of the present application provides a specific implementation method of initializing a global object of Map structure, including:

[0062] Initialize a global object of Map structure in thread local storage.

[0063] Thus, the correspondence between the request identifier and the execution unit identifier can be written into the global object of the Map structure in TLS. It is understandable that when the programming language is different, the global object of the MAP structure can also be initialized in Async_hooks or Runtime.

[0064] For example, Figure 4As shown, the global object S1 of TLS with a Map structure is initialized. When receiving a network request 1 carrying a request identifier trace-id1, Service Y distributes an execution unit T1 to the network request 1. At this time, the corresponding relationship {T1, traceid1} between the request identifier trace-id1 and the execution unit T1 is written in the global object S1. Similarly, the global objects S2 and S3 are initialized, and the corresponding relationship {T2, traceid2} between the request identifier trace-id2 and the execution unit T2 is written in the global object S2, and the corresponding relationship {T3, traceid3} between the request identifier trace-id3 and the execution unit T3 is written in the global object S3.

[0065] S304: In response to the execution unit calling the target server, obtaining a request identifier corresponding to the execution unit identifier of the execution unit from the corresponding relationship.

[0066] The execution unit in the current server can call the target server, for example Figure 4 As shown, the target server is Service Z. When the execution unit in the current server calls the target server, in response to the execution unit calling the target server, the current server obtains the request identifier corresponding to the execution unit identifier of the execution unit from the corresponding relationship.

[0067] In a possible implementation, an embodiment of the present application provides a specific implementation of obtaining a request identifier corresponding to an execution unit identifier of the execution unit from a corresponding relationship in response to the execution unit calling a target server, including:

[0068] In response to the execution unit calling the target server, a request identifier corresponding to the execution unit identifier of the execution unit is searched from the global object.

[0069] For example, Figure 4 As shown, when the execution unit T1 calls the target server Service Z, the execution unit identifier T1 of the execution unit is obtained, and based on the execution unit identifier T1, the request identifier trace-id1 corresponding to the execution unit identifier T1 is queried in the TLS global object S1.

[0070] S305: Send the request identifier to the target server.

[0071] After obtaining the request identifier, the current server sends the request identifier to the target server. Specifically, after the execution unit of the current server obtains the request identifier, the execution unit of the current server sends the request identifier to the target server.

[0072] like Figure 4As shown, after obtaining the request identifier trace-id1, the execution unit T1 sends the request identifier trace-id1 to the target server Service Z. Specifically, in actual applications, the request identifier will be sent to the target server together with the network request generated by the execution unit.

[0073] It is understandable that after the target server Service Z receives the network request and the request identifier of the network request, the target server Service Z will repeatedly execute S301-S305 to continue to pass the request identifier to the calling downstream.

[0074] It should be noted that the network request tracking method provided in the embodiment of the present application is a link tracking optimization method for all microservice architectures, and all services in the entire server can be executed according to this method.

[0075] See also Figure 5 , Figure 5 A schematic diagram of transmitting a request identifier of another network request provided in an embodiment of the present application. Figure 5 This is a schematic diagram of the transmission of the request identifier using the S301-S305 method in the embodiment of the present application. Figure 5 It can be seen that compared with Figure 4 , instead of the context object context, the embodiment of the present application can use TLS to implement the storage of the corresponding relationship, and can obtain the request identifier according to the saved corresponding relationship to realize the transmission of the request identifier to the downstream of the call.

[0076] See Table 1, which is a comparison of a method of transparently transmitting a request identifier based on a context object context and a method of obtaining and transmitting a request identifier based on a correspondence between an execution unit identifier and a request identifier stored in a global object in an embodiment of the present application.

[0077] Table 1 Comparison of two ways of transmitting request identifiers

[0078]

[0079] As shown in Table 1, in the current request identifier transmission method, the code for transmitting the context object context including the request identifier needs to be manually written in each sub-method of each service, which is prone to omission. Once the request identifier is omitted, the call chain tracking will be interrupted. Moreover, in the current request identifier transmission method, the request identifier is not a business parameter, and it is a redundant parameter for the business logic of the sub-method. The service passes additional redundant parameters in the sub-method, which reduces the maintainability of the service.

[0080] In an embodiment of the present application, the correspondence between the request identifier and the execution unit identifier is stored through the global object of TLS. When the request identifier needs to be passed, the request identifier is obtained from the saved correspondence. It can be seen that the network request tracking method provided in the embodiment of the present application can reduce the omission rate of tracking request identifiers in the server as much as possible, so that the call chain can be completely connected in series. In this way, it helps to improve the accuracy of call chain tracking and the maintainability of the service, and can also reduce the time cost of problem tracking and troubleshooting for each service. In addition, since the network request tracking method provided in the embodiment of the present application does not require the additional transmission of redundant parameters, the code tends to be concise, which can reduce the time cost of research and development of each service.

[0081] The embodiment of the present application provides a network request tracking method, which receives a network request and obtains a request identifier of the network request. Then, the execution unit corresponding to the network request is determined, and the execution unit identifier of the execution unit is obtained. The correspondence between the request identifier and the execution unit identifier is saved. When the execution unit calls the target server, in response to the execution unit calling the target server, the request identifier corresponding to the execution unit identifier of the execution unit is obtained from the saved correspondence, and the request identifier is sent to the target server. It can be seen that in the embodiment of the present application, the correspondence between the execution unit identifier and the request identifier is saved in advance, and when the execution unit needs to obtain the request identifier, the required request identifier can be directly obtained from the correspondence according to the execution unit identifier. In this way, instead of manually writing the context object including the request identifier into each sub-method of the service, that is, each sub-method of the service does not need to pass the request identifier layer by layer, the reliability of the request identifier transmission can be enhanced.

[0082] In a possible implementation, the embodiment of the present application further provides another network request tracing method. In addition to S301-S305, the network request tracing method further includes:

[0083] After the execution unit finishes executing, the correspondence between the request identifier and the execution unit identifier is deleted.

[0084] In this way, the correspondence between the new request identifier and the new execution unit identifier can be stored.

[0085] Specifically, when the correspondence between the request identifier and the execution unit identifier is stored in a global object, in a possible implementation, the embodiment of the present application further provides another network request tracing method, which, in addition to S301-S305, also includes:

[0086] After the execution of the execution unit is completed, the corresponding relationship between the request identifier and the execution unit identifier is deleted from the global object.

[0087] Thus, the global object can be released to store the corresponding relationship between the new request identifier and the new execution unit identifier.

[0088] Based on a network request tracing method provided by the above method embodiment, the embodiment of the present application also provides a network request tracing device, which will be described below in conjunction with the accompanying drawings.

[0089] See also Figure 6 As shown in FIG. 1 , this figure is a schematic diagram of the structure of a network request tracking device provided by an embodiment of the present application. Figure 6 As shown, the network request tracking device includes:

[0090] The first acquisition unit 601 is used to receive a network request and acquire a request identifier of the network request;

[0091] A second acquisition unit 602 is used to determine the execution unit corresponding to the network request and acquire the execution unit identifier of the execution unit;

[0092] A storage unit 603 is used to store the corresponding relationship between the request identifier and the execution unit identifier;

[0093] A third acquisition unit 604 is used for acquiring, in response to the execution unit calling the target server, a request identifier corresponding to the execution unit identifier of the execution unit from the corresponding relationship;

[0094] The sending unit 605 is configured to send the request identifier to the target server.

[0095] In a possible implementation, the storage unit 603 is specifically configured to:

[0096] In the thread local storage, the correspondence between the request identifier and the execution unit identifier is saved.

[0097] In a possible implementation manner, the device further includes:

[0098] Initialization unit, used to initialize the global object of Map structure;

[0099] The storage unit 603 is specifically used for:

[0100] The correspondence between the request identifier and the execution unit identifier is written into the global object.

[0101] In a possible implementation, the initialization unit is specifically used to:

[0102] Initialize a global object of Map structure in thread local storage.

[0103] In a possible implementation, the third obtaining unit 604 is specifically configured to:

[0104] In response to the execution unit calling the target server, searching the global object for a request identifier corresponding to the execution unit identifier of the execution unit.

[0105] In a possible implementation manner, the device further includes:

[0106] The first deleting unit is used to delete the corresponding relationship between the request identifier and the execution unit identifier after the execution of the execution unit is completed.

[0107] In a possible implementation manner, the device further includes:

[0108] The second deleting unit is used to delete the corresponding relationship between the request identifier and the execution unit identifier from the global object after the execution of the execution unit is completed.

[0109] Based on a network request tracking method provided by the above method embodiment, the present application also provides an electronic device, including: one or more processors; a storage device, on which one or more programs are stored, when the one or more programs are executed by the one or more processors, the one or more processors implement the network request tracking method described in any of the above embodiments.

[0110] Reference below Figure 7 , which shows a schematic diagram of the structure of an electronic device 1300 suitable for implementing the embodiment of the present application. The terminal device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (portable android devices), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs (televisions), desktop computers, etc. Figure 7 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0111] like Figure 7As shown, the electronic device 1300 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 1301, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1302 or a program loaded from a storage device 1306 into a random access memory (RAM) 1303. In the RAM 1303, various programs and data required for the operation of the electronic device 1300 are also stored. The processing device 1301, the ROM 1302, and the RAM 1303 are connected to each other via a bus 1304. An input / output (I / O) interface 1305 is also connected to the bus 1304.

[0112] Typically, the following devices may be connected to the I / O interface 1305: an input device 1306 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 1307 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 1306 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1309. The communication device 1309 may allow the electronic device 1300 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 7 The electronic device 1300 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0113] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 1309, or installed from the storage device 1306, or installed from the ROM 1302. When the computer program is executed by the processing device 1301, the above-mentioned functions defined in the method of the embodiment of the present application are executed.

[0114] The electronic device provided in the embodiment of the present application and the network request tracking method provided in the above embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0115] Based on a network request tracing method provided by the above method embodiment, an embodiment of the present application provides a computer-readable medium on which a computer program is stored, wherein when the program is executed by a processor, the network request tracing method as described in any of the above embodiments is implemented.

[0116] It should be noted that the computer-readable medium mentioned above in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0117] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0118] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0119] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the network request tracking method.

[0120] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0121] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0122] The units involved in the embodiments described in this application may be implemented by software or hardware. The name of a unit / module does not limit the unit itself in some cases. For example, a voice data acquisition module may also be described as a "data acquisition module".

[0123] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.

[0124] In the context of the present application, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0125] According to one or more embodiments of the present application, [Example 1] provides a network request tracing method, the method comprising:

[0126] Receiving a network request and obtaining a request identifier of the network request;

[0127] Determine the execution unit corresponding to the network request, and obtain the execution unit identifier of the execution unit;

[0128] Saving the correspondence between the request identifier and the execution unit identifier;

[0129] In response to the execution unit calling the target server, obtaining a request identifier corresponding to the execution unit identifier of the execution unit from the corresponding relationship;

[0130] The request identifier is sent to the target server.

[0131] According to one or more embodiments of the present application, [Example 2] provides a network request tracking method, wherein the storing of the correspondence between the request identifier and the execution unit identifier includes:

[0132] In the thread local storage, the correspondence between the request identifier and the execution unit identifier is saved.

[0133] According to one or more embodiments of the present application, [Example 3] provides a network request tracing method, the method further comprising:

[0134] Initialize the global object of Map structure;

[0135] The storing the correspondence between the request identifier and the execution unit identifier includes:

[0136] The correspondence between the request identifier and the execution unit identifier is written into the global object.

[0137] According to one or more embodiments of the present application, [Example 4] provides a network request tracking method, wherein the global object of the initialization Map structure includes:

[0138] Initialize a global object of Map structure in thread local storage.

[0139] According to one or more embodiments of the present application, [Example 5] provides a network request tracing method, wherein in response to the execution unit calling the target server, obtaining the request identifier corresponding to the execution unit identifier of the execution unit from the corresponding relationship includes:

[0140] In response to the execution unit calling the target server, searching the global object for a request identifier corresponding to the execution unit identifier of the execution unit.

[0141] According to one or more embodiments of the present application, [Example 6] provides a network request tracing method. After the execution unit is executed, the method further includes:

[0142] The correspondence between the request identifier and the execution unit identifier is deleted.

[0143] According to one or more embodiments of the present application, [Example 7] provides a network request tracing method. After the execution unit is executed, the method further includes:

[0144] The correspondence between the request identifier and the execution unit identifier is deleted from the global object.

[0145] According to one or more embodiments of the present application, [Example 8] provides a network request tracking device, the device comprising:

[0146] A first acquisition unit, configured to receive a network request and acquire a request identifier of the network request;

[0147] A second acquisition unit, used to determine the execution unit corresponding to the network request, and acquire the execution unit identifier of the execution unit;

[0148] A storage unit, used for storing the corresponding relationship between the request identifier and the execution unit identifier;

[0149] a third acquisition unit, configured to acquire, in response to the execution unit calling the target server, a request identifier corresponding to the execution unit identifier of the execution unit from the corresponding relationship;

[0150] A sending unit is used to send the request identifier to the target server.

[0151] According to one or more embodiments of the present application, [Example 9] provides a network request tracking device, wherein the storage unit 603 is specifically used to:

[0152] In the thread local storage, the correspondence between the request identifier and the execution unit identifier is saved.

[0153] According to one or more embodiments of the present application, [Example 10] provides a network request tracking device, the device further comprising:

[0154] Initialization unit, used to initialize the global object of Map structure;

[0155] The storage unit 603 is specifically used for:

[0156] The correspondence between the request identifier and the execution unit identifier is written into the global object.

[0157] According to one or more embodiments of the present application, [Example 11] provides a network request tracking device, wherein the initialization unit is specifically used to:

[0158] Initialize a global object of Map structure in thread local storage.

[0159] According to one or more embodiments of the present application, [Example 12] provides a network request tracking device, wherein the third acquisition unit 604 is specifically used to:

[0160] In response to the execution unit calling the target server, searching the global object for a request identifier corresponding to the execution unit identifier of the execution unit.

[0161] According to one or more embodiments of the present application, [Example 13] provides a network request tracking device, the device further comprising:

[0162] The first deleting unit is used to delete the corresponding relationship between the request identifier and the execution unit identifier after the execution of the execution unit is completed.

[0163] According to one or more embodiments of the present application, [Example 14] provides a network request tracking device, the device further comprising:

[0164] The second deleting unit is used to delete the corresponding relationship between the request identifier and the execution unit identifier from the global object after the execution of the execution unit is completed.

[0165] According to one or more embodiments of the present application, [Example 15] provides an electronic device, comprising: one or more processors; a memory; and one or more computer programs; wherein the one or more computer programs are stored in the memory; and characterized in that when the one or more processors execute the one or more computer programs, the electronic device implements the network request tracking method as described in any one of the above items.

[0166] According to one or more embodiments of the present application, [Example 16] provides a computer storage medium, including computer instructions, which, when executed on an electronic device, enables the electronic device to execute a network request tracking method as described in any one of the above items.

[0167] According to one or more embodiments of the present application, [Example 17] provides a computer program product, which, when executed on a computer, enables the computer to execute a network request tracking method as described in any one of the above items.

[0168] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the system or device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.

[0169] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0170] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0171] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0172] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A network request tracking method, characterized in that: The method comprises: Receiving a network request and obtaining a request identifier of the network request; Determine the execution unit corresponding to the network request, and obtain the execution unit identifier of the execution unit; Saving the correspondence between the request identifier and the execution unit identifier; In response to the execution unit calling the target server, obtaining a request identifier corresponding to the execution unit identifier of the execution unit from the corresponding relationship; Sending the request identifier to the target server; The storing the correspondence between the request identifier and the execution unit identifier includes: In the thread local storage, the correspondence between the request identifier and the execution unit identifier is saved; the thread local storage is a private global variable of each thread in the multi-thread mode.

2. The method according to claim 1, characterized in that The method further comprises: Initialize the global object of Map structure; The storing the correspondence between the request identifier and the execution unit identifier includes: The correspondence between the request identifier and the execution unit identifier is written into the global object.

3. The method according to claim 2, characterized in that The global object of the initialization Map structure includes: Initialize a global object of Map structure in thread local storage.

4. The method according to claim 2 or 3, characterized in that: The step of obtaining, in response to the execution unit calling the target server, a request identifier corresponding to the execution unit identifier of the execution unit from the corresponding relationship includes: In response to the execution unit calling the target server, searching the global object for a request identifier corresponding to the execution unit identifier of the execution unit.

5. The method according to claim 1, characterized in that After the execution unit completes execution, the method further includes: The correspondence between the request identifier and the execution unit identifier is deleted.

6. The method according to claim 2 or 3, characterized in that: After the execution unit completes execution, the method further includes: The correspondence between the request identifier and the execution unit identifier is deleted from the global object.

7. A network request tracking device, characterized in that: The device comprises: A first acquisition unit, configured to receive a network request and acquire a request identifier of the network request; A second acquisition unit, used to determine the execution unit corresponding to the network request, and acquire the execution unit identifier of the execution unit; A storage unit, used for storing the corresponding relationship between the request identifier and the execution unit identifier; a third acquisition unit, configured to acquire, in response to the execution unit calling the target server, a request identifier corresponding to the execution unit identifier of the execution unit from the corresponding relationship; A sending unit, configured to send the request identifier to the target server; The storage unit is specifically used for: In the thread local storage, the correspondence between the request identifier and the execution unit identifier is saved; the thread local storage is a private global variable of each thread in the multi-thread mode.

8. An electronic device, comprising: one or more processors; Memory; and one or more computer programs; wherein the one or more computer programs are stored in the memory; characterized in that when the one or more processors execute the one or more computer programs, the electronic device implements the network request tracking method as described in any one of claims 1-6.

9. A computer storage medium, comprising computer instructions, which, when executed on an electronic device, enable the electronic device to execute the network request tracking method as described in any one of claims 1 to 6.

10. A computer program product, when the computer program product is run on a computer, enables the computer to execute the network request tracing method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Distributed service tracking method, system, storage medium and electronic equipment

    CN108038145A

  • Request tracking method and device, computer device and storage medium

    CN108289038A

  • Asynchronous micro-service call link tracking method, device, medium and electronic equipment

    CN110445643A

  • Operation request tracking method, tracking device and server

    CN110489315A

  • Calling chain data generation method and system, topology generation method and system and computer equipment

    CN112363855A