Method and apparatus for link trace of distributed invocation of network product application

By setting request identifiers and plugin instrumentation in a distributed microservice architecture, the problem of traditional log monitoring being unable to trace the call chain is solved, enabling cross-language link tracing and log correlation, and improving the efficiency of fault location and performance analysis.

CN116264555BActive Publication Date: 2026-04-07CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-25
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

In a distributed microservice architecture, traditional log monitoring methods cannot effectively track the call chain, making fault location and performance bottleneck analysis difficult. SkyWalking only collects partial data and does not integrate traceId into the log output.

Method used

By adding request identifiers to the gateway project, setting link priorities and logging request link identifiers, defining plugins and instrumenting them, and ensuring sampling conforms to sampling rules, the system enables full-link tracing of request links and reporting, storage, and analysis of log information. It supports forced sampling and fine-grained sampling, cross-language traceId transmission, and log association.

Benefits of technology

It enables comprehensive tracking and location of distributed call chains, supports link identification and log association in multi-language environments, and improves the efficiency of fault location and performance analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116264555B_ABST
    Figure CN116264555B_ABST
Patent Text Reader

Abstract

This invention relates to the field of IT application technology and discloses a method and apparatus for tracing distributed calls in network product applications. The method includes: acquiring user requests processed by a gateway; setting link priorities and filling logs with request link identifiers for the user requests; setting sampling rules for links and logs under various scenarios; defining plugins in different languages, and applying the plugins for instrumentation and sampling request links that conform to the sampling rules; and reporting, storing, and analyzing log information generated by the request links. Through the above methods, this invention can associate request link identifiers of plugins in different languages ​​with logs, facilitating the tracing and location of call chains.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of IT application technology, specifically to a method and apparatus for link tracing in distributed calls of network product applications. Background Technology

[0002] In a distributed microservice architecture, the numerous interdependencies between services mean that a single request can involve the coordinated processing of dozens of services. Quickly and accurately locating online faults and performance bottlenecks becomes a daunting challenge for developers. Traditional methods like log monitoring are inadequate for tracing calls, troubleshooting, and performance statistics. Therefore, a new technology has emerged: distributed call chaining technology, which links the entire request call process together to monitor the request call path.

[0003] SkyWalking is an Applications Manager (APM) system designed for microservice and cloud-native architectures and supporting distributed call tracing. It provides a method for automatically detecting applications without modifying any source code of the target application, and features a collector with efficient streaming capabilities. It collects application call chain information non-intrusively by loading probes, analyzes the collected call chain information, and generates inter-application and inter-service relationships, as well as service metrics.

[0004] In current technology, SkyWalking only collects a subset of data, with a default setting of sampling the first three times every three seconds. Thus, if multiple requests using Spring, MySQL, and Redis occur on this machine within three seconds, and the first three are Spring calls, the other MySQL, Redis, and other calls will not be sampled. Furthermore, SkyWalking does not directly integrate traceId into its log output. Summary of the Invention

[0005] In view of the above problems, embodiments of the present invention provide a method and apparatus for distributed call link tracing in network product applications, which overcomes or at least partially solves the above problems.

[0006] According to one aspect of the present invention, a method for tracing distributed calls in a network product application is provided. The method includes: acquiring user requests processed by a gateway engineering process; setting link priorities and filling logs with request link identifiers for the user requests; setting sampling rules for links and logs under various scenarios; defining plugins in different languages, and applying the plugins to instrument and sample request links that conform to the sampling rules; and reporting, storing, and analyzing log information generated by the request links.

[0007] In one alternative approach, before obtaining the user request processed by the gateway project, the process includes: adding a request identifier to the header of the user request through the gateway project; and forwarding the user request carrying the request identifier through the gateway project.

[0008] In one alternative approach, setting the link priority and filling the log with the request link identifier for the user request includes: adding a sampling level parameter to the plugin's configuration file; customizing the format of the plugin's output log and embedding the request link identifier.

[0009] In one alternative approach, adding a sampling level parameter to the plugin's configuration file includes: configuring the sampling level parameter in the plugin's configuration file to "create" if only the "create" method in the monitored class is sampled; configuring the sampling level parameter in the plugin's configuration file to "delete" if only the "create" and "delete" methods in the monitored class are sampled; configuring the sampling level parameter in the plugin's configuration file to "update" if only the "create," "delete," and "update" methods in the monitored class are sampled; and configuring the sampling level parameter in the plugin's configuration file to "query" if all methods in the monitored class are sampled.

[0010] In one optional approach, the sampling rules for setting up links and logs in various scenarios include: adding a forced sampling identifier to the header of the user request, the forced sampling identifier being used to indicate whether forced sampling is required; and adding a sampling type parameter to the plugin's configuration file, the sampling type parameter being used to indicate whether to use the default sampling method or the grouped sampling method.

