Traffic recording and playback method and device, storage medium and computer device

CN122909149APending Publication Date: 2026-10-13LONGYING ZHIDA (BEIJING) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611101829.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-23
Publication Date
2026-10-13

AI Technical Summary

Technical Problem

[0004]有鉴于此,本申请实施例提供了一种流量录制与回放方法、装置、存储介质和计算机设备,以至少解决流量录制回放测试的保真度与可靠性低的技术问题

Benefits of technology

[0016]借由上述技术方案,本申请实施例提供的一种流量录制与回放方法,该方法包括:首先获取由请求报文与响应报文构成的请求响应对,以生成录制阶段拦截事件与回放阶段拦截事件,通过对响应报文进行解析提取动态字段,并对录制阶段拦截事件中的调用上下文元数据进行静态字节码分析,以得到目标引用关系图,随后,基于该目标引用关系图对动态字段进行因果指纹三元标注,生成因果指纹标注表,以构建录制时基与回放时基之间的时基偏移参数三元组,进而根据得到的因果指纹标注表和时基偏移参数三元组,利用参数重写算子对下游派生调用参数进行动态校正,以生成校正调用流;最终,通过计算校正调用流与录制调用流之间的偏离量,驱动时基偏移参数三元组迭代更新直至收敛,从而完成流量的录制与回放。也就是说,在本申请实施例中,通过对调用上下文元数据进行静态字节码分析,精准追踪动态字段的因果传染路径,并结合参数重写算子对下游派生调用参数进行动态降噪校正,利用偏离量驱动的收敛迭代机制自适应地拟合真实时基偏移,从而消除了因环境时间差引入的非缺陷性噪声误报,大幅提升了回归测试的精准度,实现了提高流量录制回放测试的保真度与可靠性的技术效果,解决了流量录制回放测试的保真度与可靠性低的技术问题。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122909149A_ABST
    Figure CN122909149A_ABST
Patent Text Reader

Abstract

The application discloses a traffic recording and playback method and device, a storage medium and a computer device. The method comprises the following steps: obtaining a request-response pair composed of a request message and a response message to generate an interception event; performing analysis processing on the response message to obtain a plurality of dynamic fields, and performing static bytecode analysis on the call context metadata in the interception event to obtain a target reference relationship graph; based on the target reference relationship graph, performing causal fingerprint ternary labeling on the plurality of dynamic fields to generate a causal fingerprint labeling table, and constructing a time base offset parameter triple; based on the causal fingerprint labeling table and the time base offset parameter triple, performing dynamic correction on the obtained downstream derived call parameters by using a parameter rewriting operator to obtain a corrected call flow; obtaining the deviation between the corrected call flow and a recording call flow to update the time base offset parameter triple until a convergence condition is met, thereby solving the problems of low fidelity and reliability of traffic recording and playback testing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of software testing technology, and in particular to a method, apparatus, storage medium, and computer device for recording and playing back traffic. Background Technology

[0002] With the evolution of microservice architecture, traffic recording and replay technology has attracted much attention because it can directly use real production traffic for regression testing. The conventional approach to this technology is to record the entry request and the response messages of downstream dependencies online to form a request-response pair. When replaying the entry traffic in the test environment, downstream calls are intercepted through simulation (Mock techniques) and the response messages from the recording phase are directly returned. Finally, the results of the replay are compared with the recording baseline to discover potential code defects in the system under test.

[0003] However, time base offsets, such as wall clocks, exist between the recording and playback environments, causing the system under test to generate dynamic fields when processing traffic containing time-related logic. These dynamic fields do not exist in isolation but are further read, calculated, and derived into intermediate fields through complex internal code reference relationships, ultimately "infecting" the input parameters of downstream derived calls. Existing traffic playback tools lack deep awareness of the internal execution logic of the code, failing to construct a reference relationship graph between fields or identify dynamic fields and their derivation paths caused by time base offsets. This results in a significant deviation in the distribution of downstream inputs intercepted during playback from corresponding calls during the recording stage, leading to numerous non-defect-related false alarms and severely reducing the fidelity and reliability of traffic recording and playback tests. Summary of the Invention

[0004] In view of this, embodiments of this application provide a method, apparatus, storage medium, and computer device for recording and playing back traffic data, so as to at least solve the technical problem of low fidelity and reliability in traffic recording and playback testing.

[0005] According to one aspect of this application, a method for recording and replaying traffic is provided. The method includes: acquiring a request-response pair consisting of a request message and a response message; generating an interception event based on the request-response pair, wherein the interception event includes at least a recording phase interception event and a replay phase interception event; parsing the response message to obtain multiple dynamic fields; performing static bytecode analysis on the call context metadata in the recording phase interception event to obtain a target reference relationship graph; based on the target reference relationship graph, performing causal fingerprint ternary annotation on the multiple dynamic fields to generate a causal fingerprint annotation table; and constructing a recording time base and a replay time base based on the causal fingerprint annotation table. The system uses a triplet of time base offset parameters between time bases, where the recording time base represents the time reference during traffic recording, and the playback time base represents the time reference during traffic playback. Downstream derived call parameters during traffic playback are obtained from intercepted events during the playback phase. Based on the causal fingerprint annotation table and the triplet of time base offset parameters, a parameter rewriting operator is used to dynamically correct the downstream derived call parameters, resulting in a corrected call stream. The system then obtains the deviation between the corrected call stream and the recording call stream during traffic recording, and updates the triplet of time base offset parameters based on the deviation until convergence conditions are met, thus achieving traffic recording and playback.

[0006] Optionally, static bytecode analysis is performed on the call context metadata in the intercepted events during the recording phase to obtain the target reference relationship graph. This includes: performing static bytecode analysis on the call context metadata to obtain an initial reference relationship graph with response message fields and intermediate fields derived along the call chain as nodes, and the reference relationships between fields as directed edges; counting the activation frequency of directed edges in the intercepted events during the recording phase to determine the activation weights, and updating the initial reference relationship graph based on the activation weights to determine the target reference relationship graph.

[0007] Optionally, based on the target reference graph, causal fingerprint ternary annotation is performed on multiple dynamic fields to generate a causal fingerprint annotation table. This includes: obtaining the activation weights of the target reference graph and traversing the target reference graph to determine the out-neighbor set of each dynamic field in the reference graph; constructing a membership function based on the out-neighbor set and activation weights, and calculating the membership degree of each dynamic field belonging to participating downstream derived classes, only bystander classes, and composite derived classes respectively using the membership function; selecting the type corresponding to the maximum membership degree as the annotation type of the dynamic field, and determining the confidence level of each dynamic field based on the membership degree of each dynamic field belonging to participating downstream derived classes, only bystander classes, and composite derived classes; and storing the field identifier, annotation type, and confidence level of each dynamic field in association to generate a causal fingerprint annotation table.

[0008] Optionally, based on the causal fingerprint annotation table, a triplet of time base offset parameters between the recording time base and the playback time base is constructed, including: filtering dynamic fields in the causal fingerprint annotation table whose annotation type is a participating downstream derived class and whose field type is timestamp; classifying the dynamic fields according to the field semantics to the target time base class, wherein the target time base class is selected from the wall clock time base class, monotonic clock time base class, and logical timing time base class; obtaining the actual value of the offset component of the target time base class between the recording time base and the playback time base, the standard deviation of the Gaussian distribution, the first field value of the target time base class in the interception event during the recording stage, and the second field value in the interception event during the playback stage, and based on the actual value of the offset component, Using the standard deviation, first field value, and second field value, a Gaussian model is constructed. Based on the Gaussian model, the time base offset components are obtained through maximum likelihood estimation. The time base offset components include at least three components: a first time base offset component, a second time base offset component, and a third time base offset component. The first time base offset component is the offset component corresponding to the target time base class being a wall clock time base class. The second time base offset component is the offset component corresponding to the target time base class being a monotonic clock time base class. The third time base offset component is the offset component corresponding to the target time base class being a logical timing time base class. A time base offset parameter triplet is constructed using the first, second, and third time base offset components.

[0009] Optionally, the parameter rewriting operator includes the following formula:

[0010] in, Used to indicate dynamic fields Apply offset parameters Rewrite the operator with subsequent parameters; Used to represent the triplet of time base offset parameters; Used to represent the first time base offset component; Used to represent the second time base offset component; Used to represent the third time base offset component; Used to represent mapping functions, It is the inverse function of the mapping function; A fingerprint parsing function used to represent a composite derived class. The inversion function used to represent the fingerprint parsing function; Used to represent dynamic fields The corresponding causal fingerprint annotation types: D is used to indicate downstream derived classes; B is used to indicate only bystander classes; and C is used to indicate synthetic derived classes. Used to represent dynamic fields The time base type is: w represents the wall clock time base class; m represents the monotonic clock time base class; s represents the logical timing time base class.

