Traceless dynamic burying point configuration method and system, electronic device and storage medium
By uniformly configuring the event tracking platform and using dynamic bytecode technology to generate code snippets, the problem of needing to modify code in existing event tracking configuration methods is solved, enabling flexible management and efficient maintenance of seamless event tracking.
Patent Information
- Application Number
- CN202311114878.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-31
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2043-08-31
AI Technical Summary
Existing event tracking configuration methods require code modification and redeployment, resulting in low maintenance efficiency and inflexible adjustments.
The method of seamless dynamic event tracking configuration is adopted. Event tracking information is configured uniformly on the event tracking management platform, and code snippets are generated and injected at runtime using dynamic bytecode technology, so as to achieve flexible management and adjustment of event tracking.
Changes to event tracking can be made without modifying the target code, improving the efficiency and flexibility of event tracking maintenance and reducing the need for code modification and redeployment.
Smart Images

Figure CN117312111B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of electronic information technology, and relates to a method for configuring embedded points, and more particularly to a method, system, electronic device and storage medium for configuring seamless dynamic embedded points. Background Technology
[0002] In daily marketing and operations, statistical analysis of various types of data is involved, such as user behavior and transaction data. Currently, the most typical technology is the use of event tracking, such as Sensors Analytics.
[0003] The main methods of data tracking currently used are as follows:
[0004] (1) The mainstream approach to event tracking is hard-coded: developers insert multiple lines of code into the specific method that needs to trigger the event to report the parameters to be uploaded to the server. The main drawback is that both inserting and modifying event tracking require code modification and re-deployment.
[0005] (2) Configurable event tracking: Event tracking is managed uniformly through configuration. The configuration results are sent to the application, and in the specific method of each triggered event, a unified processing function is called to parse the configuration and determine whether to report the triggered parameters. The advantage is that the modification and switching of event tracking can be done through configuration without involving code modification. The disadvantage is that a lot of pre-implantation work is required for event tracking.
[0006] Dynamic bytecode generation technology refers to a technique that generates bytecode during program execution and loads it into the JVM, thereby achieving dynamic code generation at runtime. Currently, there are two main Java dynamic bytecode technologies: ASM and Javassist. Both support dynamic modification of bytecode at runtime, allowing changes to classes, attributes, and methods.
[0007] In view of this, there is an urgent need to design a new method for configuring event tracking points in order to overcome at least some of the aforementioned defects in existing event tracking point configuration methods. Summary of the Invention
[0008] This invention provides a method, system, electronic device, and storage medium for seamless dynamic event tracking configuration, which can improve the efficiency of event tracking maintenance. No special requirements or preparation are needed for the target code, and event tracking changes can be achieved through configuration without modifying the code or redeploying.
[0009] To solve the above-mentioned technical problems, according to one aspect of the present invention, the following technical solution is adopted:
[0010] A method for configuring seamless dynamic tracking points, the method comprising:
[0011] Step S1: Configure the required tracking information uniformly on the tracking management platform;
[0012] Step S2: Send the data tracking information to the running system to obtain the data tracking reporting parameters and conditions;
[0013] Step S3: Automatically generate code snippets for event reporting based on the event reporting parameters and conditions, and inject them into the target method that triggers the event using dynamic bytecode technology.
[0014] In one embodiment of the present invention, step S1, which involves uniformly configuring the required embedding information, includes:
[0015] A unified configuration of event tracking information is achieved through an event tracking management platform. On the event tracking management platform, users can customize configuration information, including: events to be collected, event parameters, and triggering conditions, and save the above configuration information. When the application starts, the application obtains the above configuration information from the event tracking management platform and loads it into memory. In this way, the application can decide whether to trigger event reporting based on the configuration.
[0016] To ensure the universality of the configuration, a common configuration format is adopted; the configuration is parsed and loaded into the application without relying on a specific event tracking management platform; by using a common configuration format, different event tracking management platforms or tools can share and exchange configuration information, improving the flexibility and portability of the configuration.
[0017] In step S3, the Java code snippet for data tracking and reporting is generated using dynamic bytecode technology; these technologies allow the bytecode of Java classes to be dynamically modified at runtime.
[0018] When generating code snippets, corresponding code logic is generated based on the parameters and conditions reported by the tracking points; string concatenation is used to generate the URL of the reporting request, conditional statements are used to determine whether the triggering conditions are met, and the reporting logic is executed when the conditions are met;
[0019] ASM can be used to directly write bytecode instructions to build code snippets, while Javassist uses an API similar to Java code to generate code snippets; choose a suitable dynamic bytecode library to generate code snippets.
[0020] In one embodiment of the present invention, in step S3, the code snippet for generating the data tracking and reporting is a JAVA code snippet; to improve the readability, flexibility, and extensibility of the code, step S3 includes:
[0021] Template engine steps: Use a template engine to generate code snippets for event tracking; define a code template containing placeholders, where placeholders represent parts that need to be dynamically generated; at runtime, generate the final code snippet by filling in the placeholders in the template; this makes the code structure clear and allows for flexible modification of the template as needed without modifying the logic of the generated code;
[0022] Configuration-driven code generation steps: The configuration information for tracking points is transformed into code generation configuration. A configuration file or data structure can be designed, containing the parameters, conditions, and code snippet generation rules for the tracking points. Based on the configuration file or data structure, code snippets are dynamically generated at runtime; this way, the code generation method can be modified by changing the configuration without needing to change the code generation logic.
[0023] Steps to create a domain-specific language (DSL): Create a simple DSL to describe the configuration and generation rules of the tracking points; translate the DSL into Java code snippets by writing a DSL interpreter or compiler; use a more expressive and readable DSL to describe the tracking points, rather than just writing static code.
[0024] Reflection and annotation steps: Utilize Java's reflection and annotation mechanisms to generate code snippets for event tracking; define a set of annotations to mark the methods, classes, or fields that need to be tracked, and use reflection to obtain annotation information and generate corresponding code snippets; reduce hard coding and manual configuration work, and improve code flexibility;
[0025] The code generation steps based on a rule engine are as follows: A rule engine is used to generate code snippets based on the conditions and rules of the tracking points; a set of rules is defined to describe the conditions under which tracking points should be triggered, and corresponding code generation rules are defined. The rule engine can automatically determine the generated code snippets based on the input tracking point information and rules; the generated code can be adjusted by modifying the rules without modifying the logic of the generated code.
[0026] As one embodiment of the present invention, step S3, which involves embedding dynamic bytecode into the target method of the triggering event, includes:
[0027] Target class loading steps: Dynamic bytecode technology is needed to load the bytecode of the target class so that it can be modified and injected later; the target class can be loaded by using the class loader or class pool provided by the bytecode framework.
[0028] Bytecode modification steps: After the target class's bytecode is loaded, the bytecode can be modified using the APIs provided by the bytecode framework; new instructions are inserted into the instruction sequence of the target method to achieve code implantation;
[0029] Code snippet insertion steps: When modifying bytecode, use the methods provided by the bytecode framework to generate the code snippet to be inserted; this is achieved by constructing instruction sequences, creating new methods, or calling other methods; define the code snippet according to requirements and logic, and insert it into the appropriate position of the target method;
[0030] After modifying the bytecode, the steps are as follows: After the code is injected, the modified bytecode needs to be saved back to the target class; this can be done using the API methods provided by the bytecode framework; after saving the modified bytecode back to the target class, continue loading and using this class.
[0031] The embedded information includes embedded information configuration and instrumentation rule configuration; embedded information configuration is set through an input box, and processing rule configuration is set through a selection box.
[0032] According to another aspect of the present invention, the following technical solution is adopted: a seamless dynamic embedding point configuration system, the seamless dynamic embedding point configuration system comprising:
[0033] The event tracking information configuration module is used to uniformly configure the required event tracking information on the event tracking management platform;
[0034] The module for obtaining the reporting parameters and conditions for data collection points is used to send data collection point information to the running system and obtain the reporting parameters and conditions for data collection points.
[0035] The code snippet generation module is used to automatically generate code snippets for event reporting based on the event reporting parameters and conditions, and to inject them into the target method that triggers the event through dynamic bytecode technology.
[0036] In one embodiment of the present invention, the event tracking information configuration module is used to achieve unified configuration of event tracking information through the event tracking management platform. On the event tracking management platform, users define configuration information, including: events to be collected, event parameters, and triggering condition information, and save the above configuration information. When the application starts, the application obtains the above configuration information from the event tracking management platform and loads it into memory. In this way, the application can decide whether to trigger event reporting based on the configuration.
[0037] To ensure the universality of the configuration, the event tracking information configuration module adopts a common configuration format; the configuration is parsed and loaded into the application without relying on a specific event tracking management platform; by using a common configuration format, different event tracking management platforms or tools can share and exchange configuration information, improving the flexibility and portability of the configuration.
[0038] The code snippet generation module generates Java code snippets for data tracking and reporting using dynamic bytecode technology; these technologies allow for dynamic modification of the bytecode of Java classes at runtime.
[0039] When generating code snippets, the code snippet generation module generates corresponding code logic based on the parameters and conditions reported by the tracking points; it uses string concatenation to generate the URL of the reporting request, uses conditional statements to determine whether the triggering conditions are met, and executes the reporting logic when the conditions are met.
[0040] The code snippet generation module uses ASM to directly write bytecode instructions to construct code snippets, while Javassist uses an API similar to Java code to generate code snippets; a suitable dynamic bytecode library is selected to implement code snippet generation.
[0041] In one embodiment of the present invention, the code snippet generation module generates JAVA code snippets for data tracking and reporting; to improve the readability, flexibility, and extensibility of the code, the code snippet generation module includes:
[0042] The template engine unit is used to generate event tracking code snippets using a template engine; it defines a code template containing placeholders, where placeholders represent the parts that need to be dynamically generated; at runtime, the final code snippet is generated by filling in the placeholders in the template; this makes the code structure clear and allows for flexible modification of the template as needed without modifying the logic of the generated code;
[0043] The configuration-driven code generation unit is used to transform the configuration information of the tracking points into code generation configurations. A configuration file or data structure can be designed, containing the parameters, conditions, and code snippet generation rules for the tracking points. Based on the configuration file or data structure, code snippets are dynamically generated at runtime; this allows modification of the code generation method by changing the configuration, without needing to modify the code generation logic.
[0044] The Domain-Specific Language (DSL) creation unit is used to create a simple DSL to describe the configuration and generation rules of tracking points; by writing a DSL interpreter or compiler, the DSL is transformed into Java code snippets; using a more expressive and readable DSL to describe tracking points, rather than just writing static code;
[0045] The reflection and annotation unit is used to generate code snippets for event tracking using Java's reflection and annotation mechanisms. It defines a set of annotations to mark methods, classes, or fields that need to be tracked, and uses reflection to obtain annotation information and generate corresponding code snippets. This reduces hard coding and manual configuration work and improves code flexibility.
[0046] The rule-based code generation unit is used to generate code snippets based on the conditions and rules of the tracking points. It defines a set of rules describing the conditions under which tracking points should be triggered, and defines the corresponding code generation rules. The rule engine can automatically determine the generated code snippets based on the input tracking point information and rules; the generated code can be adjusted by modifying the rules without changing the logic of the generated code.
[0047] In one embodiment of the present invention, the code snippet generation module includes:
[0048] The target class loading unit is used to load the bytecode of the target class that requires dynamic bytecode technology for subsequent modification and injection operations; it is implemented by using the class loader or class pool provided by the bytecode framework to load the target class.
[0049] The bytecode modification unit is used to modify the bytecode after the target class's bytecode is loaded, using the APIs provided by the bytecode framework; it inserts new instructions into the instruction sequence of the target method to achieve code implantation.
[0050] The code snippet insertion unit is used to generate the code snippets to be inserted when modifying bytecode, using methods provided by the bytecode framework. This is achieved by constructing instruction sequences, creating new methods, or calling other methods. The code snippets are defined according to requirements and logic, and then inserted into the appropriate position of the target method.
[0051] The modified bytecode unit is used to complete the code injection and then saves the modified bytecode back to the target class. This is achieved through the API methods provided by the bytecode framework. After saving the modified bytecode back to the target class, the class can continue to be loaded and used.
[0052] The embedded information includes embedded information configuration and instrumentation rule configuration; embedded information configuration is set through an input box, and processing rule configuration is set through a selection box.
[0053] According to another aspect of the present invention, the following technical solution is adopted: an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above method.
[0054] According to another aspect of the present invention, the following technical solution is adopted: a storage medium storing computer program instructions thereon, which, when executed by a processor, implement the steps of the above-described method.
[0055] The beneficial effects of the present invention are as follows: The seamless dynamic event tracking configuration method, system, electronic device and storage medium proposed in the present invention can improve the efficiency of event tracking maintenance. No special requirements or preparation are required for the target code. Event tracking changes can be achieved through configuration without modifying the code or redeploying. Attached Figure Description
[0056] Figure 1 This is a flowchart of a method for configuring seamless dynamic embedding points in one embodiment of the present invention.
[0057] Figure 2 This is a schematic diagram of the composition of a seamless dynamic embedding point configuration system in one embodiment of the present invention.
[0058] Figure 3 This is a schematic diagram of the composition of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0059] The preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0060] To further understand the present invention, preferred embodiments of the present invention are described below in conjunction with examples. However, it should be understood that these descriptions are only for further illustrating the features and advantages of the present invention, and not for limiting the scope of the claims of the present invention.
[0061] The description in this section pertains to only a few typical embodiments, and the present invention is not limited to the scope of the embodiments described. Substitution of identical or similar prior art methods with some technical features in the embodiments is also within the scope of the description and protection of this invention.
[0062] The steps described in the various embodiments in the specification are for illustrative purposes only, and the implementation of this application is not limited by the order of the steps.
[0063] The term "connection" in the instruction manual includes both direct and indirect connections.
[0064] This invention discloses a method for configuring seamless dynamic embedding points. Figure 1 This is a flowchart of a seamless dynamic embedding point configuration method in one embodiment of the present invention; please refer to [link / reference]. Figure 1 The seamless dynamic embedding configuration method includes:
[0065]
Step S1
[0066]
Step S2
[0067]
Step S3
[0068] In one embodiment of the present invention, step S1, which involves uniformly configuring the required embedding information, includes:
[0069] A unified configuration of event tracking information is achieved through an event tracking management platform. On the event tracking management platform, users can customize configuration information, including: events to be collected, event parameters, trigger conditions, etc., and save the above configuration information to a database or other storage medium. When the application starts, the application obtains the above configuration information from the event tracking management platform and loads it into memory. In this way, the application can decide whether to trigger event reporting based on the configuration.
[0070] To ensure the configuration is universal, a common configuration format, such as JSON or XML, is used. This allows the configuration to be parsed and loaded into the application without relying on a specific event tracking platform. By using a common configuration format, different event tracking platforms or tools can share and exchange configuration information, improving configuration flexibility and portability.
[0071] In step S3, the Java code snippet for data tracking and reporting is generated using dynamic bytecode technology (such as ASM or Javassist); these technologies allow the bytecode of Java classes to be dynamically modified at runtime.
[0072] When generating code snippets, corresponding code logic is generated based on the parameters and conditions reported by the tracking points. For example, string concatenation can be used to generate the URL of the reporting request, conditional statements can be used to determine whether the triggering conditions are met, and the reporting logic can be executed when the conditions are met.
[0073] The specific generation method can be implemented based on the dynamic bytecode technology used; for example, using ASM (a general Java bytecode manipulation and analysis framework) to directly write bytecode instructions to build code snippets, or using Javassist or an API similar to Java code to generate code snippets; depending on the specific needs and technology selection, a suitable dynamic bytecode library can be chosen to generate code snippets.
[0074] In one embodiment of the present invention, in step S3, the code snippet for generating the data tracking and reporting is a JAVA code snippet; to improve the readability, flexibility, and extensibility of the code, step S3 includes:
[0075] Template engine steps: Use a template engine to generate code snippets for event tracking; define a code template containing placeholders, where placeholders represent parts that need to be dynamically generated; at runtime, generate the final code snippet by filling in the placeholders in the template; this method can make the code structure clear and allows for flexible modification of the template as needed without modifying the logic of generating the code;
[0076] Configuration-driven code generation steps: The configuration information for tracking points is transformed into code generation configuration. A configuration file or data structure can be designed, containing the parameters, conditions, and code snippet generation rules for the tracking points. Based on the configuration file or data structure, code snippets are dynamically generated at runtime; this way, the code generation method can be modified by changing the configuration without needing to change the code generation logic.
[0077] Steps to create a Domain-Specific Language (DSL): Create a simple DSL to describe the configuration and generation rules for tracking points; Transform the DSL into Java code snippets by writing a DSL interpreter or compiler; In this way, you can use a more expressive and readable DSL to describe tracking points, instead of just writing static code.
[0078] Reflection and annotation steps: Use Java's reflection and annotation mechanisms to generate code snippets for event tracking; define a set of annotations to mark the methods, classes, or fields that need to be tracked, and use reflection to obtain the annotation information and generate the corresponding code snippets; this approach can reduce hard coding and manual configuration work and improve code flexibility.
[0079] The code generation steps based on a rule engine are as follows: A rule engine is used to generate code snippets based on the conditions and rules of the tracking points; a set of rules is defined to describe the conditions under which tracking points should be triggered, and corresponding code generation rules are defined. The rule engine can automatically determine the generated code snippets based on the input tracking point information and rules; the generated code can be adjusted by modifying the rules without modifying the logic of the generated code.
[0080] In one embodiment, step S3, which involves embedding dynamic bytecode into the target method that triggers the event, includes:
[0081] Target class loading steps: Dynamic bytecode technology is needed to load the bytecode of the target class so that it can be modified and injected later; this can be achieved by using the class loader or class pool provided by a bytecode framework (such as ASM or Javassist);
[0082] Bytecode modification steps: After the target class's bytecode is loaded, the bytecode can be modified using APIs provided by the bytecode framework, such as ASM's ClassVisitor or Javassist's CtClass; new instructions are inserted into the instruction sequence of the target method to achieve code implantation;
[0083] Code snippet insertion steps: When modifying bytecode, use the methods provided by the bytecode framework to generate the code snippet to be inserted; this can be achieved by constructing instruction sequences, creating new methods, calling other methods, etc.; define the code snippet according to requirements and logic, and insert it into the appropriate position of the target method;
[0084] After modifying the bytecode, the steps are as follows: After the code is injected, the modified bytecode needs to be saved back to the target class. This can be done using APIs provided by the bytecode framework, such as ASM's ClassWriter or Javassist's CtClass#toBytecode() method. After saving the modified bytecode back to the target class, the class can be loaded and used.
[0085] The tracking information includes tracking information configuration and instrumentation rule configuration. Tracking information configuration is set through input boxes, such as eventType, scenType, message, and info tracking information. Processing rule configuration is configured through selection boxes, such as global configuration, replacement, removal, and insertion.
[0086] This invention further discloses a seamless dynamic embedding point configuration system. Figure 2 This is a schematic diagram of the composition of a seamless dynamic embedding point configuration system according to an embodiment of the present invention; please refer to [link / reference]. Figure 2 The seamless dynamic tracking configuration system includes: tracking information configuration module 1, tracking reporting parameters and conditions acquisition module 2, and code snippet generation module 3.
[0087] The event tracking information configuration module 1 is used to uniformly configure the required event tracking information on the event tracking management platform; the event tracking reporting parameter and condition acquisition module 2 is used to send the event tracking information to the running system and acquire the event tracking reporting parameters and conditions; the code snippet generation module 3 is used to automatically generate JAVA code snippets for event tracking based on the event tracking reporting parameters and conditions, and to embed them into the target method that triggers the event through dynamic bytecode technology.
[0088] The event tracking information configuration module 1 is used to achieve unified configuration of event tracking information through the event tracking management platform. On the event tracking management platform, users define configuration information, including: events to be collected, event parameters, trigger conditions, etc., and save this configuration information to a database or other storage medium. When the application starts, the application retrieves the configuration information from the event tracking management platform and loads it into memory. Thus, the application can decide whether to trigger event reporting based on the configuration. To ensure the configuration is universal, the event tracking information configuration module 1 adopts a common configuration format, such as JSON or XML. This allows the configuration to be parsed and loaded into the application without relying on a specific event tracking management platform. By using a common configuration format, different event tracking management platforms or tools can share and exchange configuration information, improving the flexibility and portability of the configuration.
[0089] The code snippet generation module 3 generates Java code snippets for data tracking and reporting by using dynamic bytecode technology (such as ASM or Javassist); these technologies allow dynamic modification of the bytecode of Java classes at runtime.
[0090] The code snippet generation module 3 generates corresponding code logic based on the parameters and conditions reported by the tracking points when generating code snippets. For example, it can use string concatenation to generate the URL of the reporting request, use conditional statements to determine whether the triggering conditions are met, and execute the reporting logic when the conditions are met. The specific generation method can be implemented based on the dynamic bytecode technology used. For example, the code snippet generation module can use ASM to directly write bytecode instructions to construct code snippets, or use Javassist to generate code snippets using an API similar to Java code. Depending on the specific needs and technology selection, a suitable dynamic bytecode library is chosen to generate the code snippets.
[0091] The code snippet generation module 3 generates JAVA code snippets for tracking point reporting. To improve the readability, flexibility and extensibility of the code, the code snippet generation module may include: a template engine unit, a configuration-driven code generation unit, a domain-specific language creation unit, a reflection and annotation unit, and a rule engine-based code generation unit.
[0092] The template engine unit is used to generate code snippets for event tracking using a template engine; it defines a code template containing placeholders, where the placeholders represent the parts that need to be dynamically generated; at runtime, the final code snippet is generated by filling in the placeholders in the template; this approach can make the code structure clear and allow for flexible modification of the template as needed without modifying the logic of generating the code;
[0093] The configuration-driven code generation unit is used to convert the configuration information of the tracking points into code generation configuration. A configuration file or data structure can be designed, which contains the parameters, conditions, and code snippet generation rules for the tracking points. Based on the configuration file or data structure, code snippets are dynamically generated at runtime; in this way, the code generation method can be modified by changing the configuration without modifying the code generation logic.
[0094] The Domain-Specific Language (DSL) creation unit is used to create a simple domain-specific language to describe the configuration and generation rules of tracking points. By writing a domain-specific language interpreter or compiler, the DSL is transformed into Java code snippets. In this way, tracking points can be described using a more expressive and readable DSL, rather than just writing static code.
[0095] The reflection and annotation unit is used to generate code snippets for event tracking using Java's reflection and annotation mechanisms. A set of annotations is defined to mark the methods, classes, or fields that need to be tracked, and the annotation information is obtained through reflection to generate the corresponding code snippets. This approach can reduce hard coding and manual configuration work and improve code flexibility.
[0096] The rule-based code generation unit uses a rule engine to generate code snippets based on the conditions and rules of the tracking points. It defines a set of rules describing the conditions under which tracking points should be triggered and defines corresponding code generation rules. The rule engine can automatically determine the generated code snippets based on the input tracking point information and rules; the generated code can be adjusted by modifying the rules without needing to modify the logic of the generated code.
[0097] In one embodiment of the present invention, the code fragment generation module 3 includes: a target class loading unit, a bytecode modification unit, a code fragment insertion unit, and a modified bytecode unit.
[0098] The target class loading unit is used to load the bytecode of the target class that requires dynamic bytecode technology for subsequent modification and injection operations; the loading of the target class can be achieved by using the class loader or class pool provided by the bytecode framework (such as ASM or Javassist);
[0099] The bytecode modification unit is used to modify the bytecode after the target class's bytecode is loaded, using APIs provided by the bytecode framework, such as ASM's ClassVisitor or Javassist's CtClass; to insert new instructions into the instruction sequence of the target method to achieve code implantation.
[0100] The code snippet insertion unit is used to generate the code snippet to be inserted when modifying bytecode using methods provided by the bytecode framework; it can be implemented by constructing instruction sequences, creating new methods, calling other methods, etc.; the code snippet is defined according to requirements and logic, and inserted into the appropriate position of the target method;
[0101] The modified bytecode unit is used to save the modified bytecode back to the target class after the code is injected; this can be achieved through APIs provided by the bytecode framework, such as ASM's ClassWriter or Javassist's CtClass#toBytecode() method; after saving the modified bytecode back to the target class, the class can continue to be loaded and used;
[0102] The tracking information includes tracking information configuration and instrumentation rule configuration. Tracking information configuration is set through input boxes, such as eventType, scenType, message, and info tracking information. Processing rule configuration is configured through selection boxes, such as global configuration, replacement, removal, and insertion.
[0103] In one embodiment of the present invention, the seamless dynamic embedding configuration system may further include the following modules:
[0104] Basic parameter configuration module: Configure the basic information of the event tracking points in the event tracking management platform. The basic information includes event tracking information configuration and instrumentation rule configuration. Event tracking information configuration is set through input boxes, such as eventType, scenType, message, info, etc. Processing rule configuration is configured through selection boxes, such as global configuration, replacement, removal, insertion, etc.
[0105] Basic configuration parsing module: used to parse the basic parameter configuration module and obtain the basic information of the embedded points and the instrumentation rules;
[0106] Interface module: Used to provide a list of interfaces, find a specified interface, and obtain the class to be instrumented;
[0107] Execution module: Used to process the class to be instrumented according to the instrumentation processing rules, so as to realize the bytecode instrumentation requirements of the embedded points.
[0108] Monitoring module: Used to monitor whether the data tracking requirements are effective.
[0109] Feedback module: When there are anomalies in the tracking data generated by bytecode instrumentation, the removal operation can be quickly implemented. Once the tracking monitoring is stable, global configuration and enhanced operations can be performed.
[0110] This invention also discloses an electronic device, Figure 3This is a schematic diagram of the composition of an electronic device according to an embodiment of the present invention; please refer to [link / reference]. Figure 3 At the hardware level, the electronic device includes a memory, a processor, and at least one network interface; the processor may be a microprocessor, and the memory may include main memory, such as random access memory (RAM) or non-volatile memory. Of course, the electronic device may also include other hardware as needed.
[0111] The processor, network interface, and memory are interconnected via an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. The bus may include an address bus, a data bus, a control bus, etc. The memory stores programs (including operating system programs and application programs); the programs may include program code, which may include computer operation instructions. The memory may include main memory and non-volatile memory, and provides instructions and data to the processor.
[0112] In one embodiment, the processor can read the corresponding program from non-volatile memory into memory and then run it; the processor can execute the program stored in memory and specifically perform the following operations (e.g. Figure 1 As shown):
[0113]
Step S1
[0114]
Step S2
[0115]
Step S3
[0116] This invention further discloses a storage medium storing computer program instructions, which, when executed by a processor, implement the following steps of the method of this invention (e.g. Figure 1 As shown):
[0117]
Step S1
[0118]
Step S2
[0119]
Step S3
[0120] In summary, the seamless dynamic event tracking configuration method, system, electronic device, and storage medium proposed in this invention can improve the efficiency of event tracking maintenance. No special requirements or preparations are needed for the target code, and event tracking changes can be achieved through configuration without modifying the code or redeploying.
[0121] It should be noted that this application can be implemented in software and / or a combination of software and hardware; for example, it can be implemented using an application-specific integrated circuit (ASIC), a general-purpose computer, or any other similar hardware device. In some embodiments, the software program of this application can be executed by a processor to implement the steps or functions described above. Similarly, the software program of this application (including related data structures) can be stored in a computer-readable recording medium; for example, RAM memory, magnetic or optical drives, floppy disks, and similar devices. In addition, some steps or functions of this application can be implemented in hardware; for example, as circuitry that cooperates with a processor to perform the various steps or functions.
[0122] 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.
[0123] The description and application of the present invention herein are illustrative and not intended to limit the scope of the invention to the embodiments described above. Effects or advantages involved in the embodiments may not be apparent due to various factors, and the description of effects or advantages is not intended to limit the embodiments. Variations and modifications of the embodiments disclosed herein are possible, and various substitutions and equivalents of the components in the embodiments are well known to those skilled in the art. It should be apparent to those skilled in the art that the invention can be implemented in other forms, structures, arrangements, proportions, and with other components, materials, and parts without departing from the spirit or essential characteristics of the invention. Other variations and modifications can be made to the embodiments disclosed herein without departing from the scope and spirit of the invention.
Claims
1. A method for configuring seamless dynamic embedding points, characterized in that, The seamless dynamic embedding point configuration method includes: Step S1: Configure the required tracking information uniformly on the tracking management platform; Step S2: Send the data tracking information to the running system to obtain the data tracking reporting parameters and conditions; Step S3: Automatically generate code snippets for event reporting based on the event reporting parameters and conditions, and inject them into the target method that triggers the event using dynamic bytecode technology; In step S1, the steps for uniformly configuring the required tracking information include: A unified configuration of event tracking information is achieved through an event tracking management platform. On the event tracking management platform, users can customize configuration information, including: events to be collected, event parameters, and triggering conditions, and save the above configuration information. When the application starts, the application obtains the above configuration information from the event tracking management platform and loads it into memory. In this way, the application can decide whether to trigger event reporting based on the configuration. By using a common configuration format, configuration information can be shared and exchanged between different event tracking management platforms or tools, thereby improving the flexibility and portability of configuration. In step S3, the Java code snippet for data tracking and reporting is generated using dynamic bytecode technology; these technologies allow the bytecode of Java classes to be dynamically modified at runtime. When generating code snippets, corresponding code logic is generated based on the parameters and conditions reported by the tracking points; string concatenation is used to generate the URL of the reporting request, conditional statements are used to determine whether the triggering conditions are met, and the reporting logic is executed when the conditions are met; Use ASM to directly write bytecode instructions to build code snippets or use Javassist to generate code snippets.
2. The seamless dynamic embedding point configuration method according to claim 1, characterized in that: In step S3, the code snippet for generating the event tracking report is a Java code snippet; to improve the readability, flexibility, and extensibility of the code, step S3 includes one of the following steps: Template engine steps: Use a template engine to generate code snippets for event tracking; define a code template containing placeholders, where placeholders represent parts that need to be dynamically generated; at runtime, generate the final code snippet by filling in the placeholders in the template; It makes the code structure clear and allows for flexible modification of the template as needed without requiring changes to the generated code logic; Configuration-driven code generation steps: Transform the configuration information of the tracking points into the configuration for code generation; Design a configuration file or data structure that contains the parameters, conditions, and code snippet generation rules for the tracking points; Dynamically generate code snippets at runtime based on the configuration file or data structure; Modify the code generation method by changing the configuration without changing the code generation logic. Domain-Specific Language (DSL) creation steps: Create and define a domain-specific language to describe the configuration and generation rules of the tracking points; Transform the DSL into Java code snippets by writing a domain-specific language interpreter or compiler; Use DSL to describe the embedded points; Reflection and annotation steps: Use Java's reflection and annotation mechanisms to generate code snippets for event tracking; define a set of annotations to mark the methods, classes, or fields that need to be tracked, and use reflection to obtain the annotation information and generate the corresponding code snippets; Code generation steps based on a rule engine: Use a rule engine to generate code snippets based on the conditions and rules of the tracking points; Define a set of rules to describe the conditions that need to trigger the tracking points, and define the corresponding code generation rules; the rule engine automatically determines the generated code snippets based on the input tracking point information and rules; the generated code can be adjusted by modifying the rules, without needing to modify the logic of the generated code.
3. The seamless dynamic embedding point configuration method according to claim 1, characterized in that: Step S3, which involves injecting dynamic bytecode into the target method that triggers the event, includes the following steps: Target class loading steps: Use dynamic bytecode technology to load the bytecode of the target class so that it can be modified and injected later; use the class loader or class pool provided by the bytecode framework to load the target class; Bytecode modification steps: After the target class's bytecode is loaded, use the API provided by the bytecode framework to modify the bytecode; insert new instructions into the instruction sequence of the target method to achieve code implantation; Code snippet insertion steps: When modifying bytecode, use the methods provided by the bytecode framework to generate the code snippets that need to be inserted; define the code snippets according to requirements and logic, and insert them into the appropriate positions of the target method; Modified bytecode steps: After code injection, save the modified bytecode back to the target class; implement this through the API methods provided by the bytecode framework; after saving the modified bytecode back to the target class, continue loading and using this class; The embedded information includes embedded information configuration and insertion rule configuration; embedded information configuration is set through an input box, and insertion rule configuration is set through a selection box.
4. A seamless dynamic embedding configuration system, characterized in that, The seamless dynamic embedding configuration system includes: The event tracking information configuration module is used to uniformly configure the required event tracking information on the event tracking management platform; The module for obtaining the reporting parameters and conditions for data collection points is used to send data collection point information to the running system and obtain the reporting parameters and conditions for data collection points. The code snippet generation module is used to automatically generate code snippets for event reporting based on the event reporting parameters and conditions, and to inject them into the target method that triggers the event through dynamic bytecode technology. The event tracking information configuration module is used to achieve unified configuration of event tracking information through the event tracking management platform. On the event tracking management platform, users can customize configuration information, including: events to be collected, event parameters, and triggering condition information, and save the above configuration information. When the application starts, the application obtains the above configuration information from the event tracking management platform and loads it into memory. In this way, the application can decide whether to trigger event reporting based on the configuration. By using a common configuration format, configuration information can be shared and exchanged between different event tracking management platforms or tools, thereby improving the flexibility and portability of configuration. The code snippet generation module generates Java code snippets for data tracking and reporting using dynamic bytecode technology; these technologies allow for dynamic modification of the bytecode of Java classes at runtime. When generating code snippets, the code snippet generation module generates corresponding code logic based on the parameters and conditions reported by the tracking points; it uses string concatenation to generate the URL of the reporting request, uses conditional statements to determine whether the triggering conditions are met, and executes the reporting logic when the conditions are met. The code snippet generation module uses ASM to directly write bytecode instructions to construct code snippets or uses Javassist to generate code snippets.
5. The seamless dynamic embedding configuration system according to claim 4, characterized in that: The code snippet generation module generates JAVA code snippets for data tracking and reporting. To improve code readability, flexibility, and extensibility, the code snippet generation module includes one of the following units: The template engine unit is used to generate code snippets for event tracking using a template engine; it defines a code template containing placeholders, where the placeholders represent the parts that need to be dynamically generated; at runtime, the final code snippet is generated by filling in the placeholders in the template; It makes the code structure clear and allows for flexible modification of the template as needed without requiring changes to the generated code logic; Configure the driver code generation unit to convert the configuration information of the tracking points into the configuration of code generation; Design a configuration file or data structure that contains the parameters, conditions, and code snippet generation rules for the tracking points; dynamically generate code snippets at runtime based on the configuration file or data structure; modify the code generation method by changing the configuration. Domain-Specific Language (DSL) creation unit is used to create and define a domain-specific language to describe the configuration and generation rules of the tracking points; by writing a domain-specific language interpreter or compiler, the DSL is converted into Java code snippets; Use DSL to describe the embedded points; The reflection and annotation unit is used to generate code snippets for event tracking using Java's reflection and annotation mechanisms. Define a set of annotations to mark the methods, classes or fields that need to be tracked, and use reflection to obtain the annotation information and generate the corresponding code snippets; The code generation unit based on the rule engine is used to generate code snippets based on the conditions and rules of the tracking points using the rule engine; Define a set of rules to describe the conditions that need to trigger the tracking points, and define the corresponding code generation rules; the rule engine automatically determines the generated code snippets based on the input tracking point information and rules; the generated code can be adjusted by modifying the rules, without needing to modify the logic of the generated code.
6. The seamless dynamic embedding configuration system according to claim 4, characterized in that: The code snippet generation module includes: The target class loading unit is used to load the bytecode of the target class using dynamic bytecode technology, so that it can be modified and injected later; it loads the target class by using the class loader or class pool provided by the bytecode framework. The bytecode modification unit is used to modify the bytecode after the target class's bytecode is loaded, using the API provided by the bytecode framework; it inserts new instructions into the instruction sequence of the target method to achieve code implantation. The code snippet insertion unit is used to generate the code snippets to be inserted when modifying bytecode, using methods provided by the bytecode framework; it defines the code snippets according to requirements and logic, and inserts them into the appropriate positions of the target method; The modified bytecode unit is used to complete the code injection and then saves the modified bytecode back to the target class. This is achieved through the API methods provided by the bytecode framework. After saving the modified bytecode back to the target class, the class can continue to be loaded and used. The embedded information includes embedded information configuration and insertion rule configuration; embedded information configuration is set through an input box, and insertion rule configuration is set through a selection box.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 3.
8. A storage medium storing computer program instructions thereon, characterized in that, When executed by a processor, the computer program instructions implement the steps of the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
A method and apparatus for dynamic point burying
CN112433921A
Method and device for automatically burying points
WO2017084508A1