[0011] In one alternative approach, defining plugins for different languages ​​includes: defining a Spring annotation plugin; writing an Instrumentation class; monitoring classes that meet certain conditions in the enhanceClass method; monitoring classes declared with @RestController and @Service annotations; defining the corresponding annotation level for the methods in the monitored classes; using the apm-toolkit-trace plugin to support linking multiple threads in multi-threaded scenarios; obtaining the value of the sampling level parameter of RequestContext from the Interceptor class; enhancing the annotated methods based on the value of the sampling level parameter; writing an Interceptor class to create and configure Spans at pointcuts before method execution, activate and deactivate Spans at pointcuts after method execution, and log exceptions in the handleMethodException method.

[0012] In one optional approach, the application of the plugin for instrumentation and sampling of request links conforming to the sampling rules includes: obtaining a forced sampling identifier in the header; if the forced sampling identifier is true, then forced sampling is performed by default; if the sampling type parameter in the configuration file indicates a grouped sampling method, then different components are grouped, and requests in different groups use a separate set of ContextManager and SamplingService to count the sampling frequency; inserting the traceId into the header request in the HTTP request calling neutron; connecting neutron to SkyWalking; adding the @trace annotation to the methods that need to be monitored in the classes implementing the monitored network product interfaces; customizing the method name for logging and adding the request link identifier.

[0013] According to another aspect of the present invention, a link tracing device for distributed calls in network product applications is provided. The device includes: a request acquisition unit for acquiring user requests processed by a gateway engineer; a configuration unit for setting link priorities and filling logs with request link identifiers for the user requests; a rule setting unit for setting sampling rules for links and logs under various scenarios; a sampling unit for defining plugins in different languages, applying the plugins for instrumentation, and sampling request links that conform to the sampling rules; and a link tracing unit for reporting, storing, and analyzing log information generated by the request links.

[0014] According to another aspect of the present invention, a computing device is provided, including: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other through the communication bus;

[0015] The memory is used to store at least one executable instruction that causes the processor to perform the steps of the distributed call link tracing method for the above-described network product application.

[0016] According to another aspect of the present invention, a computer storage medium is provided, the storage medium storing at least one executable instruction that causes the processor to perform the steps of the distributed call link tracing method of the above-described network product application.

[0017] This invention, through obtaining user requests processed by a gateway project; setting link priorities and filling logs with request link identifiers for the user requests; setting sampling rules for links and logs under various scenarios; defining plugins in different languages, and applying the plugins for instrumentation and sampling request links that conform to the sampling rules; and reporting, storing, and analyzing the log information generated by the request links, can associate the request link identifiers of plugins in different languages ​​with the logs, facilitating the tracking and location of call chains.

[0018] The above description is merely an overview of the technical solutions of the embodiments of the present invention. In order to better understand the technical means of the embodiments of the present invention and to implement them in accordance with the contents of the specification, and to make the above and other objects, features and advantages of the embodiments of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description

[0019] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:

[0020] Figure 1 A flowchart illustrating the distributed call link tracing method for network product applications provided in an embodiment of the present invention is shown.

[0021] Figure 2 This illustration shows a flowchart of the distributed call link tracing method for network product applications provided in this embodiment of the invention, including distributed call link tracing and log integration.

[0022] Figure 3 This invention provides a schematic diagram of the structure of a link tracing device for distributed calls in network product applications.

[0023] Figure 4 A schematic diagram of the structure of a computing device provided in an embodiment of the present invention is shown. Detailed Implementation

[0024] Exemplary embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this invention will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.

[0025] Figure 1This diagram illustrates a flowchart of a distributed call tracing method for network product applications provided in an embodiment of the present invention. This distributed call tracing method for network product applications is applied to the console server of the network product application, such as... Figure 1 As shown, the distributed call tracing methods for network product applications include:

[0026] Step S11: Obtain the user request after it has been processed by the gateway project.

[0027] In this embodiment of the invention, the SkyWalking architecture comprises three parts: the SkyWalking Agent, the Observability Analysis Platform (OAP), and the User Interface (UI). The SkyWalking Agent uses a Java agent for bytecode injection, enabling non-intrusive data collection, and sends data to the OAP via HTTP or gRPC. The OAP receives the data sent by the probes and performs data integration and computation in memory using the AnalysisCore, then stores the data on the corresponding storage medium, such as Elasticsearch, MySQL, or H2 databases. The OAP also provides an HTTP query interface using a QueryCore. The UI is a web visualization platform used to display the stored data.

[0028] In the SkyWalking architecture, a Trace represents a complete request chain, while a Span represents a single call process, requiring a start time and an end time. The SpanContext contains the global context information for the Trace, such as the request chain identifier (traceId). A complete request constitutes a Trace, and obviously, a global identifier is necessary to identify this request. Each call is called a Span, and each call must carry the global TraceId. This allows the global TraceId to be associated with each call, and this TraceId is transmitted through the SpanContext.

[0029] OAP continuously collects data. Each call to Collector gathers at least the following information: global trace_id, span_id, and parent_span_id. The global trace_id associates each sub-call with the initial request; SkyWalking uses the snowflake algorithm to locally generate globally unique trace_ids. The span_id identifies which call it is. For the parent_span_id, if the span_id of call d by b is 1.1, then its parent_span_id is the span_id of call b by a, which is 1. This is how two adjacent calls are associated.