[0011] Optionally, the deviation between the correction call stream and the recording call stream during the traffic recording process can be obtained, including: obtaining the recording distribution of each dynamic field during the traffic recording process and the playback distribution of the correction call stream; and calculating the deviation of each dynamic field using the target divergence algorithm based on the recording distribution and playback distribution of each dynamic field.

[0012] Optionally, based on the deviation, the time base offset parameter triplet is updated until the convergence condition is met to achieve traffic recording and playback. This includes: determining the target sensitivity score based on the deviation, and obtaining a first scoring threshold and a second scoring threshold corresponding to the target sensitivity score, wherein the first scoring threshold is less than the second scoring threshold; generating a feedback signal in response to the target sensitivity score being greater than the second scoring threshold, and reconstructing the time base offset parameter triplet using the feedback signal; executing the next iteration operation in response to the target sensitivity score being greater than or equal to the first scoring threshold and less than or equal to the second scoring threshold; and executing a stop iteration operation in response to the target sensitivity score being less than the first scoring threshold.

[0013] According to another aspect of this application, a traffic recording and playback apparatus is provided. The apparatus includes: a generation unit, configured to acquire a request-response pair consisting of a request message and a response message, and generate an interception event based on the request-response pair, wherein the interception event includes at least: a recording phase interception event and a playback phase interception event; an analysis unit, configured to parse and process the response message to obtain multiple dynamic fields, and perform static bytecode analysis on the call context metadata in the recording phase interception event to obtain a target reference relationship graph; and a construction unit, configured to perform causal fingerprint ternary annotation on the multiple dynamic fields based on the target reference relationship graph to generate a causal fingerprint annotation table, and construct a recording time base and... The system comprises a time base offset parameter triplet between playback time bases, where the recording time base represents the time reference during traffic recording, and the playback time base represents the time reference during traffic playback; a correction unit, which obtains downstream derived call parameters during traffic playback from intercepted events during the playback phase, and dynamically corrects the downstream derived call parameters using a parameter rewriting operator based on the causal fingerprint labeling table and the time base offset parameter triplet to obtain the corrected call stream; and an update unit, which obtains the deviation between the corrected call stream and the recording call stream during traffic recording, and updates the time base offset parameter triplet based on the deviation until the convergence condition is met to achieve traffic recording and playback.

[0014] According to another aspect of this application, a storage medium is provided that stores a computer program thereon, which, when executed by a processor, implements the above-described traffic recording and playback method.

[0015] According to another aspect of this application, a computer device is provided, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor executes the program to implement the above-described traffic recording and playback method.

[0016] Using the above technical solution, this application provides a traffic recording and playback method, which includes: firstly, obtaining a request-response pair consisting of a request message and a response message to generate a recording stage interception event and a playback stage interception event; extracting dynamic fields by parsing the response message and performing static bytecode analysis on the call context metadata in the recording stage interception event to obtain a target reference relationship graph; subsequently, performing causal fingerprint triplet annotation on the dynamic fields based on the target reference relationship graph to generate a causal fingerprint annotation table to construct a time base offset parameter triplet between the recording time base and the playback time base; then, based on the obtained causal fingerprint annotation table and the time base offset parameter triplet, using a parameter rewriting operator to dynamically correct the downstream derived call parameters to generate a corrected call stream; finally, by calculating the deviation between the corrected call stream and the recorded call stream, driving the time base offset parameter triplet to iteratively update until convergence, thereby completing the traffic recording and playback. In other words, in this embodiment, by performing static bytecode analysis on the call context metadata, the causal propagation path of dynamic fields is accurately traced, and the downstream derived call parameters are dynamically denoised and corrected by combining parameter rewriting operators. The deviation-driven convergence iteration mechanism is used to adaptively fit the real time base offset, thereby eliminating non-defective noise false alarms introduced by environmental time differences, significantly improving the accuracy of regression testing, achieving the technical effect of improving the fidelity and reliability of traffic recording and playback testing, and solving the technical problem of low fidelity and reliability of traffic recording and playback testing.

[0017] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description

[0018] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 A flowchart illustrating a traffic recording and playback method provided in an embodiment of this application is shown; Figure 2 This illustration shows a schematic diagram of the structure of a traffic recording and playback platform provided in an embodiment of this application; Figure 3A flowchart illustrating a recording and playback method based on JavaAgent technology provided in an embodiment of this application is shown. Figure 4 This illustration shows a schematic diagram of a traffic recording and playback device provided in an embodiment of this application; Figure 5 A schematic diagram of the device structure of a computer device provided in an embodiment of this application is shown. Detailed Implementation

[0019] The present application will be described in detail below with reference to the accompanying drawings and embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in the embodiments of the present application can be combined with each other.

[0020] In this embodiment, Figure 1 This document illustrates a flowchart of a traffic recording and playback method provided in an embodiment of this application. Figure 1 As shown, the method includes: Step S101: Obtain the request-response pair consisting of the request message and the response message, and generate an interception event based on the request-response pair.

[0021] In the technical solution provided in step S101 of this application, a request-response pair consisting of a request message and a response message is obtained by using probe technology (JavaAgent technology), and an interception event is generated based on the obtained request-response pair. The interception event includes at least: a recording stage interception event and a playback stage interception event.

[0022] Optionally, JavaAgent technology is a bytecode enhancement mechanism provided by the Java Virtual Machine (JVM). This technology allows agent programs (probes) to dynamically intercept and rewrite the bytecode of target classes before class loading or at runtime without modifying the business source code, thereby achieving non-intrusive runtime state monitoring, data collection, and business logic enhancement of the application.

[0023] Optionally, the call context metadata, call snapshot, and recording stage identifier are obtained; the call context metadata, call snapshot, and recording stage identifier constitute the recording stage interception event. The call snapshot refers to the complete recording of the operational status of the system under test processing real traffic during the traffic recording stage.

[0024] Optionally, the call context metadata, call snapshot, and replay stage identifier are obtained; the call context metadata, call snapshot, and replay stage identifier constitute the replay stage interception event.

[0025] For example, using JavaAgent technology, bytecode probes are inserted into the external dependency methods called by the system under test to capture request-response pairs consisting of request and response messages and output interception events. These interception events include recording stage interception events and playback stage interception events, and the two have the same structure and are only distinguished by the recording stage identifier or the playback stage identifier.

[0026] Furthermore, by registering an AgentBuilder through the pre-main entry point or runtime entry point of JavaAgent, instrumentation points are located in the external dependency methods called by the system under test at three granularities: method name matching, annotation matching, and inheritance relationship matching. At each instrumentation point, two types of aspect bytecode—before advice and after advice—are woven in. Interception events are then assembled from three components: call context metadata, call snapshot, and recording or playback stage identifier. In other words, these three components are encapsulated into the aforementioned interception events, which are then delivered to the recording and storage module for asynchronous persistence. This step ensures that all external dependency calls triggered by a single entry request belong to the same tracing context.

[0027] It should be noted that this is only a preferred implementation method for generating interception events, and the process and method of generating interception events are not specifically limited. As long as it is based on request-response pairs, the process and method of generating interception events are within the protection scope of this application, and will not be listed here.

[0028] Step S102: The response message is parsed to obtain multiple dynamic fields, and the call context metadata in the intercepted event during the recording phase is analyzed by static bytecode to obtain the target reference relationship graph.

[0029] In the technical solution provided in step S102 of this application, the obtained response message is parsed to obtain multiple dynamic fields, and static bytecode analysis is performed on the call context metadata in the intercepted event during the recording phase to obtain the target reference relationship graph. The dynamic fields can be simply referred to as fields.

[0030] Optionally, dynamic fields include at least a timestamp field, a tracking identifier field, and a unique identifier field. The target reference graph is used to represent the causal propagation paths of reading, calculating, and deriving between fields within the code, and through... To express, ,in, This is a set of nodes used to represent elements such as dynamic fields contained in the target reference relationship graph. This is a set of edges used to represent the reference relationships between dynamic fields.

[0031] For example, in the system under test, the response message is first parsed to extract dynamic fields, such as "transaction time" and "serial number". Then, the call context metadata in the intercepted event during the recording phase is analyzed using static bytecode to trace the flow logic of these fields within the code, so as to generate a target reference relationship graph, thereby clearly representing the calculation and propagation path of the dynamic fields within the code.

