Method and device for local debugging of microservice system
By determining policies in the microservice system, collecting configuration information and using generalized mode for debugging, the problem of cumbersome debugging process in the existing technology and relying on multiple test environments is solved, and flexible and efficient local debugging is achieved.
Patent Information
- Application Number
- CN202010603618.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-29
- Publication Date
- 2025-02-21
- Estimated Expiration
- 2040-06-29
AI Technical Summary
The prior art requires simulation services for all scenarios in microservice system debugging, and rely on the ability of engineers and requires redeployment of the environment, resulting in cumbersome debugging process.
By determining the policy of the service to be monitored in the microservice system, collecting configuration information, generating call requests, and using the generalized mode to monitor the service to be monitored, generating debug results, local debugging is realized.
It realizes flexible call to pre-release services or test environments, reduces dependence on multiple test environments, simplifies the debugging process, and improves debugging efficiency.
Smart Images

Figure CN113760693B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a local debugging method for a microservice system. Background Art
[0002] When a problem occurs during function development or online, the code needs to be debugged, and after the code is modified, it is necessary to verify whether the code is correct. The existing technology mainly uses the following methods for debugging:
[0003] Method 1: Simulate the monitoring service to debug the microservice system.
[0004] Method 2: Add debug logs, deploy a pre-release environment, and debug the microservice system.
[0005] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:
[0006] Method 1 requires simulation services for all scenarios;
[0007] Method 2 relies on the ability of engineers, and each debugging should require redeployment of the environment. Summary of the invention
[0008] In view of this, an embodiment of the present invention provides a method and apparatus for local debugging of a microservice system, which can achieve the technical effect of flexibly calling a pre-release service or a test environment.
[0009] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for local debugging of a microservice system is provided, comprising:
[0010] Determine the strategy corresponding to the service to be monitored in the microservice system;
[0011] Collecting configuration information of the service to be monitored according to the policy corresponding to the service to be monitored;
[0012] Generate a call request according to the configuration information;
[0013] The service to be monitored is monitored using the generalized mode and the call request to generate a debugging result.
[0014] Optionally, before determining the policy corresponding to the service to be monitored in the microservice system, the following steps are included:
[0015] Add annotations to the services to be monitored in the microservice system;
[0016] The attributes corresponding to the annotation include the policy corresponding to the service to be monitored and the remarks corresponding to the policy.
[0017] Optionally, the configuration information includes: service name, service group, timeout period, number of retries, and service protocol.
[0018] Optionally, generating a call request according to the configuration information includes:
[0019] Parsing the configuration information and generating request information;
[0020] A call request is generated according to the request information.
[0021] Optionally, using the generalized pattern and the call request, a debugging result is generated, including:
[0022] The service to be monitored is called using the generalized mode, JSON serialization is performed according to the call request, and the client proxy is returned.
[0023] Optionally, after generating the debugging result, the following steps are included:
[0024] If the debugging result is successful, deserialize the debugging result and return the deserialized result;
[0025] If the debugging result is abnormal, abnormal information is generated according to the abnormal information and the generated stack information.
[0026] According to another aspect of an embodiment of the present invention, there is provided a device for local debugging of a microservice system, comprising:
[0027] A policy determination module is used to determine the policy corresponding to the service to be monitored in the microservice system;
[0028] A configuration information collection module, used to collect configuration information of the service to be monitored according to the policy corresponding to the service to be monitored;
[0029] A call request generation module, used to generate a call request according to the configuration information;
[0030] The debugging result generating module is used to monitor the service to be monitored by using the generalized mode and the calling request, and generate a debugging result.
[0031] Optionally, before determining the policy corresponding to the service to be monitored in the microservice system, the following steps are included:
[0032] Add annotations to the services to be monitored in the microservice system;
[0033] The attributes corresponding to the annotation include the policy corresponding to the service to be monitored and the remarks corresponding to the policy.
[0034] Optionally, the configuration information includes: service name, service group, timeout period, number of retries, and service protocol.
[0035] Optionally, generating a call request according to the configuration information includes:
[0036] Parsing the configuration information and generating request information;
[0037] A call request is generated according to the request information.
[0038] Optionally, using the generalized pattern and the call request, a debugging result is generated, including:
[0039] The service to be monitored is called using the generalized mode, JSON serialization is performed according to the call request, and the client proxy is returned.
[0040] Optionally, after generating the debugging result, the following steps are included:
[0041] If the debugging result is successful, deserialize the debugging result and return the deserialized result;
[0042] If the debugging result is abnormal, abnormal information is generated according to the abnormal information and the generated stack information.
[0043] According to another aspect of an embodiment of the present invention, there is provided an electronic device for local debugging of a microservice system, comprising:
[0044] one or more processors;
[0045] a storage device for storing one or more programs,
[0046] When the one or more programs are executed by the one or more processors, the one or more processors implement the method for local debugging of a microservice system provided by the present invention.
[0047] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the method for local debugging of a microservice system provided by the present invention is implemented.
[0048] One embodiment of the above invention has the following advantages or beneficial effects:
[0049] This application solves the technical defect of the existing technology that many test environments for dependent services are missing through technical means of local debugging, thereby achieving the technical effect of flexibly calling pre-release services or test environments.
[0050] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0052] Figure 1 is a schematic diagram of the main process of a method for local debugging of a microservice system according to an embodiment of the present invention;
[0053] Figure 2 is a schematic diagram of a specific embodiment of a method for local debugging of a microservice system according to an embodiment of the present invention;
[0054] Figure 3 is a schematic diagram of main modules of a device for local debugging of a microservice system according to an embodiment of the present invention;
[0055] Figure 4 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0056] Figure 5 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0057] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0058] Figure 1 is a schematic diagram of the main process of a method for local debugging of a microservice system according to an embodiment of the present invention, such as Figure 1 As shown, including:
[0059] Step S101, determining the strategy corresponding to the service to be monitored in the microservice system;
[0060] Step S102: Collect configuration information of the service to be monitored according to the policy corresponding to the service to be monitored;
[0061] Step S103: Generate a call request according to the configuration information;
[0062] Step S104: monitor the service to be monitored using the generalized mode and the call request to generate a debugging result.
[0063] In actual applications, the strategies to be monitored mainly include: calling pre-release environment services and calling test environments. Specifically, the strategy for calling pre-release environment services can be set to number 1, and the strategy for calling test environments can be set to number 2. For example, the annotation added to the annotation of the service to be monitored is: @Monitor(strateg5=1, remark='Proxy xxx service').
[0064] The configuration information includes at least one of the following: service name, service group, timeout, number of retries, and service protocol. The configuration information can be used to limit the service monitored by the call request, for example, to monitor whether the service to be monitored exists according to the timeout.
[0065] This application solves the technical defect of the existing technology that many test environments for dependent services are missing through technical means of local debugging, thereby achieving the technical effect of flexibly calling pre-release services or test environments.
[0066] Optionally, before determining the policy corresponding to the service to be monitored in the microservice system, the following steps are included:
[0067] Add annotations to the services to be monitored in the microservice system;
[0068] The attributes corresponding to the annotation include the strategy corresponding to the service to be monitored and the remark corresponding to the strategy.
[0069] In actual applications, the information of the service to be monitored can be collected through the client agent, and the policy corresponding to the service can be used to call the service to be monitored.
[0070] Specifically, when the strategy corresponding to the service to be monitored is to call the pre-release environment service, the information corresponding to the service can be collected, such as the service registration center, service name, service group, service protocol, etc., and then the collected information can be serialized in JSON and sent to the server. After obtaining the response, the client parses the data and uses it as the response of the dependent service.
[0071] When the policy corresponding to the service to be monitored is to call the test environment setting, the service may not be processed, that is, the content of the annotation is ignored. Specifically, the calling of all steps may be proxied in a proxy manner.
[0072] Optionally, generating a call request according to the configuration information includes:
[0073] Parsing the configuration information and generating request information;
[0074] A call request is generated according to the request information.
[0075] Optionally, using the generalized pattern and the call request, a debugging result is generated, including:
[0076] The service to be monitored is called using the generalized mode, JSON serialization is performed according to the call request, and the client proxy is returned.
[0077] The generalization mode is mainly used when there is no API interface on the consumer side; there is no need to introduce an interface jar package (Java archive file), but to directly initiate a service call through the GenericService interface, and the java objects in the parameters and return values are represented by Map.
[0078] Specifically, the server does not need to pay attention to the generalized call, and can be exposed as a normal service. By using the generalized mode to call the monitored service, the coupling between algorithms can be reduced, thereby avoiding technical defects with high requirements on the algorithm, thereby minimizing the workload of programmers.
[0079] Optionally, after generating the debugging result, the following steps are included:
[0080] If the debugging result is successful, deserialize the debugging result and return the deserialized result;
[0081] If the debugging result is abnormal, abnormal information is generated according to the abnormal information and the generated stack information.
[0082] The following is a detailed description of the process of this application using a specific embodiment. Assume that the service provided by the application is service A, and service A depends on service 1, service 2, and service 3. Figure 2 is a schematic diagram of a specific embodiment of a method for local debugging of a microservice system according to an embodiment of the present invention, such as Figure 2 As shown, including:
[0083] Step S201: Service A receives the request and processes related parameters;
[0084] Step S202: Call service 1 to trigger client proxy monitoring. If the policy corresponding to service 1 is set to 2 to call the test environment service, it is directly released without any processing; otherwise, collect the relevant configuration information of service 1, such as service name, service group, timeout, number of retries, service protocol, etc., serialize the information into JSON, and send an HTTP request to the server. Request structure:
[0085]
[0086] Step S203: The server receives the request, parses the request information, assembles the call request according to the request information, calls the service 1 of the pre-release environment using the generalized mode, and after receiving the response, assembles the information, serializes it in JSON, and returns it to the client agent. At this time, the response of the generalized call may be an abnormal error, and the assembled information also supports this scenario.
[0087] Specifically, a successful response may be:
[0088]
[0089]
[0090] Failure responses can be:
[0091]
[0092] Step S204, the client proxy obtains the response and determines whether it is successful according to the result flag (result_flag). If successful, the data is deserialized and returned as the proxy response; otherwise, the exception information and stack information are parsed and an exception is thrown.
[0093] Step S205, continue to execute the program code;
[0094] Step S206, calling service 2 and service 3, same as step S202 to step S204;
[0095] Step S207, continue to execute subsequent codes;
[0096] Step S208: Service A completes the processing and responds externally.
[0097] Figure 3 is a schematic diagram of main modules of a device for local debugging of a microservice system according to an embodiment of the present invention;
[0098] According to another aspect of an embodiment of the present invention, there is provided a device for local debugging of a microservice system, comprising:
[0099] A policy determination module 301 is used to determine the policy corresponding to the service to be monitored in the microservice system;
[0100] The configuration information collection module 302 is used to collect the configuration information of the service to be monitored according to the policy corresponding to the service to be monitored;
[0101] A call request generating module 303, used to generate a call request according to the configuration information;
[0102] The debugging result generating module 304 is used to monitor the service to be monitored by using the generalized mode and the calling request to generate a debugging result.
[0103] Optionally, before determining the policy corresponding to the service to be monitored in the microservice system, the following steps are included:
[0104] Add annotations to the services to be monitored in the microservice system;
[0105] The attributes corresponding to the annotation include the policy corresponding to the service to be monitored and the remarks corresponding to the policy.
[0106] Optionally, the configuration information includes: service name, service group, timeout period, number of retries, and service protocol.
[0107] Optionally, generating a call request according to the configuration information includes:
[0108] Parsing the configuration information and generating request information;
[0109] A call request is generated according to the request information.
[0110] Optionally, using the generalized pattern and the call request, a debugging result is generated, including:
[0111] The service to be monitored is called using the generalized mode, JSON serialization is performed according to the call request, and the client proxy is returned.
[0112] Optionally, after generating the debugging result, the following steps are included:
[0113] If the debugging result is successful, deserialize the debugging result and return the deserialized result;
[0114] If the debugging result is abnormal, abnormal information is generated according to the abnormal information and the generated stack information.
[0115] Figure 4 An exemplary system architecture 400 is shown to which a local debugging method for a microservice system or a local debugging device for a microservice system according to an embodiment of the present invention can be applied.
[0116] like Figure 4 As shown, system architecture 400 may include terminal devices 401, 402, 403, network 404 and server 405. Network 404 is used to provide a medium for communication links between terminal devices 401, 402, 403 and server 405. Network 404 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0117] Users can use terminal devices 401, 402, 403 to interact with server 405 through network 404 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 401, 402, 403, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0118] The terminal devices 401 , 402 , and 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0119] The server 405 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 401, 402, and 403. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information, product information - only an example) to the terminal device.
[0120] It should be noted that the local debugging method for the microservice system provided in the embodiment of the present invention is generally executed by the server 405 , and accordingly, the local debugging device for the microservice system is generally arranged in the server 405 .
[0121] It should be understood that Figure 4 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0122] Reference below Figure 5 , which shows a schematic diagram of the structure of a computer system 500 of a terminal device suitable for implementing an embodiment of the present invention. Figure 5 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0123] like Figure 5 As shown, the computer system 500 includes a central processing module (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the system 500 are also stored. The CPU 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0124] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that a computer program read therefrom is installed into the storage section 508 as needed.
[0125] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a 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 part 509, and / or installed from the removable medium 511. When the computer program is executed by the central processing module (CPU) 501, the above-mentioned functions defined in the system of the present invention are executed.
[0126] It should be noted that the computer-readable medium shown in the present invention 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 invention, 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 invention, 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. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, 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 appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0127] 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 invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a 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 box can also occur in a different order from the order marked in the accompanying drawings. For example, two 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 box in the block diagram or flow chart, and the combination of the boxes in the block diagram 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.
[0128] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be set in a processor. For example, they may be described as: a processor includes a sending module, an acquisition module, a determination module, and a first processing module. The names of these modules do not, in some cases, constitute limitations on the modules themselves. For example, the sending module may also be described as a "module for sending a picture acquisition request to the connected server."
[0129] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes:
[0130] Determine the strategy corresponding to the service to be monitored in the microservice system;
[0131] Collecting configuration information of the service to be monitored according to the policy corresponding to the service to be monitored;
[0132] Generate a call request according to the configuration information;
[0133] The service to be monitored is monitored using the generalized mode and the call request to generate a debugging result.
[0134] The technical solution according to the embodiment of the present invention may include the following technical effects:
[0135] This application solves the technical defect of the existing technology that many test environments for dependent services are missing through technical means of local debugging, thereby achieving the technical effect of flexibly calling pre-release services or test environments.
[0136] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for local debugging of a microservice system, characterized in that: include: Determine the strategy corresponding to the service to be monitored in the microservice system; The strategy includes: calling a pre-release environment service and calling a test environment service; According to the policy corresponding to the service to be monitored, collecting the configuration information of the service to be monitored, including: in response to the determined policy being to call the pre-release environment service, collecting the configuration information of the service to be monitored; the configuration information includes at least one of the following: service name, service group, timeout period, number of retries, and service protocol; Generate a call request according to the configuration information; The service to be monitored is monitored using the generalized mode and the call request to generate a debugging result.
2. The method according to claim 1, characterized in that Before determining the strategy corresponding to the service to be monitored in the microservice system, include: Add annotations to the services to be monitored in the microservice system; The attributes corresponding to the annotation include the policy corresponding to the service to be monitored and the remarks corresponding to the policy.
3. The method according to claim 1, characterized in that Generate a call request according to the configuration information, including: Parsing the configuration information and generating request information; A call request is generated according to the request information.
4. The method according to claim 1, characterized in that: Using the generalized pattern and the call request, a debugging result is generated, including: The service to be monitored is called using the generalized mode, JSON serialization is performed according to the call request, and the client proxy is returned.
5. The method according to any one of claims 1 to 4, characterized in that: After the debugging result is generated, it includes: If the debugging result is successful, deserialize the debugging result and return the deserialized result; If the debugging result is abnormal, abnormal information is generated according to the abnormal information and the generated stack information.
6. A device for local debugging of a microservice system, characterized in that: include: A policy determination module is used to determine the policy corresponding to the service to be monitored in the microservice system; The strategy includes: calling a pre-release environment service and calling a test environment service; A configuration information collection module, used to collect configuration information of the service to be monitored according to the policy corresponding to the service to be monitored; A call request generation module, used to generate a call request according to the configuration information; A debugging result generating module, used for monitoring the service to be monitored by using the generalized mode and the calling request, and generating a debugging result; The configuration information collection module is also used to: in response to the determined strategy of calling the pre-release environment service, collect the configuration information of the service to be monitored; the configuration information includes at least one of the following: service name, service group, timeout period, number of retries, and service protocol.
7. An electronic device for local debugging of a microservice system, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.
8. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Micro-service arrangement method and system, micro-service execution method and system, architecture, equipment and storage medium
CN111078315A