[0030] SkyWalking employs a pluggable architecture combined with Java agent bytecode instrumentation to automate the collection and reporting of span data. This approach ensures non-intrusive code handling, while the pluggable architecture provides excellent scalability and flexibility. The SkyWalking Agent collects and reports application data to the Collector and stores it in the Observability Analysis Platform (OAP) storage, which then queries the data. SkyWalking only collects a subset of the data, with a default setting of sampling the first three times every three seconds. In the SkyWalking architecture, data is generally divided into headers and bodies, similar to HTTP headers and bodies. The body typically stores business data, so the context is transmitted within the header.

[0031] Before step S11, the user request is processed by the gateway project, which adds a request identifier (requestId) to the header. The user request carrying the request identifier (requestId) is then forwarded by the gateway project. Specifically, the user request is forwarded by the gateway project to the console server of the network product application implemented based on Neutron. A filter is applied to filter the user request, retrieve the parameters from the header, and set them in the RequestContext using `transmittable-thread-local`, at which point the request identifier (requestId) is carried. The console server of the network product application then receives the user request forwarded by the gateway project, which carries the request identifier (requestId).

[0032] Step S12: Set the link priority and fill the log with the request link identifier for the user request.

[0033] In this embodiment of the invention, the link priority at the request method level in the acquired user requests is configured, and the request link identifier traceId is filled into the log. Specifically, in step S12, firstly, in order to enable more granular sampling, a sampling level parameter is added to the plugin's configuration file. Optionally, if only the create method in the monitored class is sampled, the sampling level parameter in the plugin's configuration file is configured as create; if only the create and delete methods in the monitored class are sampled, the sampling level parameter in the plugin's configuration file is configured as delete; if only the create, delete, and update methods in the monitored class are sampled, the sampling level parameter in the plugin's configuration file is configured as update; if all methods in the monitored class are sampled, the sampling level parameter in the plugin's configuration file is configured as query.

[0034] Then, customize the format of the plugin's output logs and embed the request trace ID. Optionally, use log4j to customize the plugin's output log format by embedding the traceId in the custom log format: <property name="FILE_PATTERN"value="%d{yyyy-MM-ddHH:mm:ss.SSS}${LOG_LEVEL_PATTERN:-%5p}${PID:-}---[%15.15t]:[%X{request_id}]%m---[%{traceId}]---[%logger{39}:%M:%L]%n${LOG_EXCEPTION_CONVE RSION_WORD:-%wEx}" / > And implement a log4j plugin to support it. Define a class that inherits from LogEventPatternConverter and declare it as a plugin. Specify the placeholder to be replaced through the @ConverterKeys annotation, and then replace it in the format method.

[0035] Step S13: Set sampling rules for various scenarios of links and logs.

[0036] In an embodiment of the invention, optionally, in order to enforce sampling of a specified request, a forced sampling identifier `force_sample` is added to the header of the user request. The forced sampling identifier `force_sample` indicates whether forced sampling is required. Specifically, `force_sample = true` indicates that forced sampling is required, and `force_sample = false` indicates that forced sampling is not required.

[0037] To enable finer-grained sampling, a sampling type parameter `sample_type` is added to the plugin's configuration file. This parameter indicates whether to use the default sampling method or a grouped sampling method. Specifically, `sample_type = default` indicates that SkyWalking's default sampling method is used, while `sample_type = by_group` indicates that grouped sampling is used, sampling different components.

[0038] Step S14: Define plugins for different languages, and apply the plugins to instrument and sample request links that conform to the sampling rules.

[0039] In this embodiment of the invention, optionally, a Spring annotation plugin is defined, and an Instrumentation class is written. The `enhanceClass` method monitors classes that meet certain conditions, and also monitors classes declared with `@RestController` and `@Service` annotations. The corresponding annotation levels for the methods in the monitored classes are defined. Specifically, the methods in the monitored classes are divided into four levels: create, delete, update, and query. Four custom annotation levels—`MonitorLevelCreate`, `MonitorLevelDelete`, `MonitorLevelUpdate`, and `MonitorLevelQuery`—are defined to annotate the methods. The plugin `apm-toolkit-trace` is used to support the association of links between multiple threads in multi-threaded scenarios. In the custom Spring annotation plugin, the value of the `sample_level` parameter of `RequestContext` is obtained from the `Interceptor` class, and the annotated methods are enhanced based on the value of the `sample_level` parameter. Write an Interceptor class to create and configure the Span at the beforeMethod point before the method is executed, activate and deactivate the Span at the afterMethod point after the method is executed, and log exceptions in the handleMethodException method.