[0032] It is understood that this is only a preferred implementation of obtaining the target reference relationship graph, and the method of obtaining the target reference relationship graph is not specifically limited. As long as the process and method of obtaining the target reference relationship graph by performing static bytecode analysis on the call context metadata in the intercepted event during the recording stage are within the protection scope of this application, they will not be listed here.

[0033] Step S103: Based on the target reference relationship graph, perform causal fingerprint ternary annotation on multiple dynamic fields to generate a causal fingerprint annotation table, and construct a time base offset parameter ternary between the recording time base and the playback time base based on the causal fingerprint annotation table.

[0034] In the technical solution provided in step S103 of this application, causal fingerprint ternary annotation is performed on multiple dynamic fields according to the target reference relationship graph to generate a causal fingerprint annotation table. Then, based on the causal fingerprint annotation table, a time base offset parameter ternary set between the recording time base and the playback time base can be constructed.

[0035] Optionally, the recording time base is used to represent the time reference during traffic recording, and the playback time base is used to represent the time reference during traffic playback. The causal fingerprint annotation table is used to characterize the causal contagion path derived from dynamic fields within the code, and the structured mapping relationship of their time base influence attributes. The time base offset parameter triplet may include: a wall clock offset component, a monotonic clock offset component, and a sequence number offset component.

[0036] For example, for each dynamic field identified in the response message, a record consisting of the field identifier, annotation type, and annotation confidence is generated. The above records for all fields are combined to form a causal fingerprint annotation table. Based on the causal fingerprint annotation table, a triplet of time base offset parameters between the recording time base and the playback time base is constructed to facilitate the next step of processing.

[0037] It is understood that this is only a preferred embodiment for constructing a triplet of time base offset parameters between the recording time base and the playback time base. The construction process and method of the triplet of time base offset parameters are not specifically limited. As long as it is based on the causal fingerprint labeling table, the process and method of constructing a triplet of time base offset parameters between the recording time base and the playback time base are within the protection scope of this application, and will not be listed here.

[0038] Step S104: Obtain the downstream derived call parameters during the traffic replay process from the intercepted events during the replay stage, and dynamically correct the downstream derived call parameters using the parameter rewriting operator based on the causal fingerprint labeling table and the time base offset parameter triplet to obtain the corrected call flow.

[0039] In the technical solution provided in step S104 of this application, downstream derived call parameters during the traffic replay process are obtained from the intercepted events during the replay stage. Then, based on the obtained causal fingerprint labeling table and time base offset parameter triplet, a parameter rewriting operator is used to dynamically correct the downstream derived call parameters to obtain a corrected call flow. The downstream derived call parameters can be referred to as downstream derived call context parameters or downstream derived call input parameters. The parameter rewriting operator can be... To express.

[0040] For example, when a downstream call is intercepted during the playback phase, its parameters include the dynamic field "request timestamp (T1)". According to the causal fingerprint annotation table, this field originates from the system clock; combined with the time base offset parameter triplet, the parameter rewriting operator corrects the request timestamp T1 at the time of recording. After this dynamic correction, the downstream derived call parameters conform to the playback time base, forming a corrected call flow that is causally consistent with the recorded traffic, ensuring the correctness of the playback logic.

[0041] Step S105: Obtain the correction call stream and the deviation between the recording call stream during the traffic recording process, and update the time base offset parameter triplet based on the deviation until the convergence condition is met, so as to realize traffic recording and playback.

[0042] In the technical solution provided in step S105 of this application, the deviation between the correction call stream and the recording call stream during the traffic recording process is obtained. Then, based on the obtained deviation, the time base offset parameter triplet is updated until the convergence condition is met, so as to realize traffic recording and playback. Here, the deviation can be called the distribution deviation.

[0043] For example, in the system under test, the recorded call stream includes a transaction time field (T2). During playback, the transaction time field T2 can be corrected to T2+Δ. However, the parameters of the downstream reconciliation call after playback deviate from the reconciliation parameters during recording by Δ1. After calculating this deviation, the time base offset parameter is updated, and the playback call parameters are corrected again. This process is repeated until the deviation is less than the threshold (convergence), ensuring that the playback call stream is consistent with the recorded stream and achieving accurate playback.

[0044] In the technical solution provided by steps S101 to S105 of this application, a request-response pair consisting of a request message and a response message is first obtained to generate a recording stage interception event and a playback stage interception event. Dynamic fields are extracted by parsing the response message, and static bytecode analysis is performed on the call context metadata in the recording stage interception event to obtain a target reference relationship graph. Subsequently, causal fingerprint triplet annotation is performed on the dynamic fields based on the target reference relationship graph to generate a causal fingerprint annotation table to construct a time base offset parameter triplet between the recording time base and the playback time base. Then, based on the obtained causal fingerprint annotation table and the time base offset parameter triplet, the downstream derived call parameters are dynamically corrected using a parameter rewriting operator to generate a corrected call flow. Finally, by calculating the deviation between the corrected call flow and the recorded call flow, the time base offset parameter triplet is driven to iteratively update until convergence, thereby completing the recording and playback of traffic. This application embodiment takes into account the need to perform static bytecode analysis on the call context metadata to accurately trace the causal propagation path of dynamic fields, and to combine parameter rewriting operators to dynamically denoise and correct downstream derived call parameters. It also utilizes a deviation-driven convergence iteration mechanism to adaptively fit the true time base offset, thereby eliminating non-defective noise false alarms introduced by environmental time differences. This significantly improves the accuracy of regression testing, achieves the technical effect of improving the fidelity and reliability of traffic recording and playback testing, and solves the technical problem of low fidelity and reliability in traffic recording and playback testing.

[0045] The method described in this embodiment will be further described below.

[0046] As an optional implementation, static bytecode analysis is performed on the call context metadata in the intercepted events during the recording phase to obtain the target reference relationship graph. This includes: performing static bytecode analysis on the call context metadata to obtain an initial reference relationship graph with response message fields and intermediate fields derived along the call chain as nodes, and the reference relationships between fields as directed edges; counting the activation frequency of directed edges in the intercepted events during the recording phase to determine the activation weights, and updating the initial reference relationship graph based on the activation weights to determine the target reference relationship graph.

[0047] In this embodiment, static bytecode analysis is performed on the call context metadata to obtain an initial reference graph with response message fields and intermediate fields derived along the call chain as nodes, and the reference relationships between fields as directed edges. The activation frequency of directed edges in intercepted events during the recording phase is then counted to determine the activation weight. Based on this activation weight, the target reference graph is determined. The activation frequency of a directed edge is the number of times it is actually activated during the recording phase.

[0048] Optionally, the activation frequency of directed edges in the intercepted events during the recording phase is counted using the following formula to determine the activation weight, including:

[0049] in, Used to represent fields To field The runtime activation weight of derived edges, which is a scalar and takes values ​​ranging from 1 to 2. Dimensionless; Used to represent fields To field The number of times a derived edge is actually activated during the recording phase is a scalar, with a value range of non-negative integers and is dimensionless. Used to represent the total number of events intercepted during the recording phase, it is a scalar with a value range of positive integers, dimensionless, and serves as the normalization base. Dimension verification: The left side is a dimensionless ratio, and the numerator and denominator on the right side are both dimensionless counts; the dimensions of both sides are consistent.

[0050] For example, by performing static bytecode analysis on the system under test, a reference relationship graph can be obtained. The reference graph is constructed using response message fields and intermediate fields derived along the call chain as nodes, and directed edges representing the derived data flows between fields. The reference graph depicts the dependency paths where each field is read by downstream calls and derived as input parameters for those calls. Its nodes are the two fields defined in the weight definition above (corresponding to the identified dynamic fields or intermediate fields derived along the call chain, and there can be one or more). During the interception point injection runtime observation probe, runtime activation weights are collected to update the constructed reference graph, resulting in the updated reference graph, i.e., the target reference graph.

[0051] As an optional implementation, based on the target reference graph, causal fingerprint ternary annotation is performed on multiple dynamic fields to generate a causal fingerprint annotation table. This includes: obtaining the activation weights of the target reference graph and traversing the graph to determine the out-neighbor set of each dynamic field; constructing a membership function based on the out-neighbor set and activation weights, and calculating the membership degree of each dynamic field belonging to participating downstream derived classes, merely observing classes, and composite derived classes using the membership function; selecting the type corresponding to the maximum membership degree as the annotation type of the dynamic field, and determining the confidence level of each dynamic field based on its membership degree; and storing the field identifier, annotation type, and confidence level of each dynamic field in association to generate a causal fingerprint annotation table.

