CN-122001939-A - Service link tracking method, system, medium and electronic equipment
Abstract
The application provides a service link tracking method, a system, a medium and electronic equipment, which relate to the technical field of data processing, respond to a service call request from a first protocol environment, identify link tracking context information of the first protocol carried in the service call request, convert the link tracking context information of the first protocol in the service call request into link tracking context information conforming to a second protocol to obtain a target request, send the target request to a target service in the second protocol environment to enable the target service to execute business operation corresponding to the target request, and acquire semantic data associated with the business call operation based on the link tracking context information of the second protocol when at least one preset type of business call operation is detected in the process of executing the business operation by the target service so as to form enhanced link tracking information containing the semantic data. Link tracking across protocol services can be achieved.
Inventors
- HAN XIAO
- XU CHUANTAI
- MA WEIBIN
- QIU LI
- Li Tongshuai
Assignees
- 杭州小码教育科技有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20260409
Claims (10)
- 1. A method for service link tracking, comprising: in response to receiving a service call request from a first protocol environment, identifying link tracking context information of a first protocol carried in the service call request; Converting the link tracking context information of the first protocol in the service call request into link tracking context information conforming to the second protocol to obtain a target request; sending the target request to a target service in a second protocol environment, so that the target service executes business operation corresponding to the target request; And in the process of executing business operation by the target service, when at least one preset type of business calling operation is detected, acquiring semantic data associated with the business calling operation based on the link tracking context information of the second protocol so as to form enhanced link tracking information containing the semantic data.
- 2. The method of claim 1, wherein converting the link trace context information of the first protocol to link trace context information conforming to the second protocol comprises: extracting a global tracking identifier and a current span identifier from the link tracking context information of the first protocol; Mapping the global tracking identifier into a tracking identifier in a second protocol format, and mapping the current span identifier into a parent span identifier in the second protocol format; and according to the standard structure of the second protocol, assembling the mapped tracking identifier, the parent span identifier and preset service metadata to generate second protocol link tracking context information.
- 3. The method of claim 1, wherein the predetermined type of service invocation operation comprises an HTTP call, and wherein the gathering semantic data associated with the service invocation operation comprises: when the HTTP call is initiated in the service operation, converting the link tracking context information of the second protocol into a format suitable for HTTP transmission, and injecting the format into a request header of the HTTP call; Capturing a target address and a request method of the HTTP call; And collecting the target address and the request method as semantic data.
- 4. The method of claim 1, wherein the predetermined type of business call operation comprises a query operation to a database, and wherein the gathering semantic data associated with the business call operation comprises: When the database query is detected to be executed in the business operation, acquiring an original query statement to be executed; parameterizing the original query statement to generate a templated query statement; and collecting the templated query statement and the corresponding database identifier as semantic data.
- 5. The method according to claim 4, wherein the method further comprises: recording the execution time consumption of the database query operation; And taking the execution time as semantic data acquisition.
- 6. The method of claim 1, wherein when the service invocation request is a command line task, the method further comprises: creating a root span based on the second protocol link trace context information at a command line task execution portal; Acquiring script identification and incoming parameters of a current command line task; And recording the script identification and the incoming parameters as attribute data of the root span.
- 7. A service link tracking apparatus, comprising: the identifying unit is used for responding to a service call request from a first protocol environment and identifying link tracking context information of a first protocol carried in the service call request; the conversion unit is used for converting the link tracking context information of the first protocol in the service call request into link tracking context information conforming to the second protocol to obtain a target request; the first execution unit is used for sending the target request to a target service in a second protocol environment so that the target service executes business operation corresponding to the target request; And the second execution unit is used for acquiring semantic data associated with the service calling operation based on the link tracking context information of the second protocol when at least one preset type of service calling operation is detected in the process of executing the service operation by the target service so as to form enhanced link tracking information containing the semantic data.
- 8. The apparatus of claim 7, wherein the conversion unit comprises: an extracting subunit, configured to extract a global tracking identifier and a current span identifier from link tracking context information of the first protocol; the mapping subunit is used for mapping the global tracking identifier into a tracking identifier in a second protocol format and mapping the current span identifier into a parent span identifier in the second protocol format; and the generating subunit is used for assembling the mapped tracking identifier, the parent span identifier and the preset service metadata according to the standard structure of the second protocol to generate second protocol link tracking context information.
- 9. A storage medium comprising stored instructions, wherein the instructions, when executed, control a device in which the storage medium is located to perform the service link tracking method according to any one of claims 1 to 6.
- 10. An electronic device comprising a memory and one or more instructions, wherein the one or more instructions are stored in the memory and configured to perform the service link tracking method of any of claims 1-6 by one or more processors.
Description
Service link tracking method, system, medium and electronic equipment Technical Field The present application relates to the field of data processing technologies, and in particular, to a service link tracking method, a system, a medium, and an electronic device. Background Under a micro-service architecture, applications are typically made up of service components developed in a variety of programming languages. To monitor calls between these distributed services, distributed link tracking techniques are widely used. The technology restores the complete call link by burying points in each service through which the request passes and reporting data with specific identification. There are a variety of link tracking systems such as Zipkin, skyWalking, etc. that each define a different context propagation protocol. However, in a mixed deployment of services implemented by different languages, the tracking protocols employed by the respective services tend to be different. For example, java services may use the SW8 protocol of SKYWALKING, while PHP services may employ the B3 protocol of Zipkin. Because protocols are mutually incompatible, when a call of one service enters another service, the link context cannot be correctly identified and inherited, so that the service link is broken at a cross-language position, and effective service link tracking cannot be formed. Disclosure of Invention The application aims to provide a service link tracking method, a system, a medium and electronic equipment, which are used for realizing the service link tracking of a cross-tracking protocol. The specific scheme is as follows: a service link tracking method, comprising: in response to receiving a service call request from a first protocol environment, identifying link tracking context information of a first protocol carried in the service call request; Converting the link tracking context information of the first protocol in the service call request into link tracking context information conforming to the second protocol to obtain a target request; sending the target request to a target service in a second protocol environment, so that the target service executes business operation corresponding to the target request; And in the process of executing business operation by the target service, when at least one preset type of business calling operation is detected, acquiring semantic data associated with the business calling operation based on the link tracking context information of the second protocol so as to form enhanced link tracking information containing the semantic data. The method, optionally, converting the link tracking context information of the first protocol into link tracking context information conforming to the second protocol includes: extracting a global tracking identifier and a current span identifier from the link tracking context information of the first protocol; Mapping the global tracking identifier into a tracking identifier in a second protocol format, and mapping the current span identifier into a parent span identifier in the second protocol format; and according to the standard structure of the second protocol, assembling the mapped tracking identifier, the parent span identifier and preset service metadata to generate second protocol link tracking context information. The method, optionally, the service calling operation of the preset type comprises HTTP calling, and the collecting the semantic data associated with the service calling operation comprises the following steps: when the HTTP call is initiated in the service operation, converting the link tracking context information of the second protocol into a format suitable for HTTP transmission, and injecting the format into a request header of the HTTP call; Capturing a target address and a request method of the HTTP call; And collecting the target address and the request method as semantic data. The method, optionally, the service calling operation of the preset type comprises a query operation on a database, and the collecting the semantic data associated with the service calling operation comprises the following steps: When the database query is detected to be executed in the business operation, acquiring an original query statement to be executed; parameterizing the original query statement to generate a templated query statement; and collecting the templated query statement and the corresponding database identifier as semantic data. The method, optionally, further comprising: recording the execution time consumption of the database query operation; And taking the execution time as semantic data acquisition. In the above method, optionally, when the service call request is a command line task, the method further includes: creating a root span based on the second protocol link trace context information at a command line task execution portal; Acquiring script identification and incoming parameters of a current command line task; And rec