[0040] In this embodiment of the invention, when the plugin is applied for instrumentation and sampling of request chains conforming to the sampling rules, the forced sampling flag in the header is obtained by modifying the implementation in the `createEntrySpan` method of `ContextManager`. If the forced sampling flag `force_sample` is true, then forced sampling is performed by default. If the sampling type parameter `sample_type` in the configuration file indicates a grouped sampling method (by_group), then different components are grouped, and requests from different groups use a separate set of `ContextManager` and `SamplingService` to count the sampling frequency. These different components can be Spring, MySQL, Redis, MQ, etc.

[0041] In the HTTP request calling Neutron from the console server, insert the traceId into the header request. Integrate Neutron into SkyWalking, add the @trace annotation to the methods of the classes that implement the monitored network product interfaces, for example, @trace(op='customized_method_name'); log the custom method name and add the request trace identifier.

[0042] Step S15: Report, store, and analyze the log information generated by the request link.

[0043] The sampled log information is reported and stored, and OAP is used to analyze and display the reported logs, thereby realizing distributed call link tracing and log integration.

[0044] The complete process of the embodiments of the present invention is as follows: Figure 2 As shown, user requests for API calls are forwarded to network product services via the gateway project after a requestId is added to the header. The requestId-added user requests are prioritized and the traceId is populated in logs based on multiple languages. Sampling rules are set for various scenarios involving the request chain and logs. These languages ​​include, but are not limited to, MySQL, MOP, OP, Network, Compute, and Neutron. Custom Java and Python plugins are used to instrument and sample request chains from the console and Neutron services that conform to the aforementioned rules. During sampling, the plugins perform the sampling, and the SkyWalking Agent reports and stores the log information generated by the sampled request chains. OAP is used to analyze and display the reported logs for user convenience.

[0045] SkyWalking's existing Spring plugin does not support forced sampling; instead, it samples three times every 3 seconds by default, and does not support fine-grained sampling based on the request method. This embodiment of the invention supports both forced sampling and fine-grained sampling based on the request method, supporting fine-grained sampling at four levels: create, delete, update, and query. This embodiment of the invention allows users to indicate that a request requires forced sampling by adding the `force_sample` parameter to the request header, thus forcing sampling in the `createEntrySpan` method of `ContextManager`; and it samples methods with different annotation levels according to the configured sampling method level in the `Interceptor` class.

[0046] In SkyWalking, existing Spring plugins only support uniform sampling across all components, failing to group sampling based on different components. Existing Java plugins do not support the association between traceId and logs, nor do Python plugins support the passing of traceIds. This invention supports group sampling based on different components and the passing of traceIds, maintaining continuity between plugins. This invention uses the `sample_type` parameter in the configuration file to indicate whether group sampling of different components is required, performing sampling 3 times every 3 seconds for requests from different components, or forcing sampling. Through a custom implementation of the log4j component, the association between traceId and logs is achieved. Furthermore, by passing the traceId in the HTTP request header between different languages, the traceIds of plugins in different languages ​​are associated with the logs, facilitating call chain tracing and location.

[0047] In summary, this embodiment of the invention obtains user requests processed by the gateway engineering; sets link priorities and fills logs with request link identifiers for the user requests; sets sampling rules for links and logs under various scenarios; defines plugins for different languages, applies the plugins for instrumentation, and samples request links that conform to the sampling rules; and reports, stores, and analyzes the log information generated by the request links. This enables the association between the request link identifiers of plugins in different languages ​​and the logs, facilitating the tracking and location of call chains.

[0048] Figure 3 A schematic diagram of the structure of a link tracing device for distributed calls in a network product application according to an embodiment of the present invention is shown. Figure 3As shown, the distributed call link tracing device for this network product application is applied to a base station and includes: a request acquisition unit 301, a configuration unit 302, a rule setting unit 303, a sampling unit 304, and a link tracing unit 305. Wherein:

[0049] The request acquisition unit 301 is used to acquire user requests processed by the gateway project; the configuration unit 302 is used to set the link priority and fill the log with the request link identifier for the user requests; the rule setting unit 303 is used to set sampling rules for links and logs in various scenarios; the sampling unit 304 is used to define plugins in different languages, and apply the plugins to instrument and sample request links that conform to the sampling rules; the link tracing unit 305 is used to report, store and analyze the log information generated by the request links.

[0050] In one alternative approach, the request acquisition unit 301 is configured to: add a request identifier to the header of the user request through the gateway process; and forward the user request carrying the request identifier through the gateway process.

[0051] In an alternative approach, configuration unit 302 is used to: add sampling level parameters to the plugin's configuration file; customize the format of the plugin's output logs and embed request link identifiers.

[0052] In an alternative approach, configuration unit 302 is configured to: set the sampling level parameter in the plugin's configuration file to "create" if only the "create" method in the monitored class is sampled; set the sampling level parameter in the plugin's configuration file to "delete" if only the "create" and "delete" methods in the monitored class are sampled; set the sampling level parameter in the plugin's configuration file to "update" if only the "create," "delete," and "update" methods in the monitored class are sampled; and set the sampling level parameter in the plugin's configuration file to "query" if all methods in the monitored class are sampled.