[0052] In this embodiment, the activation weights of the target reference graph are first obtained, and the target reference graph is traversed to determine the out-neighbor set of each dynamic field in the reference graph. Then, based on the out-neighbor set and activation weights, a membership function is constructed. Using the membership function, the membership degree of each dynamic field belonging to the downstream derived class, the bystander class, and the composite derived class is calculated respectively. Then, the type corresponding to the maximum membership degree is selected as the labeling type of the dynamic field. Based on the membership degree of each dynamic field belonging to the downstream derived class, the bystander class, and the composite derived class, the confidence of each dynamic field is determined. Finally, the field identifier, labeling type, and confidence of each dynamic field are associated and stored to generate a causal fingerprint labeling table.

[0053] Alternatively, the set of out-adjacent edges can be obtained by... To express, Represented as a field The set of out-neighbor edges. The annotation type can be determined by... This can be represented. Confidence level can be expressed through... This can be represented. The membership function can be expressed as follows: To express.

[0054] Optionally, the membership function is constructed based on the out-neighbor set and activation weights using the following formula, including:

[0055] For each dynamic field Construct membership functions for three types of labels , And respectively represent participating in downstream derived classes, merely observing classes, and synthesized derived classes. Used to represent fields Labeled as type The membership degree, with a value range of . Dimensionless; The weights used to represent the fusion of static analysis and runtime observations are, more specifically, in this embodiment, empirically assigned to... Selected as follows , , One of them, wherein the above three values ​​are the components selected for the fusion weight of static analysis and runtime observation for the three types of participating downstream derived classes, only bystander classes, and synthetic derived classes respectively. That is, the same fusion weight that takes the value according to the type in the previous formula. It should be noted that, in addition to the empirical values ​​given in this embodiment, its value can also be determined by calibrating on the labeled field sample set with the goal of maximizing the accuracy of ternary labeling, so that it matches the corresponding type. Used to represent fields Does it fall into the type obtained from static analysis? Candidate set In the indicator function, the value is taken or ; Used to represent fields In the reference diagram The set of out-adjacent edges in the equation; Used to represent edges For type The contribution coefficient, with a value range of , where t takes one of three types: participating downstream derived class, merely observing class, and composite derived class; Used to represent edges Runtime activation weights.

[0056] Optionally, the type corresponding to the maximum membership degree can be selected as the annotation type for the dynamic field using the following formula, including:

[0057] in, Used to represent fields The annotation type takes values ​​from a set. , Recorded as participating in downstream derived classes, Recorded as a bystander only This is denoted as a synthesized derived class.

[0058] Optionally, the confidence level of each dynamic field is determined based on its membership degree to participating downstream derived classes, bystander classes, and composite derived classes using the following formula, including:

[0059] in, Used to represent fields The confidence level of the label, with a value range of 100%. It is dimensionless. For each dynamic field identified in the response message, a record consisting of three items is generated: the field identifier, the annotation type, and the annotation confidence level. By summarizing the above records for all fields, a causal fingerprint annotation table can be constructed.

[0060] As an optional implementation, based on a causal fingerprint annotation table, a triplet of time base offset parameters between the recording time base and the playback time base is constructed. This includes: filtering dynamic fields in the causal fingerprint annotation table whose annotation type is a participating downstream derived class and whose field type is timestamp; classifying the dynamic fields according to the field semantics to the target time base class, wherein the target time base class is selected from the wall clock time base class, monotonic clock time base class, and logical timing time base class; obtaining the actual value of the offset component of the target time base class between the recording time base and the playback time base, the standard deviation of the Gaussian distribution, the first field value of the target time base class in the interception event during the recording stage, and the second field value in the interception event during the playback stage, and based on the offset component... Measure the actual value, standard deviation, first field value, and second field value to construct a Gaussian model. Based on the Gaussian model, obtain the time base offset components through maximum likelihood estimation. The time base offset components include at least: a first time base offset component, a second time base offset component, and a third time base offset component. The first time base offset component is the offset component corresponding to the target time base class being the wall clock time base class. The second time base offset component is the offset component corresponding to the target time base class being the monotonic clock time base class. The third time base offset component is the offset component corresponding to the target time base class being the logical timing time base class. Construct a time base offset parameter triplet using the first time base offset component, the second time base offset component, and the third time base offset component.

[0061] In this embodiment, dynamic fields in the causal fingerprint annotation table that are labeled as participating downstream derived classes and whose field type is timestamp are first screened. Then, according to the field semantics, the dynamic fields are assigned to the target time base class selected from the wall clock time base class, monotonic clock time base class, and logical timing time base class. Then, the actual value of the offset component of the target time base class between the recording time base and the playback time base, the standard deviation of the Gaussian distribution, the first field value of the target time base class in the intercepted event during the recording stage, and the second field value in the intercepted event during the playback stage are obtained. Then, based on the actual value, standard deviation, first field value, and second field value of the offset component obtained above, a Gaussian model is constructed. Finally, based on the Gaussian model, the time base offset component is obtained by maximum likelihood estimation. The time base offset component includes at least three time base offset components. Through these three time base offset components, the time base offset parameter triplet is constructed.

[0062] Optionally, the actual value of the offset component can be called the true value of the offset component. For example, when the target time base class is a wall clock time base class, the actual value of the offset component is the true value of the wall clock offset component. The first field value is the timestamp field value during the recording stage. For example, when the target time base class is a wall clock time base class, the first field value is the wall clock timestamp field value during the recording stage. The second field value is the corresponding timestamp field value during the playback stage. For example, when the target time base class is a wall clock time base class, the second field value is the corresponding wall clock timestamp field value during the playback stage.

[0063] Optionally, based on the Gaussian model, the maximum likelihood estimate of the offset component is obtained through maximum likelihood estimation, and this maximum likelihood estimate is determined as the time base offset component. The time base offset component includes at least: a first time base offset component, a second time base offset component, and a third time base offset component. The first time base offset component can be referred to as the wall clock offset component, and is determined through... In this representation, the second time base offset component can be called the monotonic clock offset component, and is expressed as follows: The third time base offset component can be called the logical timing offset component or the sequence number offset component, and is represented by... This is represented. The time base offset parameter triplet is expressed through... To express.

[0064] For example, based on the causal fingerprint annotation table, a time base offset parameter triplet is constructed between the recording time base and the playback time base. The time base offset parameter triplet includes a wall clock offset component, a monotonic clock offset component, and a logical timing offset component. The timestamp fields participating in downstream derived classes are automatically assigned to the wall clock time base class, monotonic clock time base class, or logical timing time base class according to the field semantics. For each time base class, the corresponding time base offset component is obtained by maximum likelihood estimation based on pairwise samples of the same timestamp field values.

[0065] Optionally, a Gaussian model is constructed based on the actual values ​​and standard deviations of the offset components, the values ​​of the first field, and the values ​​of the second field, using the following formula:

[0066] Taking the wall clock offset component as an example, it is assumed that the offset between the recording time base and the playback time base follows a position parameter. Scale parameters are In the Gaussian model, the above formula, The first one used to indicate the recording stage The wall clock timestamp field value is in milliseconds (ms). The timestamp field value of the wall clock during the playback phase is used to represent the value of the wall clock in milliseconds. Used to represent the true value of the wall clock offset component, in milliseconds (ms); Used to indicate the first The observation noise for each sample, in milliseconds; denoted as the standard deviation of the Gaussian distribution, in milliseconds (ms).

[0067] Furthermore, the time base offset component is obtained by maximum likelihood estimation based on the Gaussian model using the following formula, including:

[0068] According to the Gaussian model, the log-likelihood function is expressed by the formula above. 'n' represents the number of samples (i.e., the number of data points). Taking the wall clock offset component as an example, for... and Taking the partial derivatives and setting them to zero, we obtain the maximum likelihood estimates of the wall clock offset component and variance:

[0069] in, The maximum likelihood estimate of the wall clock offset component is used to represent the unit ms. This is used to represent the maximum likelihood estimate of the observed noise variance, in ms². It should be noted that dimensional verification is performed here: The unit on the left is milliseconds (ms), and the unit on the right is milliseconds (ms). The unit is milliseconds (ms), summed and then divided by the dimensionless value. Still in milliseconds (ms), with consistent dimensions; The unit on the left is ms², and the unit on the right is... The unit is ms², and the dimensions are consistent. It should be noted that the monotonic clock offset component and the sequence number offset component are constructed separately according to the same modeling approach as the wall clock offset component, in order to obtain the second time base offset component and the third time base offset component, and realize the construction of the final time base offset parameter triplet.

[0070] As an optional implementation, the parameter rewriting operator includes the following formula:

[0071] in, Used to indicate dynamic fields Apply offset parameters Rewrite the operator with subsequent parameters; Used to represent the triplet of time base offset parameters; Used to represent the first time base offset component; Used to represent the second time base offset component; Used to represent the third time base offset component; Used to represent mapping functions, It is the inverse function of the mapping function; A fingerprint parsing function used to represent a composite derived class. The inversion function used to represent the fingerprint parsing function; Used to represent dynamic fields The corresponding causal fingerprint annotation types: D is used to indicate downstream derived classes; B is used to indicate only bystander classes; and C is used to indicate synthetic derived classes. Used to represent dynamic fields The time base type is: w represents the wall clock time base class; m represents the monotonic clock time base class; s represents the logical timing time base class.

[0072] In this embodiment, based on the time base offset parameter triplet, dynamic correction is performed on the downstream derived call parameters generated by the system under test during the playback phase, and a corrected call stream is output. That is, at the bytecode enhancement interception point of the downstream derived call method in the system under test, the downstream derived call input parameters are captured, the input parameter object is read via reflection, and the input parameter graph is dynamically constructed by combining it with the derivation path recorded in the causal fingerprint annotation table. Each input parameter field is processed according to the topological order of the input parameter graph. Apply parameters to rewrite operators :

[0073] in, Used to indicate input parameters Apply offset parameters The result of the rewrite; For the time base offset parameter triple; For reference The causal fingerprint labeling type of the corresponding field (i.e., the value can be one of the following: participating downstream derived class, merely observing class, or synthetic derived class); This is a mapping function from sequence number to integer ordinal number. It is the inverse function of the mapping function; This is a composite function for fingerprint parsing in a synthesized derived class. This is the inverse function of the combined function fingerprint parsing function. It should be noted that the rewritten downstream derived call parameters are used as elements of the corrected call stream, assembled into a corrected call stream according to the timestamp order of the intercepted events, and output to the next step for processing.

[0074] As an optional implementation method, obtaining the correction call stream and the deviation between the recording call stream and the recording call stream during the traffic recording process includes: obtaining the recording distribution of each dynamic field during the traffic recording process and the playback distribution of the correction call stream; and calculating the deviation of each dynamic field using a target divergence algorithm based on the recording distribution and playback distribution of each dynamic field.

[0075] In this embodiment, the recording distribution of each dynamic field during the traffic recording process and the playback distribution of the corrected call stream are obtained. Then, based on the recording distribution and playback distribution of each dynamic field, the deviation of each dynamic field is calculated using the target divergence algorithm.

[0076] Optionally, the target divergence algorithm can be a preset divergence algorithm, such as relative entropy (Kullback-Leibler divergence, or KL divergence for short). The recording distribution can be determined through... This is represented. The playback distribution can be called the input parameter distribution, and it can be represented by... To express.

[0077] Optionally, the deviation of each dynamic field is calculated using the target divergence algorithm based on the recording and playback distributions of each dynamic field, according to the following formula:

[0078] in, Used to represent fields The KL divergence between the recording distribution and the playback distribution is the dynamic field. The deviation is expressed in nats; x represents the sample point. Used to represent the set of samples corresponding to sample points; To prevent extremely small constants from being divided by zero, this embodiment takes... In other words, for each dynamic field Establish recording distribution during the recording phase During the playback phase, establish the parameter distribution of this field in the corrected call stream element. The Kullback-Leibler divergence is used, that is, the distribution deviation between the two is calculated using the above formula.

[0079] As an optional implementation, the time base offset parameter triplet is updated based on the deviation until a convergence condition is met to achieve traffic recording and playback. This includes: determining a target sensitivity score based on the deviation, and obtaining a first scoring threshold and a second scoring threshold corresponding to the target sensitivity score, wherein the first scoring threshold is less than the second scoring threshold; generating a feedback signal in response to the target sensitivity score being greater than the second scoring threshold, and reconstructing the time base offset parameter triplet using the feedback signal; executing the next iteration operation in response to the target sensitivity score being greater than or equal to the first scoring threshold and less than or equal to the second scoring threshold; and stopping the iteration operation in response to the target sensitivity score being less than the first scoring threshold.

[0080] In this embodiment, a target sensitivity score is determined based on the deviation amount, and a first scoring threshold and a second scoring threshold corresponding to the target sensitivity score are obtained. The target sensitivity score is compared with the first scoring threshold and the second scoring threshold, respectively. When the target sensitivity score is greater than the second scoring threshold, a feedback signal is generated, and the time base offset parameter triplet is reconstructed using the feedback signal. When the target sensitivity score is greater than or equal to the first scoring threshold and less than or equal to the second scoring threshold, the next round of iteration is executed. When the target sensitivity score is less than the first scoring threshold, the iteration is stopped.

[0081] Optionally, the first scoring threshold can be called the convergence threshold, which can be determined by... This is represented. The second scoring threshold, which can be called the feedback threshold, can be expressed through... The target sensitivity score can be represented by T. The target sensitivity score can also be called the global infectivity score, or simply the infectivity score.

[0082] Optionally, the target sensitivity score is determined based on the deviation using the following formula, including:

[0083] in, Infectivity score, unit: nat; Used to represent fields The weight corresponding to the annotation type. (Take...) , , ,and To select the field from the above three weights The weights correspond to the labeling type. In other words, the KL divergence of each field is weighted according to the causal fingerprint labeling type to obtain the global infectivity score.

[0084] Furthermore, based on the infectivity score and the preset feedback threshold... and convergence threshold The feedback action is determined, and the above process can be represented by the following formula:

[0085] in, Used to represent the feedback threshold, which can be taken as... nat; Used to represent the convergence threshold, can be taken as... nat; The threshold value satisfies This ensures the state machine does not jitter. Action(T) is the feedback action of the decision output, taking one of three values: a1, a2, or a3. When the value is a1, a feedback trigger signal is generated to trigger parameter reestimation; when the value is a2, the next round of observation continues; when the value is a3, the time base offset parameter triplet is locked and feedback iteration stops. It should be noted that the feedback action decision result given by Action(T) is one of three values: trigger feedback, continue iteration, or convergence and locking.

[0086] Furthermore, when triggering parameter reestimation, the confidence interval is used as prior information to trigger the reestimation. New observation samples are then fused using a Bayesian posterior update method to obtain the updated time base offset parameter triplet. Taking the wall clock offset component as an example, the confidence interval is obtained as follows: Based on Fisher information, a two-sided 95% confidence interval for the wall clock offset component is constructed, which can be expressed by the following formula:

[0087] in, Used to represent the two-sided 95% confidence interval of the wall clock offset component, in milliseconds; This value represents the upper 2.5% quantile of the standard normal distribution, with a value of 1.96 and is dimensionless. It should be noted that the confidence intervals corresponding to the monotonic clock offset component and the sequence number offset component can be determined separately using the same modeling approach as the wall clock offset component.

[0088] By applying the technical solution of this embodiment, a request-response pair consisting of a request message and a response message is first obtained to generate interception events during the recording and playback stages. Dynamic fields are extracted by parsing the response message, and static bytecode analysis is performed on the call context metadata in the recording stage interception event to obtain a target reference relationship graph. Subsequently, causal fingerprint triplet annotation is performed on the dynamic fields based on the target reference relationship graph to generate a causal fingerprint annotation table to construct a time base offset parameter triplet between the recording time base and the playback time base. Then, based on the obtained causal fingerprint annotation table and the time base offset parameter triplet, the downstream derived call parameters are dynamically corrected using a parameter rewriting operator to generate a corrected call stream. Finally, by calculating the deviation between the corrected call stream and the recorded call stream, the time base offset parameter triplet is driven to iteratively update until convergence, thereby completing the recording and playback of traffic. This application embodiment takes into account the need to perform static bytecode analysis on the call context metadata to accurately trace the causal propagation path of dynamic fields, and to combine parameter rewriting operators to dynamically denoise and correct downstream derived call parameters. It also utilizes a deviation-driven convergence iteration mechanism to adaptively fit the true time base offset, thereby eliminating non-defective noise false alarms introduced by environmental time differences. This significantly improves the accuracy of regression testing, achieves the technical effect of improving the fidelity and reliability of traffic recording and playback testing, and solves the technical problem of low fidelity and reliability in traffic recording and playback testing.

[0089] Furthermore, as Figure 1 In the specific implementation of the method, in the embodiments of this application, Figure 2 This paper illustrates a schematic diagram of the structure of a traffic recording and playback platform provided in an embodiment of this application. Figure 2 As shown, the traffic recording and playback platform may include: bytecode enhancement interception module 1, causal fingerprint annotation module 2, time base offset modeling module 3, derived call correction module 4, infectivity observation module 5, recording and storage module 6, and matching pattern extension module 7, and the infectivity scoring feedback path from infectivity observation module 5 to time base offset modeling module 3 is marked with a dashed arrow.