[0053] In an alternative approach, the rule setting unit 303 is used to: add a forced sampling identifier to the header of the user request, the forced sampling identifier being used to indicate whether forced sampling is required; and add a sampling type parameter to the plugin's configuration file, the sampling type parameter being used to indicate whether to use the default sampling method or the grouped sampling method.

[0054] In an optional approach, sampling unit 304 is used to: define a Spring annotation plugin, write an Instrumentation class, monitor classes that meet the conditions in the enhanceClass method, and monitor classes declared with @RestController and @Service annotations; define the corresponding annotation annotation level for the methods in the monitored classes; use the plugin apm-toolkit-trace to support the association of multiple thread links in multi-threaded scenarios; obtain the value of the sampling level parameter of RequestContext from the Interceptor class, and enhance the annotated methods according to the value of the sampling level parameter; write an Interceptor class to create and configure Spans at the pointcuts before the monitored methods are executed, activate and deactivate Spans at the pointcuts after the methods are executed, and log exceptions in the handleMethodException method.

[0055] In an optional manner, sampling unit 304 is further configured to: obtain a forced sampling identifier in the header; if the forced sampling identifier is true, then forced sampling is performed by default; if the sampling type parameter in the configuration file indicates a grouped sampling method, then different components are grouped, and requests in different groups use a separate set of ContextManager and SamplingService to count the sampling frequency; insert the traceId into the header request in the HTTP request that calls neutron; connect neutron to SkyWalking; add the @trace annotation to the methods that need to be monitored in the classes that implement the monitored network product interfaces; log the custom method name and add the request link identifier.

[0056] This invention, through obtaining user requests processed by a gateway project; setting link priorities and filling logs with request link identifiers for the user requests; setting sampling rules for links and logs under various scenarios; defining plugins in different languages, and applying the plugins for instrumentation and sampling request links that conform to the sampling rules; and reporting, storing, and analyzing the log information generated by the request links, can associate the request link identifiers of plugins in different languages ​​with the logs, facilitating the tracking and location of call chains.

[0057] This invention provides a non-volatile computer storage medium storing at least one executable instruction that can execute a distributed call link tracing method for network product applications in any of the above method embodiments.

[0058] Executable instructions can specifically be used to cause the processor to perform the following operations:

[0059] Obtain user requests after they have been processed by the gateway project;

[0060] Set the link priority for the user request and fill the log with the request link identifier;

[0061] Configure sampling rules for various scenarios involving links and logs;

[0062] Define plugins for different languages, and apply the plugins to instrument and sample request chains that conform to the sampling rules;

[0063] The log information generated by the request chain is reported, stored, and analyzed.

[0064] In an alternative approach, the executable instructions cause the processor to perform the following operations:

[0065] The user request is processed by the gateway project, which adds a request identifier to the header.

[0066] The user request carrying the request identifier is forwarded through the gateway.

[0067] In an alternative approach, the executable instructions cause the processor to perform the following operations:

[0068] Add the sampling level parameter to the plugin's configuration file;

[0069] Customize the format of the plugin's output logs and embed request link identifiers.

[0070] In an alternative approach, the executable instructions cause the processor to perform the following operations:

[0071] If you only sample the create method in the monitored class, then configure the sampling level parameter in the plugin's configuration file to create;

[0072] If you only sample the create and delete methods in the monitored class, then configure the sampling level parameter in the plugin's configuration file to delete.

[0073] If you only sample the create, delete, and update methods in the monitored class, then configure the sampling level parameter in the plugin's configuration file to update;

[0074] If you want to sample all methods in the monitored class, then configure the sampling level parameter in the plugin's configuration file to query.

[0075] In an alternative approach, the executable instructions cause the processor to perform the following operations:

[0076] Add a forced sampling flag to the header of the user request. The forced sampling flag is used to indicate whether forced sampling is required.

[0077] Add a sampling type parameter to the plugin's configuration file. This sampling type parameter indicates whether to use the default sampling method or the grouped sampling method.

[0078] In an alternative approach, the executable instructions cause the processor to perform the following operations:

[0079] Define a Spring annotation plugin, write an Instrumentation class, monitor classes that meet the conditions in the enhanceClass method, and monitor classes declared with @RestController and @Service annotations;

[0080] The link level of the method is marked by the corresponding annotation defined in the monitored class;

[0081] The plugin apm-toolkit-trace supports linking multiple threads in multi-threaded scenarios;

[0082] Get the value of the sampling level parameter of RequestContext from the Interceptor class, and enhance the annotated method according to the value of the sampling level parameter;

[0083] Write an Interceptor class to create and configure the Span at the pointcut before the method execution, activate and deactivate the Span at the pointcut after the method execution, and log exceptions in the handleMethodException method.

[0084] In an alternative approach, the executable instructions cause the processor to perform the following operations:

[0085] Retrieve the forced sampling flag from the header. If the forced sampling flag is true, then forced sampling is performed by default.

[0086] If the sampling type parameter in the configuration file indicates a grouped sampling method, then different components are grouped, and requests in different groups use a separate set of ContextManager and SamplingService to count the sampling frequency.

[0087] In the HTTP request that calls Neutron, insert the traceId into the header request. Connect Neutron to SkyWalking, add the @trace annotation to the methods of the classes that implement the network product interface that need to be monitored, customize the method name for logging, and add the aforementioned request trace identifier.

[0088] This invention, through obtaining user requests processed by a gateway project; setting link priorities and filling logs with request link identifiers for the user requests; setting sampling rules for links and logs under various scenarios; defining plugins in different languages, and applying the plugins for instrumentation and sampling request links that conform to the sampling rules; and reporting, storing, and analyzing the log information generated by the request links, can associate the request link identifiers of plugins in different languages ​​with the logs, facilitating the tracking and location of call chains.

[0089] This invention provides a computer program product, which includes a computer program stored on a computer storage medium. The computer program includes program instructions, which, when executed by a computer, cause the computer to execute a distributed call link tracing method for a network product application in any of the above method embodiments.

[0090] Executable instructions can specifically be used to cause the processor to perform the following operations:

[0091] Obtain user requests after they have been processed by the gateway project;

[0092] Set the link priority for the user request and fill the log with the request link identifier;

[0093] Configure sampling rules for various scenarios involving links and logs;

[0094] Define plugins for different languages, and apply the plugins to instrument and sample request chains that conform to the sampling rules;

[0095] The log information generated by the request chain is reported, stored, and analyzed.

[0096] In an alternative approach, the executable instructions cause the processor to perform the following operations:

[0097] The user request is processed by the gateway project, which adds a request identifier to the header.

[0098] The user request carrying the request identifier is forwarded through the gateway.

[0099] In an alternative approach, the executable instructions cause the processor to perform the following operations:

[0100] Add the sampling level parameter to the plugin's configuration file;

[0101] Customize the format of the plugin's output logs and embed request link identifiers.

[0102] In an alternative approach, the executable instructions cause the processor to perform the following operations:

[0103] If you only sample the create method in the monitored class, then configure the sampling level parameter in the plugin's configuration file to create;

[0104] If you only sample the create and delete methods in the monitored class, then configure the sampling level parameter in the plugin's configuration file to delete.

[0105] If you only sample the create, delete, and update methods in the monitored class, then configure the sampling level parameter in the plugin's configuration file to update;

[0106] If you want to sample all methods in the monitored class, then configure the sampling level parameter in the plugin's configuration file to query.

[0107] In an alternative approach, the executable instructions cause the processor to perform the following operations:

[0108] Add a forced sampling flag to the header of the user request. The forced sampling flag is used to indicate whether forced sampling is required.

[0109] Add a sampling type parameter to the plugin's configuration file. This sampling type parameter indicates whether to use the default sampling method or the grouped sampling method.

[0110] In an alternative approach, the executable instructions cause the processor to perform the following operations:

[0111] Define a Spring annotation plugin, write an Instrumentation class, monitor classes that meet the conditions in the enhanceClass method, and monitor classes declared with @RestController and @Service annotations;

[0112] The link level of the method is marked by the corresponding annotation defined in the monitored class;

[0113] The plugin apm-toolkit-trace supports linking multiple threads in multi-threaded scenarios;

[0114] Get the value of the sampling level parameter of RequestContext from the Interceptor class, and enhance the annotated method according to the value of the sampling level parameter;

[0115] Write an Interceptor class to create and configure the Span at the pointcut before the method execution, activate and deactivate the Span at the pointcut after the method execution, and log exceptions in the handleMethodException method.

[0116] In an alternative approach, the executable instructions cause the processor to perform the following operations:

[0117] Retrieve the forced sampling flag from the header. If the forced sampling flag is true, then forced sampling is performed by default.

[0118] If the sampling type parameter in the configuration file indicates a grouped sampling method, then different components are grouped, and requests in different groups use a separate set of ContextManager and SamplingService to count the sampling frequency.

[0119] In the HTTP request that calls Neutron, insert the traceId into the header request. Connect Neutron to SkyWalking, add the @trace annotation to the methods of the classes that implement the network product interface that need to be monitored, customize the method name for logging, and add the aforementioned request trace identifier.

[0120] This invention, through obtaining user requests processed by a gateway project; setting link priorities and filling logs with request link identifiers for the user requests; setting sampling rules for links and logs under various scenarios; defining plugins in different languages, and applying the plugins for instrumentation and sampling request links that conform to the sampling rules; and reporting, storing, and analyzing the log information generated by the request links, can associate the request link identifiers of plugins in different languages ​​with the logs, facilitating the tracking and location of call chains.

[0121] Figure 4 The diagram shows a schematic of the structure of a computing device provided in an embodiment of the present invention. The specific embodiments of the present invention do not limit the specific implementation of the device.

[0122] like Figure 4 As shown, the computing device may include: a processor 402, a communications interface 404, a memory 406, and a communications bus 408.