[0090] Bytecode Enhancement Interception Module 1 is used for recording and replaying data capture infrastructure. Relying on a set of interfaces provided by the Java Virtual Machine (JVM Instrumentation API), it dynamically attaches JavaAgent technology during the JVM process loading phase or runtime of the system under test. It inserts bytecode probes into the externally dependent methods called by the system under test, captures request-response pairs composed of request and response messages, and outputs interception events.

[0091] Optionally, the bytecode enhancement interception module 1 weaves two types of aspect bytecode—before advice and after advice—into each instrumentation point: before advice captures the request message before the execution of the original method bytecode, where the request message includes the target Uniform Resource Locator, request line parameters, request body payload, and request header set; after advice captures the response message after the original method bytecode returns normally or throws an exception, where the response message includes the response status code, response header set, response body payload or exception type and stack, and binds the request message and response message into a request-response pair.

[0092] Causal fingerprint annotation module 2 is used to receive the interception event output by bytecode enhancement interception module 1, perform causal fingerprint ternary annotation on the dynamic fields in the response message for participating downstream derived classes, only bystander classes and synthetic derived classes, and output causal fingerprint annotation table.

[0093] Optionally, the causal fingerprinting module 2 first performs static analysis on the bytecode of the system under test. Through depth-first traversal of the method call graph, operand stack tracing, and local variable assignment-usage chain analysis, it obtains the reference relationship graph of the return value fields of external dependent methods and the input parameter fields of downstream derived calls. Based on this, the causal fingerprint annotation module 2 injects runtime observation probes at the interception points of the bytecode enhancement interception module 1 to collect the frequency of actual activation of each edge in the reference relationship graph during the recording phase, obtain the runtime activation weight, and then construct the membership function of the three types of annotations and determine the annotation type through argmax operation.

[0094] The time base offset modeling module 3 is used to construct a time base offset parameter triplet between the recording time base and the playback time base based on the causal fingerprint annotation table. The time base offset parameter triplet includes the wall clock offset component, the monotonic clock offset component, and the serial number offset component.

[0095] Optionally, the time base offset modeling module 3 automatically assigns the timestamp field to the corresponding time base class based on its semantic characteristics: the timestamp field of the wall clock time base class is presented as a date and time string or milliseconds, and its value spans across calendar days; the timestamp field of the monotonic clock time base class is presented as nanoseconds or microseconds, and its monotonicity exists only within a single process; the timestamp field of the logical time series time base class is presented as a business serial number or transaction sequence number, and its value monotonically increases according to business rules. For the wall clock time base class, the monotonic clock time base class, and the logical time series time base class, the time base offset modeling module 3 uses the maximum likelihood estimation method to construct the corresponding time base offset components and 95% confidence intervals, respectively.

[0096] Optionally, the monotonic clock offset component is uniformly aligned to the nanosecond-level monotonic clock within the JVM process during sample acquisition, and the sequence number offset component is estimated using a differential method based on the algebraic group structure of the business serial number. When the infectivity score fed back by the infectivity observation module 5 exceeds the preset threshold, the time base offset modeling module 3 uses the confidence interval as prior information to trigger parameter re-estimation, and fuses the new observation samples using a Bayesian posterior update method to obtain the updated time base offset parameter triplet.

[0097] The derived call correction module 4 is used to perform dynamic correction on the downstream derived call field parameters generated by the system under test during the playback stage based on the time base offset parameter triplet, and output the correction call stream.

[0098] Optionally, the derived call correction module 4 captures the downstream derived call input parameters at the bytecode enhancement interception pre-point of the downstream derived call method in the system under test, and performs parameter rewriting on the input parameter fields contaminated by stale dynamic fields based on the causal fingerprint annotation table and the time base offset parameter triplet. The derived call correction module 4 first constructs an input parameter graph for the downstream derived call input parameters. The graph is dynamically constructed by the derived call correction module 4 at the time of the call by reading the input parameter object tree through reflection and combining it with the derived path recorded in the causal fingerprint annotation table.

[0099] Optionally, the derived call to the correction module 4 applies the parameter rewrite operator to each input parameter field according to the topological order of the input parameter graph. When there are composite derived class nodes in the input parameter graph, the derived call to the correction module 4 follows the combination function fingerprint. Perform function inversion, that is, first input parameters to the synthesized derived class... Decompose into independent factor fields, and recursively apply the parameter rewrite operator to each factor field. Finally, after The original input parameter space is synthesized. In this embodiment, the derived call correction module 4 maintains field-level shadow copies before and after correction to support rollback. When the correction causes the tested system to throw a validity check exception, the derived call correction module 4 rolls back the input parameters to the unrewritten state according to the preset rollback strategy and records the event in the exception log.

[0100] Infectivity observation module 5 is used to statistically analyze the deviation of the corrected call stream from the corresponding call in the recording stage and generate an infectiousness score. The infectiousness score is then fed back to time base offset modeling module 3 to iteratively update the time base offset parameter triplet.

[0101] Optionally, the infectivity observation module 5 receives the correction call stream output by the derived call correction module 4 and performs deviation statistics on the distribution of downstream derived call input parameters in the intercepted events during the recording phase. For each dynamic field... The infectivity observation module 5 first establishes the input parameter distribution for this field during the recording phase. During the playback phase, establish the parameter distribution of this field in the corrected call stream element. Then, the distribution deviation between the two was calculated using Kullback-Leibler divergence, and the global infectivity score was obtained by weighting them according to the causal fingerprint labeling type. Based on the infectivity score and a preset feedback threshold. and convergence threshold Three levels of decision-making for determining feedback actions.

[0102] The recording and storage module 6 is used to connect directly with the bytecode enhancement and interception module 1. It is responsible for asynchronously serializing the intercepted events into recording session records by timestamp and persisting them to persistent storage media, including file systems, relational databases and object storage.

[0103] Optionally, the recording and storage module 6 adopts a decoupled producer-consumer queue model. After the bytecode enhancement interception module 1 delivers the intercepted event to the bounded blocking queue, it immediately returns to avoid blocking the business path of the system under test. The background asynchronous thread consumes the queue and serializes it into the target format (Protobuf format) in batches according to the preset batch size before writing it to the persistent storage medium.

[0104] The matching pattern extension module 7 is used to provide a set of matching patterns during the replay stage. The set of matching patterns includes three types: exact matching pattern, fuzzy matching pattern, and script-extracted matching pattern. It also injects specific markers into the request header through a traffic coloring mechanism to distinguish between real traffic and replay traffic.

[0105] Optionally, the matching pattern extension module 7 provides a set of matching patterns during the playback phase. The exact matching pattern compares playback requests and recording requests by field equality, suitable for idempotent query interfaces; the fuzzy matching pattern calls the causal fingerprint annotation table to perform exemption comparisons on participating downstream derived classes, with the remaining fields after exemption still compared by field equality, suitable for interfaces containing dynamic fields; the script extraction matching pattern extracts key-value pairs from the request message according to a user-defined script file and then compares them, suitable for requests with complex nested structures. The matching pattern extension module 7 also injects specific markers into the request header through a traffic coloring mechanism to distinguish between real traffic and playback traffic.

[0106] In this embodiment, the recording and storage module 6 is directly connected to the bytecode enhancement interception module 1 and asynchronously persists the interception events delivered to the bounded blocking queue by the bytecode enhancement interception module 1. The matching mode extension module 7 is connected to the bytecode enhancement interception module 1 and the causal fingerprint labeling module 2, calls the causal fingerprint labeling table to perform exemption comparisons on the participating downstream derived classes, and reads the traffic coloring mark by the bytecode enhancement interception module 1 at the gateway or entry interception point to switch the recording or playback working mode.

[0107] Optionally, the output of the intercepted events from the bytecode enhancement interception module 1 is simultaneously supplied to the causal fingerprint annotation module 2 for field identification and to the derived call correction module 4 for capturing the derived call pre-point. The causal fingerprint annotation table output by the causal fingerprint annotation module 2 drives the time base offset modeling module 3 to lock the sample range of the downstream derived class timestamp fields and also drives the derived call correction module 4 to determine the branch selection of the parameter rewriting operator. The time base offset parameter triplet output by the time base offset modeling module 3 is directly used as the offset parameter of the parameter rewriting operator of the derived call correction module 4. The correction call stream output by the derived call correction module 4 is the input of the deviation statistics of the infectivity observation module 5. The infectivity score generated by the infectivity observation module 5 updates the parameter estimation of the time base offset modeling module 3 through the feedback path, thereby completing the causal infection suppression closed loop.

[0108] In this application embodiment, a JavaAgent-based recording and playback system is provided. The system includes a processor and a memory. The processor may be a central processing unit, a graphics processing unit, a tensor processing unit, or a heterogeneous combination of the above processors. The memory includes non-volatile storage media and volatile storage media. When computer instructions are executed by the processor, the above seven modules are instantiated in the processor's process space respectively.

[0109] Furthermore, as Figure 1 In the specific implementation of the method, in the embodiments of this application, Figure 3 This document illustrates a flowchart of a recording and playback method based on JavaAgent technology, as provided in an embodiment of this application. Figure 3 As shown, the method mainly includes the following steps: Step S301, bytecode enhancement interception.

[0110] Step S302, causal fingerprint ternary labeling.

[0111] Step S303, Time Base Shift Modeling.

[0112] Step S304, Derivative call correction.

[0113] Step S305, Infectivity observation.

[0114] Step S306: Determine whether the infectivity score has converged.

[0115] In this embodiment, it is necessary to determine whether the infectivity score has converged. If it has converged, the process ends directly; if it has not converged, step S303 is executed, which involves updating the time base offset parameter triplet.

[0116] In the technical solutions provided in steps S301 to S306, steps S301 to S302 are executed during the recording phase to establish a causal fingerprint labeling table and a recording baseline distribution; and the complete steps of S301 to S306 are executed during the playback phase to achieve the active cutting off of the stale time-series snapshot's downstream derived call infection path along the call chain.

[0117] Furthermore, as Figure 1 In the specific implementation of the method, in the embodiments of this application, Figure 4 This paper illustrates a schematic diagram of a traffic recording and playback device according to an embodiment of this application. Figure 4 As shown, the traffic recording and playback device 400 includes: a generation unit 401, an analysis unit 402, a construction unit 403, a correction unit 404, and an update unit 405.

[0118] The generation unit 401 is used to obtain a request-response pair consisting of a request message and a response message, and generate an interception event based on the request-response pair. The interception event includes at least a recording stage interception event and a playback stage interception event.

[0119] Analysis unit 402 is used to parse and process the response message to obtain multiple dynamic fields, and to perform static bytecode analysis on the call context metadata in the intercepted event during the recording phase to obtain the target reference relationship graph.

[0120] The construction unit 403 is used to perform causal fingerprint ternary annotation on multiple dynamic fields based on the target reference relationship graph, generate a causal fingerprint annotation table, and construct a time base offset parameter ternary between the recording time base and the playback time base based on the causal fingerprint annotation table. The recording time base is used to represent the time base during the traffic recording process, and the playback time base is used to represent the time base during the traffic playback process.

[0121] The correction unit 404 is used to obtain the downstream derived call parameters in the traffic playback process from the intercepted events during the playback stage, and to dynamically correct the downstream derived call parameters based on the causal fingerprint label table and the time base offset parameter triplet, using the parameter rewriting operator to obtain the corrected call flow.

[0122] The update unit 405 is used to obtain the correction call stream and the deviation between the recording call stream during the traffic recording process, and update the time base offset parameter triplet based on the deviation until the convergence condition is met, so as to realize traffic recording and playback.

[0123] Optionally, the device is further configured to: perform static bytecode analysis on the call context metadata in the intercepted events during the recording phase to obtain a target reference graph, including: performing static bytecode analysis on the call context metadata to obtain an initial reference graph with response message fields and intermediate fields derived along the call chain as nodes and the reference relationships between fields as directed edges; counting the activation frequency of directed edges in the intercepted events during the recording phase to determine the activation weights, and updating the initial reference graph based on the activation weights to determine the target reference graph.

[0124] Optionally, the device is further configured to: perform causal fingerprint ternary annotation on multiple dynamic fields based on the target reference graph to generate a causal fingerprint annotation table, including: obtaining the activation weights of the target reference graph and traversing the target reference graph to determine the set of out-neighbor edges for each dynamic field in the reference graph; constructing a membership function based on the out-neighbor set and activation weights, and calculating the membership degree of each dynamic field belonging to participating downstream derived classes, only bystander classes, and composite derived classes respectively through the membership function; selecting the type corresponding to the maximum membership degree as the annotation type of the dynamic field, and determining the confidence level of each dynamic field based on the membership degree of each dynamic field belonging to participating downstream derived classes, only bystander classes, and composite derived classes; and storing the field identifier, annotation type, and confidence level of each dynamic field in association to generate a causal fingerprint annotation table.

[0125] Optionally, the device is further configured to: construct a triplet of time base offset parameters between the recording time base and the playback time base based on a causal fingerprint annotation table, including: filtering dynamic fields in the causal fingerprint annotation table whose annotation type is a participating downstream derived class and whose field type is a timestamp; classifying the dynamic fields according to the field semantics to a target time base class, wherein the target time base class is selected from wall clock time base class, monotonic clock time base class, and logical timing time base class; obtaining the actual value of the offset component of the target time base class between the recording time base and the playback time base, the standard deviation of the Gaussian distribution, the first field value of the target time base class in the interception event during the recording stage, and the second field value in the interception event during the playback stage, and based on the offset component A Gaussian model is constructed using the actual value, standard deviation, first field value, and second field value. Based on the Gaussian model, the time base offset components are obtained through maximum likelihood estimation. The time base offset components include at least three components: a first time base offset component, a second time base offset component, and a third time base offset component. The first time base offset component is the offset component corresponding to the target time base class being a wall clock time base class, the second time base offset component is the offset component corresponding to the target time base class being a monotonic clock time base class, and the third time base offset component is the offset component corresponding to the target time base class being a logical timing time base class. A time base offset parameter triplet is constructed using the first, second, and third time base offset components.

[0126] Optionally, the parameter rewriting operator includes the following formula:

[0127] in, Used to indicate dynamic fields Apply offset parameters Rewrite the operator with subsequent parameters; Used to represent the triplet of time base offset parameters; Used to represent the first time base offset component; Used to represent the second time base offset component; Used to represent the third time base offset component; Used to represent mapping functions, It is the inverse function of the mapping function; A fingerprint parsing function used to represent a composite derived class. The inversion function used to represent the fingerprint parsing function; Used to represent dynamic fields The corresponding causal fingerprint annotation types: D is used to indicate downstream derived classes; B is used to indicate only bystander classes; and C is used to indicate synthetic derived classes. Used to represent dynamic fields The time base type is: w represents the wall clock time base class; m represents the monotonic clock time base class; s represents the logical timing time base class.

[0128] Optionally, the device is also used to: acquire the correction call stream and the deviation between the recording call streams during the traffic recording process, including: acquiring the recording distribution of each dynamic field during the traffic recording process and the playback distribution of the correction call stream; and calculating the deviation of each dynamic field using a target divergence algorithm based on the recording distribution and playback distribution of each dynamic field.

[0129] Optionally, the device is further configured to: update the time base offset parameter triplet based on the deviation until the convergence condition is met, so as to realize traffic recording and playback, including: determining the target sensitivity score based on the deviation, and obtaining a first scoring threshold and a second scoring threshold corresponding to the target sensitivity score, wherein the first scoring threshold is less than the second scoring threshold; generating a feedback signal in response to the target sensitivity score being greater than the second scoring threshold, and reconstructing the time base offset parameter triplet using the feedback signal; executing the next round of iteration operation in response to the target sensitivity score being greater than or equal to the first scoring threshold and less than or equal to the second scoring threshold; and executing a stop iteration operation in response to the target sensitivity score being less than the first scoring threshold.

[0130] In this embodiment, a generation unit obtains a request-response pair consisting of a request message and a response message, and generates an interception event based on the request-response pair. The interception event includes at least a recording phase interception event and a playback phase interception event. An analysis unit parses the response message to obtain multiple dynamic fields and performs static bytecode analysis on the call context metadata in the recording phase interception event to obtain a target reference relationship graph. A construction unit performs causal fingerprint ternary annotation on the multiple dynamic fields based on the target reference relationship graph to generate a causal fingerprint annotation table. Based on the causal fingerprint annotation table, a time base offset parameter triplet between the recording time base and the playback time base is constructed. The recording time base is used to represent the time during the traffic recording process. The baseline and playback time base are used to represent the time base during traffic playback. The correction unit obtains the downstream derived call parameters during traffic playback from the intercepted events in the playback stage, and dynamically corrects the downstream derived call parameters using the parameter rewriting operator based on the causal fingerprint label table and the time base offset parameter triplet to obtain the corrected call stream. The update unit obtains the deviation between the corrected call stream and the recording call stream during traffic recording, and updates the time base offset parameter triplet based on the deviation until the convergence condition is met to realize traffic recording and playback. This achieves the technical effect of improving the fidelity and reliability of traffic recording and playback testing, and solves the technical problem of low fidelity and reliability in traffic recording and playback testing.