[0123] The processor 402, communication interface 404, and memory 406 communicate with each other via communication bus 408. Communication interface 404 is used to communicate with other network elements such as clients or other servers. The processor 402 executes program 410, specifically performing the relevant steps in the distributed call link tracing method embodiment of the aforementioned network product application.

[0124] Specifically, program 410 may include program code that includes computer operation instructions.

[0125] Processor 402 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention. The device may include one or more processors of the same type, such as one or more CPUs; or it may include processors of different types, such as one or more CPUs and one or more ASICs.

[0126] Memory 406 is used to store program 410. Memory 406 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.

[0127] Specifically, program 410 can be used to cause processor 402 to perform the following operations:

[0128] Obtain user requests after they have been processed by the gateway project;

[0129] Set the link priority for the user request and fill the log with the request link identifier;

[0130] Configure sampling rules for various scenarios involving links and logs;

[0131] Define plugins for different languages, and apply the plugins to instrument and sample request chains that conform to the sampling rules;

[0132] The log information generated by the request chain is reported, stored, and analyzed.

[0133] In an alternative manner, the program 410 causes the processor to perform the following operations:

[0134] The user request is processed by the gateway project, which adds a request identifier to the header.

[0135] The user request carrying the request identifier is forwarded through the gateway.

[0136] In an alternative manner, the program 410 causes the processor to perform the following operations:

[0137] Add the sampling level parameter to the plugin's configuration file;

[0138] Customize the format of the plugin's output logs and embed request link identifiers.

[0139] In an alternative manner, the program 410 causes the processor to perform the following operations:

[0140] If you only sample the create method in the monitored class, then configure the sampling level parameter in the plugin's configuration file to create;

[0141] If you only sample the create and delete methods in the monitored class, then configure the sampling level parameter in the plugin's configuration file to delete.

[0142] If you only sample the create, delete, and update methods in the monitored class, then configure the sampling level parameter in the plugin's configuration file to update;

[0143] If you want to sample all methods in the monitored class, then configure the sampling level parameter in the plugin's configuration file to query.

[0144] In an alternative manner, the program 410 causes the processor to perform the following operations:

[0145] Add a forced sampling flag to the header of the user request. The forced sampling flag is used to indicate whether forced sampling is required.

[0146] Add a sampling type parameter to the plugin's configuration file. This sampling type parameter indicates whether to use the default sampling method or the grouped sampling method.

[0147] In an alternative manner, the program 410 causes the processor to perform the following operations:

[0148] Define a Spring annotation plugin, write an Instrumentation class, monitor classes that meet the conditions in the enhanceClass method, and monitor classes declared with @RestController and @Service annotations;

[0149] The link level of the method is marked by the corresponding annotation defined in the monitored class;

[0150] The plugin apm-toolkit-trace supports linking multiple threads in multi-threaded scenarios;

[0151] Get the value of the sampling level parameter of RequestContext from the Interceptor class, and enhance the annotated method according to the value of the sampling level parameter;

[0152] Write an Interceptor class to create and configure the Span at the pointcut before the method execution, activate and deactivate the Span at the pointcut after the method execution, and log exceptions in the handleMethodException method.

[0153] In an alternative manner, the program 410 causes the processor to perform the following operations:

[0154] Retrieve the forced sampling flag from the header. If the forced sampling flag is true, then forced sampling is performed by default.

[0155] If the sampling type parameter in the configuration file indicates a grouped sampling method, then different components are grouped, and requests in different groups use a separate set of ContextManager and SamplingService to count the sampling frequency.

[0156] In the HTTP request that calls Neutron, insert the traceId into the header request. Connect Neutron to SkyWalking, add the @trace annotation to the methods of the classes that implement the network product interface that need to be monitored, customize the method name for logging, and add the aforementioned request trace identifier.

[0157] This invention, through obtaining user requests processed by a gateway project; setting link priorities and filling logs with request link identifiers for the user requests; setting sampling rules for links and logs under various scenarios; defining plugins in different languages, and applying the plugins for instrumentation and sampling request links that conform to the sampling rules; and reporting, storing, and analyzing the log information generated by the request links, can associate the request link identifiers of plugins in different languages ​​with the logs, facilitating the tracking and location of call chains.

[0158] The algorithms or displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used in conjunction with the teachings herein. The required structure for constructing such systems is apparent from the above description. Furthermore, the embodiments of the present invention are not directed to any particular programming language. It should be understood that the content of the invention described herein can be implemented using various programming languages, and the above description of specific languages ​​is for the purpose of disclosing the best mode of implementation of the invention.

[0159] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.

[0160] Similarly, it should be understood that, in order to streamline the invention and aid in understanding one or more of the various aspects of the invention, features of the embodiments of the invention are sometimes grouped together in a single embodiment, figure, or description thereof in the above description of exemplary embodiments of the invention. However, this disclosure should not be construed as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim.

[0161] Those skilled in the art will understand that modules in the device of the embodiments can be adaptively changed and placed in one or more devices different from that embodiment. Modules, units, or components in the embodiments can be combined into a single module, unit, or component, and further, they can be divided into multiple sub-modules, sub-units, or sub-components. Except where at least some of such features and / or processes or units are mutually exclusive, any combination can be used to combine all features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all processes or units of any method or device so disclosed. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.