[0131] It should be noted that other corresponding descriptions of the functional units involved in the traffic recording and playback device provided in this application embodiment can be found by referring to... Figure 1 The corresponding descriptions in [the document] will not be repeated here.

[0132] This application also provides a computer device, which may specifically be a personal computer, a server, a network device, etc. Figure 5 This application provides a schematic diagram of the device structure of a computer device according to an embodiment of the present application. Figure 5 As shown, the computer device includes a bus, a processor, memory, and a communication interface, and may also include an input / output interface and a display device. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database stores location information. The network interface allows communication with external terminals via a network connection. When the computer program is executed by the processor, it implements the steps in the various method embodiments.

[0133] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0134] In one embodiment, a computer-readable storage medium is provided, which may be non-volatile or volatile, having stored thereon a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0135] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0136] It should be noted that the user personal information involved in the embodiments of this application is all authorized (with the knowledge and consent) by the relevant parties or fully authorized by all parties, and the executing entity can obtain it through various legal and compliant means. The collection, storage, use, processing, transmission, provision, and disclosure of the information, data, and signals involved all comply with the relevant laws and regulations of the relevant countries and regions, and do not violate public order and good morals. It should be noted that if any software tools or components other than those of this company appear in the embodiments of this application, they are merely illustrative examples and do not represent actual use.

[0137] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, graphics processors, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0138] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0139] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for recording and playing back traffic data, characterized in that, The method includes: Obtain a request-response pair consisting of a request message and a response message, and generate an interception event based on the request-response pair, wherein the interception event includes at least: a recording stage interception event and a playback stage interception event; The response message is parsed to obtain multiple dynamic fields, and the call context metadata in the intercepted event during the recording stage is analyzed by static bytecode to obtain the target reference relationship graph. Based on the target reference relationship graph, causal fingerprint ternary annotation is performed on multiple dynamic fields to generate a causal fingerprint annotation table. Based on the causal fingerprint annotation table, a time base offset parameter triplet between the recording time base and the playback time base is constructed. The recording time base is used to represent the time base during the traffic recording process, and the playback time base is used to represent the time base during the traffic playback process. From the intercepted events during the replay phase, the downstream derived call parameters during the traffic replay process are obtained, and based on the causal fingerprint labeling table and the time base offset parameter triplet, the downstream derived call parameters are dynamically corrected using the parameter rewriting operator to obtain the corrected call flow. The deviation between the correction call stream and the recording call stream during the traffic recording process is obtained, and the time base offset parameter triplet is updated based on the deviation until the convergence condition is met, so as to realize traffic recording and playback.

2. The method according to claim 1, characterized in that, Static bytecode analysis is performed on the call context metadata in the intercepted events during the recording phase to obtain the target reference relationship graph, including: Static bytecode analysis is performed on the call context metadata to obtain an initial reference relationship graph with response message fields and intermediate fields derived along the call chain as nodes and the reference relationships between fields as directed edges. The activation frequency of directed edges in the intercepted events during the recording phase is counted to determine the activation weight. Based on the activation weight, the initial reference graph is updated to determine the target reference graph.

3. The method according to claim 1, characterized in that, Based on the target reference relationship graph, causal fingerprint ternary annotations are performed on multiple dynamic fields to generate a causal fingerprint annotation table, including: Obtain the activation weight of the target reference graph, and traverse the target reference graph to determine the set of out-neighbor edges for each dynamic field in the reference graph; Based on the set of out-neighbor edges and the activation weights, a membership function is constructed, and the membership degree of each dynamic field belonging to the downstream derived class, the bystander class, and the composite derived class is calculated using the membership function. The type corresponding to the maximum membership value is selected as the labeling type of the dynamic field, and the confidence level of each dynamic field is determined based on the membership degree of each dynamic field belonging to the downstream derived class, the bystander class, and the composite derived class. The field identifier, label type, and confidence level of each dynamic field are associated and stored to generate the causal fingerprint label table.

4. The method according to claim 1, characterized in that, Based on the causal fingerprint annotation table, a triplet of time base offset parameters between the recording time base and the playback time base is constructed, including: Filter the dynamic fields in the causal fingerprint annotation table whose annotation type is participating in downstream derived classes and whose field type is timestamp; The dynamic fields are assigned to a target time base class according to the field semantics, wherein the target time base class is selected from the wall clock time base class, the monotonic clock time base class, and the logical timing time base class; Obtain the actual value of the offset component of the target time base class between the recording time base and the playback time base, the standard deviation of the Gaussian distribution, the first field value of the target time base class in the interception event during the recording stage, and the second field value in the interception event during the playback stage; and construct a Gaussian model based on the actual value of the offset component, the standard deviation, the first field value, and the second field value. Based on the Gaussian model, the time base offset component is obtained by maximum likelihood estimation. The time base offset component includes at least a first time base offset component, a second time base offset component, and a third time base offset component. The first time base offset component is the offset component corresponding to the target time base class being the wall clock time base class. The second time base offset component is the offset component corresponding to the target time base class being the monotonic clock time base class. The third time base offset component is the offset component corresponding to the target time base class being the logical timing time base class. The time base offset parameter triplet is constructed using the first time base offset component, the second time base offset component, and the third time base offset component.

5. The method according to claim 1, characterized in that, The parameter rewriting operator includes the following formula: in, Used to indicate dynamic fields Apply offset parameters The parameters are then rewritten by the operator; Used to represent the time base offset parameter triplet; Used to represent the first time base offset component; Used to represent the second time base offset component; Used to represent the third time base offset component; Used to represent mapping functions, It is the inverse function of the mapping function; A fingerprint parsing function used to represent a composite derived class. The inversion function used to represent the fingerprint parsing function; Used to represent the dynamic field The corresponding causal fingerprint labeling type; D is used to indicate the downstream derived class; B is used to indicate the bystander class; and C is used to indicate the synthetic derived class. Used to represent the dynamic field The time base type is: w represents the wall clock time base class; m represents the monotonic clock time base class; s represents the logical timing time base class.

6. The method according to claim 1, characterized in that, Obtaining the correction call stream and the deviation between the recording call stream during the traffic recording process includes: Obtain the recording distribution of each of the dynamic fields during the traffic recording process, as well as the playback distribution of the correction call stream; Based on the recording distribution and playback distribution of each dynamic field, the deviation of each dynamic field is calculated using the target divergence algorithm.

7. The method according to claim 1, characterized in that, Based on the deviation, the time base offset parameter triplet is updated until the convergence condition is met to achieve traffic recording and playback, including: Based on the deviation, a target sensitivity score is determined, and a first scoring threshold and a second scoring threshold corresponding to the target sensitivity score are obtained, wherein the first scoring threshold is less than the second scoring threshold. In response to the target sensing score being greater than the second scoring threshold, a feedback signal is generated, and the time base offset parameter triplet is reconstructed using the feedback signal; In response to the target sensing score being greater than or equal to the first scoring threshold and less than or equal to the second scoring threshold, the next iteration operation is executed; In response to the target sensing score being less than the first scoring threshold, a stop iteration operation is performed.

8. A device for recording and playing back traffic data, characterized in that, The device includes: A generation unit is used to obtain a request-response pair consisting of a request message and a response message, and to generate an interception event based on the request-response pair, wherein the interception event includes at least: a recording stage interception event and a playback stage interception event; The analysis unit is used to parse and process the response message to obtain multiple dynamic fields, and to perform static bytecode analysis on the call context metadata in the intercepted event during the recording stage to obtain the target reference relationship graph. The construction unit is used to perform causal fingerprint ternary annotation on multiple dynamic fields based on the target reference relationship graph, generate a causal fingerprint annotation table, and construct a time base offset parameter triplet between the recording time base and the playback time base based on the causal fingerprint annotation table, wherein the recording time base is used to represent the time base during the traffic recording process, and the playback time base is used to represent the time base during the traffic playback process. The correction unit is used to obtain the downstream derived call parameters in the traffic replay process from the intercepted events in the replay stage, and to dynamically correct the downstream derived call parameters based on the causal fingerprint label table and the time base offset parameter triplet using the parameter rewriting operator to obtain the corrected call flow. The update unit is used to obtain the correction call stream and the deviation between the recording call stream in the traffic recording process, and update the time base offset parameter triplet based on the deviation until the convergence condition is met, so as to realize traffic recording and playback.

9. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 7.

10. A computer device, comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method of any one of claims 1 to 7.