[0162] It should be noted that the above embodiments are illustrative of the invention and not restrictive, and that those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names. The steps in the above embodiments, unless otherwise specified, should not be construed as limiting the order of execution.

Claims

1. A method for distributed call tracing in network product applications, characterized in that, The method includes: Obtain user requests after they have been processed by the gateway project; The user requests are prioritized and logs are populated with request link identifiers. Specifically, a sampling level parameter is added to the plugin's configuration file to customize the plugin's output log format and embed the request link identifier. If only the `create` method in the monitored class is sampled, the sampling level parameter in the plugin's configuration file is configured as `create`. If only the `create` and `delete` methods in the monitored class are sampled, the sampling level parameter in the plugin's configuration file is configured as `delete`. If only the `create`, `delete`, and `update` methods in the monitored class are sampled, the sampling level parameter in the plugin's configuration file is configured as `update`. If all methods in the monitored class are sampled, the sampling level parameter in the plugin's configuration file is configured as `query`. Configure sampling rules for various scenarios of links and logs; among them, add a forced sampling flag to the header of the user request, which is used to indicate whether forced sampling is required; add a sampling type parameter to the plugin configuration file, which is used to indicate whether to use the default sampling method or the group sampling method. Define plugins for different languages, and apply the plugins to instrument and sample request chains that conform to the sampling rules; The log information generated by the request chain is reported, stored, and analyzed.

2. The method according to claim 1, characterized in that, Before obtaining the user request processed by the gateway project, the following steps are included: The user request is processed by the gateway project, which adds a request identifier to the header. The user request carrying the request identifier is forwarded through the gateway.

3. The method according to claim 1, characterized in that, The plugins that define different languages ​​include: Define a Spring annotation plugin, write an Instrumentation class, monitor classes that meet the conditions in the enhanceClass method, and monitor classes declared with @RestController and @Service annotations; The link level of the method is marked by the corresponding annotation defined in the monitored class; The plugin apm-toolkit-trace supports linking multiple threads in multi-threaded scenarios; Retrieve the value of the sampling level parameter of the RequestContext from the Interceptor class, and enhance the annotated method based on the value of the sampling level parameter; Write an Interceptor class to create and configure the Span at the pointcut before the method execution, activate and deactivate the Span at the pointcut after the method execution, and log exceptions in the handleMethodException method.

4. The method according to claim 1, characterized in that, The application of the plugin for instrumentation and sampling of request chains conforming to the sampling rules includes: Retrieve the forced sampling flag from the header. If the forced sampling flag is true, then forced sampling is performed by default. If the sampling type parameter in the configuration file indicates a grouped sampling method, then different components are grouped, and requests in different groups use a separate set of ContextManager and SamplingService to count the sampling frequency. In the HTTP request that calls Neutron, insert the traceId into the header request. Connect Neutron to SkyWalking, add the @trace annotation to the methods of the classes that implement the network product interface that need to be monitored, customize the method name for logging, and add the aforementioned request trace identifier.

5. A link tracing device for distributed calls in network product applications, characterized in that, The device includes: The request retrieval unit is used to retrieve user requests after they have been processed by the gateway project. The configuration unit is used to set the link priority and fill the request link identifier in the log for the user request. Specifically, a sampling level parameter is added to the plugin's configuration file to customize the format of the plugin's output log and embed the request link identifier. If only the `create` method in the monitored class is sampled, the sampling level parameter in the plugin's configuration file is configured as `create`. If only the `create` and `delete` methods in the monitored class are sampled, the sampling level parameter in the plugin's configuration file is configured as `delete`. If only the `create`, `delete`, and `update` methods in the monitored class are sampled, the sampling level parameter in the plugin's configuration file is configured as `update`. If all methods in the monitored class are sampled, the sampling level parameter in the plugin's configuration file is configured as `query`. The rule setting unit is used to set sampling rules for various scenarios of links and logs; among them, a forced sampling identifier is added to the header of the user request, which is used to indicate whether forced sampling is required; and a sampling type parameter is added to the plugin's configuration file, which is used to indicate whether to use the default sampling method or the group sampling method. The sampling unit is used to define plugins for different languages, and to apply the plugins to instrument and sample request links that conform to the sampling rules; The link tracing unit is used to report, store, and analyze the log information generated by the request link.

6. A computing device, characterized in that, include: The processor, memory, communication interface, and communication bus are provided, wherein the processor, memory, and communication interface communicate with each other via the communication bus. The memory is used to store at least one executable instruction that causes the processor to perform the steps of the link tracing method for distributed calls in a network product application according to any one of claims 1-4.

7. A computer storage medium, characterized in that, The storage medium stores at least one executable instruction that causes the processor to perform the steps of the link tracing method for distributed calls in a network product application according to any one of claims 1-4.

Citation Information

Patent Citations

  • Distributed service chain tracking and log aggregation method

    CN110806959A