[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN115328801A - Database access log generation method, device, storage medium and computer device - Google Patents

Database access log generation method, device, storage medium and computer device Download PDF

Info

Publication number
CN115328801A
CN115328801A CN202211054139.5A CN202211054139A CN115328801A CN 115328801 A CN115328801 A CN 115328801A CN 202211054139 A CN202211054139 A CN 202211054139A CN 115328801 A CN115328801 A CN 115328801A
Authority
CN
China
Prior art keywords
function
instruction information
database access
instruction
interface
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211054139.5A
Other languages
Chinese (zh)
Inventor
张友璇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Pinwei Software Co Ltd
Original Assignee
Guangzhou Pinwei Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Pinwei Software Co Ltd filed Critical Guangzhou Pinwei Software Co Ltd
Priority to CN202211054139.5A priority Critical patent/CN115328801A/en
Publication of CN115328801A publication Critical patent/CN115328801A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/362Debugging of software
    • G06F11/3636Debugging of software by tracing the execution of the program
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/362Debugging of software
    • G06F11/3644Debugging of software by instrumenting at runtime
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3696Methods or tools to render software testable

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application provides a database access log generation method, a database access log generation device, a storage medium and computer equipment, which are used for acquiring instruction information returned by an instruction information acquisition function and a call stack corresponding to the instruction information acquisition function in the call process under the condition that an application to be tested calls the instruction information acquisition function. For the call stack, the method and the device can match function information of call functions at all levels in the call stack in sequence according to the direction from the stack top to the stack bottom so as to determine the interface name of a target interface for sending the database access instruction corresponding to the instruction information. And generating log information of the instruction information acquisition function in local call after obtaining the interface name and the instruction information, and writing the log information into a database access log of the application to be tested to obtain a complete database access log of the application to be tested in the execution process, so that the data problem can be checked based on the database access log to accelerate the checking efficiency.

Description

数据库访问日志生成方法、装置、存储介质及计算机设备Database access log generation method, device, storage medium and computer equipment

技术领域technical field

本申请涉及数据库技术领域,尤其涉及一种数据库访问日志生成方法、装置、存储介质及计算机设备。The present application relates to the technical field of databases, in particular to a database access log generation method, device, storage medium and computer equipment.

背景技术Background technique

为降低本地存储的数据量,一般会将部分数据存储于数据库中,应用可从数据库中读取数据或者将数据写入至数据库中,以根据所获取的数据进行处理或者更新数据库中的数据。在此过程中,数据的读取情况以及数据的写入情况都有可能影响应用的执行。因此,为确保应用在正式上线之后能够正常运行,在上线前需要对应用进行测试。测试时,若应用执行出现数据问题,则需要对导致该数据问题的原因进行排查。但是,考虑到多方面的因素都可能会导致数据问题,目前在进行排查时存在排查效率低的问题。In order to reduce the amount of data stored locally, some data is generally stored in a database, and the application can read data from the database or write data to the database, so as to process or update data in the database according to the acquired data. During this process, both the reading of data and the writing of data may affect the execution of the application. Therefore, in order to ensure that the application can run normally after it is officially launched, it is necessary to test the application before going online. During the test, if there is a data problem in the execution of the application, you need to troubleshoot the cause of the data problem. However, considering that various factors may cause data problems, there is a problem of low efficiency in the current investigation.

发明内容Contents of the invention

本申请的目的旨在至少能解决上述的技术缺陷之一,特别是现有技术中排查效率低的技术缺陷。The purpose of this application is to at least solve one of the above-mentioned technical defects, especially the technical defect of low troubleshooting efficiency in the prior art.

第一方面,本申请实施例提供了一种数据库访问日志生成方法,所述方法包括:In the first aspect, the embodiment of the present application provides a method for generating a database access log, the method comprising:

在监听到待测试应用调用指令信息获取函数的情况下,获取所述指令信息获取函数所返回的指令信息,以及获取所述指令信息获取函数在本次调用中所对应的调用栈;所述指令信息获取函数用于获取数据库访问指令的指令信息;Obtain the instruction information returned by the instruction information acquisition function and obtain the call stack corresponding to the instruction information acquisition function in this call when the application to be tested is monitored to call the instruction information acquisition function; the instruction The information acquisition function is used to acquire the instruction information of the database access instruction;

按照从栈顶到栈底的方向,依次对所述调用栈中各级调用函数的函数信息进行匹配,以确定目标接口的接口名称;所述目标接口为发送与所述指令信息相对应的数据库访问指令的接口函数;According to the direction from the top of the stack to the bottom of the stack, the function information of the call function at each level in the call stack is matched in turn to determine the interface name of the target interface; the target interface is to send a database corresponding to the instruction information Interface functions for accessing instructions;

根据所述指令信息及所述目标接口的接口名称生成所述指令信息获取函数在本次调用中的日志信息,并将所述日志信息写入所述待测试应用的数据库访问日志中。Generate log information in this call of the instruction information acquisition function according to the instruction information and the interface name of the target interface, and write the log information into the database access log of the application to be tested.

在其中一个实施例中,所述按照从栈顶到栈底的方向,依次对所述调用栈中各级调用函数的函数信息进行匹配,以确定目标接口的接口名称的步骤,包括:In one of the embodiments, the step of sequentially matching the function information of the calling functions at all levels in the call stack in the direction from the top of the stack to the bottom of the stack to determine the interface name of the target interface includes:

按照从栈顶到栈底的方向,依次将各级调用函数的函数信息作为当前待匹配函数信息,直至所述当前待匹配函数信息所包括的类名存在预设的关键字段,并将所述当前待匹配函数信息作为目标函数信息;According to the direction from the top of the stack to the bottom of the stack, the function information of the calling functions at all levels is used as the current function information to be matched, until the class name included in the current function information to be matched has a preset key field, and the Describe the current function information to be matched as the target function information;

根据所述目标函数信息所包括的类名和函数名,确定所述目标接口的接口名称。The interface name of the target interface is determined according to the class name and function name included in the target function information.

在其中一个实施例中,所述根据所述指令信息及所述目标接口的接口名称生成所述指令信息获取函数在本次调用中的日志信息的步骤,包括:In one of the embodiments, the step of generating the log information of the instruction information acquisition function in this call according to the instruction information and the interface name of the target interface includes:

按照预设的数据库访问指令格式对所述指令信息进行组装,以得到目标数据库访问指令;所述目标数据库访问指令为与所述指令信息相对应的数据库访问指令;Assembling the instruction information according to a preset database access instruction format to obtain a target database access instruction; the target database access instruction is a database access instruction corresponding to the instruction information;

基于所述目标数据库访问指令及所述目标接口的接口名称生成所述指令信息获取函数在本次调用中的日志信息,以使所述日志信息包括所述目标数据库访问指令及所述接口名称。Generate log information of the instruction information acquisition function in this call based on the target database access instruction and the interface name of the target interface, so that the log information includes the target database access instruction and the interface name.

在其中一个实施例中,基于所述目标数据库访问指令及所述目标接口的接口名称生成所述指令信息获取函数在本次调用中的日志信息,以使所述日志信息包括所述目标数据库访问指令及所述接口名称的步骤,包括:In one of the embodiments, based on the target database access command and the interface name of the target interface, the log information of the instruction information acquisition function in this call is generated, so that the log information includes the target database access The steps of the instruction and the name of the interface include:

从所述指令信息中提取所述目标数据库访问指令中的操作标签,并根据所述操作标签确定所述目标接口的读写属性;Extracting the operation label in the target database access instruction from the instruction information, and determining the read-write attribute of the target interface according to the operation label;

基于所述目标数据库访问指令、所述目标接口的接口名称和所述目标接口的读写属性生成所述指令信息获取函数在本次调用中的日志信息,以使所述日志信息包括所述目标数据库访问指令、所述接口名称及所述读写属性。Generate log information of the command information acquisition function in this call based on the target database access command, the interface name of the target interface, and the read-write attribute of the target interface, so that the log information includes the target Database access instruction, the interface name and the read-write attribute.

在其中一个实施例中,所述根据所述操作标签确定所述目标接口的读写属性的步骤,包括:In one of the embodiments, the step of determining the read-write attribute of the target interface according to the operation tag includes:

若所述操作标签为选择标签,则确定所述目标接口的读写属性为读属性;If the operation tag is a selection tag, then determine that the read-write attribute of the target interface is a read attribute;

若所述操作标签为插入标签、更新标签或者删除标签,则确定所述目标接口的读写属性为写属性。If the operation tag is an insert tag, an update tag, or a delete tag, it is determined that the read-write attribute of the target interface is a write attribute.

在其中一个实施例中,所述在监听到待测试应用调用指令信息获取函数的情况下,获取所述指令信息获取函数所返回的指令信息,以及获取所述指令信息获取函数在本次调用中所对应的调用栈的步骤之前,还包括:In one of the embodiments, when it is detected that the application under test calls the instruction information acquisition function, the instruction information returned by the instruction information acquisition function is obtained, and the instruction information acquisition function is obtained in this call Before the steps of the corresponding call stack, it also includes:

利用程序插桩技术在所述待测试应用中插入测试函数,以通过所述测试函数监听所述待测试应用是否调用所述指令信息获取函数。A test function is inserted into the application under test by using a program insertion technology, so as to monitor whether the application under test calls the instruction information acquisition function through the test function.

在其中一个实施例中,所述利用程序插桩技术在所述待测试应用中插入测试函数的步骤,包括:In one of the embodiments, the step of inserting a test function into the application under test by using the program insertion technology includes:

利用程序插桩技术在所述待测试应用的指定位置处插入所述测试函数,所述指定位置为使得所述测试函数与所述指令信息获取函数在同一线程中运行的位置。Inserting the test function at a specified location of the application to be tested by using a program insertion technique, the specified location is a location where the test function and the instruction information acquisition function run in the same thread.

第二方面,本申请实施例提供了一种数据库访问日志生成装置,所述装置包括:In the second aspect, the embodiment of the present application provides a database access log generating device, the device comprising:

调用信息获取模块,用于在监听到待测试应用调用指令信息获取函数的情况下,获取所述指令信息获取函数所返回的指令信息,以及获取所述指令信息获取函数在本次调用中所对应的调用栈;所述指令信息获取函数用于获取数据库访问指令的指令信息;The call information acquisition module is used to obtain the instruction information returned by the instruction information acquisition function and obtain the instruction information corresponding to the instruction information acquisition function in this call when the application to be tested is monitored to call the instruction information acquisition function. the call stack; the instruction information obtaining function is used to obtain the instruction information of the database access instruction;

接口名称获取模块,用于按照从栈顶到栈底的方向,依次对所述调用栈中各级调用函数的函数信息进行匹配,以确定目标接口的接口名称;所述目标接口为发送与所述指令信息相对应的数据库访问指令的接口函数;The interface name acquisition module is used to match the function information of the call functions at all levels in the call stack in turn according to the direction from the top of the stack to the bottom of the stack, so as to determine the interface name of the target interface; The interface function of the database access command corresponding to the above command information;

日志生成模块,用于根据所述指令信息及所述目标接口的接口名称生成所述指令信息获取函数在本次调用中的日志信息,并将所述日志信息写入所述待测试应用的数据库访问日志中。A log generating module, configured to generate log information of the instruction information acquisition function in this call according to the instruction information and the interface name of the target interface, and write the log information into the database of the application to be tested in the access log.

第三方面,本申请实施例提供了一种存储介质,所述存储介质中存储有计算机可读指令,所述计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行上述任一实施例所述数据库访问日志生成方法的步骤。In a third aspect, the embodiment of the present application provides a storage medium, the storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, one or more processors Execute the steps of the database access log generation method described in any of the above embodiments.

第四方面,本申请实施例提供了一种计算机设备,包括:一个或多个处理器,以及存储器;In a fourth aspect, the embodiment of the present application provides a computer device, including: one or more processors, and a memory;

所述存储器中存储有计算机可读指令,所述计算机可读指令被所述一个或多个处理器执行时,执行上述任一实施例所述数据库访问日志生成方法的步骤。Computer-readable instructions are stored in the memory, and when the computer-readable instructions are executed by the one or more processors, the steps of the method for generating a database access log in any of the above embodiments are executed.

在本申请的数据库访问日志生成方法、装置、存储介质及计算机设备中,可对指令信息获取函数进行监听,在监听到待测试应用调用指令信息获取函数的情况下,获取指令信息获取函数所返回的指令信息以及该指令信息获取函数在本次调用过程中对应的调用栈。对于该调用栈,本申请可按照从栈顶到栈底的方向,依次对调用栈中的各级调用函数的函数信息进行匹配,以确定发送与指令信息相对应的数据库访问指令的目标接口的接口名称。在得到接口名称及指令信息生产生成指令信息获取函数在本地调用中的日志信息,并将该日志信息写入至待测试应用的数据库访问日志中,以得到待测试应用在执行过程中的完整数据库访问日志,从而可基于该数据库访问日志排查数据问题,以加快排查效率。In the database access log generation method, device, storage medium, and computer equipment of the present application, the instruction information acquisition function can be monitored, and when the application to be tested is detected to call the instruction information acquisition function, the information returned by the instruction information acquisition function can be obtained. The instruction information and the instruction information obtains the corresponding call stack of the function during this call. For the call stack, the application can sequentially match the function information of the call functions at all levels in the call stack in the direction from the top of the stack to the bottom of the stack, so as to determine the target interface for sending the database access instruction corresponding to the instruction information Interface name. After obtaining the interface name and instruction information, generating instruction information, obtaining the log information in the local call of the function, and writing the log information into the database access log of the application to be tested, so as to obtain a complete database of the application to be tested during execution Access logs, so that you can troubleshoot data problems based on the database access logs to speed up troubleshooting.

附图说明Description of drawings

为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其它的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present application. Those skilled in the art can also obtain other drawings based on these drawings without any creative effort.

图1为一个实施例中数据库访问日志生成方法的流程示意图;Fig. 1 is a schematic flow diagram of a method for generating a database access log in an embodiment;

图2为一个实施例中数据库访问日志生成装置的结构示意图;Fig. 2 is a schematic structural diagram of a database access log generation device in an embodiment;

图3为一个实施例中计算机设备的结构示意图。Fig. 3 is a schematic structural diagram of a computer device in an embodiment.

具体实施方式Detailed ways

下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, not all of them. Based on the embodiments in this application, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the scope of protection of this application.

在一个实施例中,本申请提供了一种数据库访问日志生成方法。下述实施例以该方法应用于服务器为例进行说明。可以理解,执行数据库访问日志生成方法的服务器可以是单个服务器,也可以是由多个服务器组成的服务器集群,本申请对此不作具体限制。如图1所示,该方法具体包括如下步骤:In one embodiment, the present application provides a method for generating a database access log. The following embodiments are described by taking the method applied to a server as an example. It can be understood that the server executing the database access log generation method may be a single server or a server cluster composed of multiple servers, which is not specifically limited in this application. As shown in Figure 1, the method specifically includes the following steps:

S102,在监听到待测试应用调用指令信息获取函数的情况下,获取所述指令信息获取函数所返回的指令信息,以及获取所述指令信息获取函数在本次调用中所对应的调用栈;所述指令信息获取函数用于获取数据库访问指令的指令信息。S102. Obtain the instruction information returned by the instruction information acquisition function, and acquire the call stack corresponding to the instruction information acquisition function in this call, when it is detected that the application to be tested calls the instruction information acquisition function; The instruction information obtaining function described above is used to obtain the instruction information of the database access instruction.

其中,待测试应用可以通过调用指令信息获取函数来获取数据库访问指令的指令信息,该指令信息包括但不限于是数据库访问指令的操作标签、操作对象和操作条件等。在其中一个实施例中,指令信息获取函数可以为MappedStatement类的getBoundSql()函数,换言之,服务器可以监听待测试应用是否调用getBoundSql()函数,并在监听到待测试应用调用该方法的情况下,获取getBoundSql()函数所返回的指令信息以及getBoundSql()函数在本地调用中所对应的调用栈。Wherein, the application to be tested can obtain the instruction information of the database access instruction by calling the instruction information acquisition function, the instruction information includes but not limited to the operation label, operation object and operation condition of the database access instruction. In one of the embodiments, the command information acquisition function can be the getBoundSql() function of the MappedStatement class. In other words, the server can monitor whether the application under test calls the getBoundSql() function, and when it detects that the application under test calls the method, Get the instruction information returned by the getBoundSql() function and the call stack corresponding to the getBoundSql() function in the local call.

调用栈记录有指令信息获取函数在本次调用过程中各层级调用函数所对应的函数信息,如各层级调用函数的函数名称、各层级调用函数所对应的类名等。在其中一个实施例中,服务器可以调用Thread.currentThread().getStackTrace()方法来获取指令信息获取函数在本次调用过程中的调用栈。The call stack records the function information corresponding to the call function at each level in the current call process of the instruction information acquisition function, such as the function name of the call function at each level, the class name corresponding to the call function at each level, and so on. In one embodiment, the server may call the Thread.currentThread().getStackTrace() method to obtain instruction information and obtain the call stack of the function during this call.

S104,按照从栈顶到栈底的方向,依次对所述调用栈中各级调用函数的函数信息进行匹配,以确定目标接口的接口名称;所述目标接口为发送与所述指令信息相对应的数据库访问指令的接口函数。S104, according to the direction from the top of the stack to the bottom of the stack, sequentially match the function information of the call function at each level in the call stack to determine the interface name of the target interface; The interface function of the database access instruction.

其中,调用栈的栈顶记录有最先执行的调用函数所对应的函数信息,调用栈的栈底记录有最晚执行的调用函数所对应的函数信息。例如,在指令信息获取函数的本次调用过程中,待测试应用先调用函数A,并在函数A内调用函数B,而后在函数B内调用指令信息获取函数,那么函数A所对应的函数信息位于调用栈的栈顶,函数B所对应的函数信息位于调用栈的栈底。Wherein, the stack top of the call stack records the function information corresponding to the call function executed first, and the stack bottom of the call stack records the function information corresponding to the call function executed latest. For example, in this calling process of the instruction information acquisition function, the application under test calls function A first, then calls function B in function A, and then calls the instruction information acquisition function in function B, then the function information corresponding to function A It is located at the top of the call stack, and the function information corresponding to function B is located at the bottom of the call stack.

服务器可依据调用栈分析出调用该指令信息获取函数的来源接口。具体而言,服务器可以按照从栈顶到栈底的方向,依次对调用栈中各级调用函数所对应的函数信息进行匹配,并根据首个满足预设匹配规则的函数信息得到目标接口所对应的接口名称。例如,在上述示例中,服务器可先对函数A所对应的函数信息进行匹配,以判断函数A所对应的函数信息是否满足预设匹配规则,若是,则根据函数A所对应的函数信息确定目标接口的接口名称,若否,则对函数B所对应的函数信息进行匹配,以判断其是否满足预设的匹配规则,以此类推。The server can analyze the source interface for calling the instruction information acquisition function according to the call stack. Specifically, the server can sequentially match the function information corresponding to the call functions at all levels in the call stack in the direction from the top of the stack to the bottom of the stack, and obtain the corresponding function information of the target interface according to the first function information that meets the preset matching rules. interface name. For example, in the above example, the server can first match the function information corresponding to function A to determine whether the function information corresponding to function A satisfies the preset matching rules, and if so, determine the target according to the function information corresponding to function A The interface name of the interface, if not, match the function information corresponding to function B to determine whether it satisfies the preset matching rules, and so on.

本申请通过按照从栈顶到栈底的方向,依次对调用栈中各级调用函数的函数信息进行匹配,从而可提高接口名称的获取效率,进而提高测试效率。The present application sequentially matches the function information of calling functions at various levels in the call stack in the direction from the top of the stack to the bottom of the stack, thereby improving the efficiency of obtaining interface names and further improving the testing efficiency.

S106,根据所述指令信息及所述目标接口的接口名称生成所述指令信息获取函数在本次调用中的日志信息,并将所述日志信息写入所述待测试应用的数据库访问日志中。S106. Generate log information in this call of the instruction information acquisition function according to the instruction information and the interface name of the target interface, and write the log information into the database access log of the application to be tested.

在得到指令信息和目标接口的接口名称后,服务器可以根据指令信息和目标接口的接口名称生成对应的日志信息,该日志信息中记录有指令信息及目标接口的接口名称。在其中一个实施例中,日志信息还可记录有指令信息获取函数的调用时间或者数据库访问时间。After obtaining the instruction information and the interface name of the target interface, the server can generate corresponding log information according to the instruction information and the interface name of the target interface, and the log information records the instruction information and the interface name of the target interface. In one of the embodiments, the log information may also record the call time of the instruction information acquisition function or the database access time.

在得到日志信息后,服务器可将该日志信息写入至待测试应用的数据库访问日志中。After obtaining the log information, the server may write the log information into the database access log of the application to be tested.

本申请中,可对指令信息获取函数进行监听,在监听到待测试应用调用指令信息获取函数的情况下,获取指令信息获取函数所返回的指令信息以及该指令信息获取函数在本次调用过程中对应的调用栈。对于该调用栈,本申请可按照从栈顶到栈底的方向,依次对调用栈中的各级调用函数的函数信息进行匹配,以确定发送与指令信息相对应的数据库访问指令的目标接口的接口名称。在得到接口名称及指令信息生产生成指令信息获取函数在本地调用中的日志信息,并将该日志信息写入至待测试应用的数据库访问日志中,以得到待测试应用在执行过程中的完整数据库访问日志,从而可基于该数据库访问日志排查数据问题,以加快排查效率。In this application, the instruction information acquisition function can be monitored, and when the application to be tested is monitored to call the instruction information acquisition function, the instruction information returned by the instruction information acquisition function and the instruction information acquisition function during this call The corresponding call stack. For the call stack, the application can sequentially match the function information of the call functions at all levels in the call stack in the direction from the top of the stack to the bottom of the stack, so as to determine the target interface for sending the database access instruction corresponding to the instruction information Interface name. After obtaining the interface name and instruction information, generating instruction information, obtaining the log information in the local call of the function, and writing the log information into the database access log of the application to be tested, so as to obtain a complete database of the application to be tested during execution Access logs, so that you can troubleshoot data problems based on the database access logs to speed up troubleshooting.

在一个实施例中,所述按照从栈顶到栈底的方向,依次对所述调用栈中各级调用函数的函数信息进行匹配,以确定目标接口的接口名称的步骤,包括:In one embodiment, the step of sequentially matching the function information of the calling functions at various levels in the call stack from the top of the stack to the bottom of the stack to determine the interface name of the target interface includes:

按照从栈顶到栈底的方向,依次将各级调用函数的函数信息作为当前待匹配函数信息,直至所述当前待匹配函数信息所包括的类名存在预设的关键字段,并将所述当前待匹配函数信息作为目标函数信息;According to the direction from the top of the stack to the bottom of the stack, the function information of the calling functions at all levels is used as the current function information to be matched, until the class name included in the current function information to be matched has a preset key field, and the Describe the current function information to be matched as the target function information;

根据所述目标函数信息所包括的类名和函数名,确定所述目标接口的接口名称。The interface name of the target interface is determined according to the class name and function name included in the target function information.

具体而言,服务器可以按照从栈顶到栈底的方向,依次将各级调用函数的函数信息作为当前待匹配函数信息,并判断当前待匹配函数信息的类名中是否存在预设的关键字段,若存在,则将当前待匹配函数信息作为目标函数信息,若不存在,则将下一级调用函数的函数信息作为当前待匹配函数信息,并判断当前待匹配函数信息的类名中是否存在预设的关键字段,并按照前述步骤执行,直至确定目标函数信息为止。可以理解,该预设的关键字段可以依据实际情况确定。在其中一个实施例中,预设的关键字段包括“Service”和“Help”,换言之,服务器可以按照从栈顶到栈底的方向,将首个类名同时包括Service和Help的函数信息作为目标函数信息。Specifically, the server can sequentially use the function information of the calling functions at all levels as the current function information to be matched according to the direction from the top of the stack to the bottom of the stack, and judge whether there is a preset keyword in the class name of the current function information to be matched segment, if it exists, use the current function information to be matched as the target function information, if it does not exist, use the function information of the next-level call function as the current function information to be matched, and judge whether the class name of the current function information to be matched is There are preset key fields, and the preceding steps are followed until the objective function information is determined. It can be understood that the preset key fields may be determined according to actual conditions. In one embodiment, the preset key fields include "Service" and "Help". In other words, the server can use the function information whose first class name includes both Service and Help in the direction from the top of the stack to the bottom of the stack as Objective function information.

在得到目标函数信息后,本申请可以根据目标函数信息中的类名和函数名,确定目标接口的接口名称。在其中一个实施例中,目标接口的接口名称可以包括目标函数信息中的类名和函数名。After obtaining the target function information, the application can determine the interface name of the target interface according to the class name and function name in the target function information. In one embodiment, the interface name of the target interface may include the class name and function name in the target function information.

本申请实施例中,通过按照从栈顶到栈底的方向,将调用栈中首个类名包括预设的关键字段的函数信息作为目标函数信息,并依据目标函数信息确定目标接口的接口名称,从而可快速且准确地获取目标接口的接口名称,进而可提高测试效率及日志信息的准确性。In the embodiment of the present application, by following the direction from the top of the stack to the bottom of the stack, the function information of the first class name in the call stack including the preset key field is used as the target function information, and the interface of the target interface is determined according to the target function information Name, so that the interface name of the target interface can be obtained quickly and accurately, which can improve the test efficiency and the accuracy of log information.

在一个实施例中,所述根据所述指令信息及所述目标接口的接口名称生成所述指令信息获取函数在本次调用中的日志信息的步骤,包括:In one embodiment, the step of generating the log information of the instruction information acquisition function in this call according to the instruction information and the interface name of the target interface includes:

按照预设的数据库访问指令格式对所述指令信息进行组装,以得到目标数据库访问指令;所述目标数据库访问指令为与所述指令信息相对应的数据库访问指令;Assembling the instruction information according to a preset database access instruction format to obtain a target database access instruction; the target database access instruction is a database access instruction corresponding to the instruction information;

基于所述目标数据库访问指令及所述目标接口的接口名称生成所述指令信息获取函数在本次调用中的日志信息,以使所述日志信息包括所述目标数据库访问指令及所述接口名称。Generate log information of the instruction information acquisition function in this call based on the target database access instruction and the interface name of the target interface, so that the log information includes the target database access instruction and the interface name.

具体而言,在依据指令信息和目标接口的接口名称生成日志信息的过程中,由于指令信息获取函数所返回的指令信息为解析后的目标数据库访问指令的描述对象,因此,服务器可依据指令信息获取函数所返回的指令信息组装得到目标数据库访问指令,并据此生成指令信息获取函数在本次调用过程中所对应的日志信息,使得日志信息可以同时记录目标数据库访问指令和目标接口的接口名称。如此,可得到更为完整的数据库访问日志,从而可基于该数据库访问日志排查数据问题,以进一步加快排查效率。Specifically, in the process of generating log information based on the command information and the interface name of the target interface, since the command information returned by the command information acquisition function is the description object of the parsed target database access command, the server can The command information returned by the acquisition function is assembled to obtain the target database access command, and the log information corresponding to the command information acquisition function in this calling process is generated accordingly, so that the log information can record the target database access command and the interface name of the target interface at the same time . In this way, a more complete database access log can be obtained, so that data problems can be checked based on the database access log, so as to further speed up the checking efficiency.

在一个实施例中,基于所述目标数据库访问指令及所述目标接口的接口名称生成所述指令信息获取函数在本次调用中的日志信息,以使所述日志信息包括所述目标数据库访问指令及所述接口名称的步骤,包括:In one embodiment, based on the target database access command and the interface name of the target interface, the log information of the instruction information acquisition function in this call is generated, so that the log information includes the target database access command and the steps of the interface name, including:

从所述指令信息中提取所述目标数据库访问指令中的操作标签,并根据所述操作标签确定所述目标接口的读写属性;Extracting the operation label in the target database access instruction from the instruction information, and determining the read-write attribute of the target interface according to the operation label;

基于所述目标数据库访问指令、所述目标接口的接口名称和所述目标接口的读写属性生成所述指令信息获取函数在本次调用中的日志信息,以使所述日志信息包括所述目标数据库访问指令、所述接口名称及所述读写属性。Generate log information of the command information acquisition function in this call based on the target database access command, the interface name of the target interface, and the read-write attribute of the target interface, so that the log information includes the target Database access instruction, the interface name and the read-write attribute.

具体而言,服务器可以从指令信息获取函数所返回的指令信息中提取目标数据库访问指令的操作标签,该操作标签可以为选择标签“select”、插入标签“insert”、更新标签“update”或者删除标签“delete”。在得到目标数据库访问指令的操作标签后,服务器可以根据操作标签确定目标数据库访问指令的读写操作属性,该读写操作属性即为目标接口的读写属性。Specifically, the server can extract the operation label of the target database access instruction from the instruction information returned by the instruction information acquisition function. The operation label can be the selection label "select", the insertion label "insert", the update label "update" or delete Label "delete". After obtaining the operation label of the target database access instruction, the server can determine the read and write operation attributes of the target database access instruction according to the operation label, and the read and write operation attributes are the read and write attributes of the target interface.

在得到目标数据库访问指令、目标接口的接口名称和目标接口的读写属性之后,服务器可根据前述信息生成指令信息获取函数在本次调用过程中的日志信息,该日志信息中包括前述全部信息。服务器可将所生成的日志信息写入至待测试应用的数据库访问日志中。After obtaining the target database access command, the interface name of the target interface, and the read/write attributes of the target interface, the server can generate command information according to the aforementioned information to obtain the log information of the function during this call, and the log information includes all the aforementioned information. The server can write the generated log information into the database access log of the application to be tested.

本实施例中,根据目标数据库访问指令的操作标签确定目标接口的读写属性,并将该读写属性写入至数据库访问日志中,从而可依据目标接口的读写属性回放生产流量,以进一步降低人力维护成本。In this embodiment, the read-write attribute of the target interface is determined according to the operation label of the target database access command, and the read-write attribute is written into the database access log, so that the production traffic can be played back according to the read-write attribute of the target interface to further Reduce labor maintenance costs.

在一个实施例中,所述根据所述操作标签确定所述目标接口的读写属性的步骤,包括:In one embodiment, the step of determining the read-write attribute of the target interface according to the operation tag includes:

若所述操作标签为选择标签,则确定所述目标接口的读写属性为读属性;If the operation tag is a selection tag, then determine that the read-write attribute of the target interface is a read attribute;

若所述操作标签为插入标签、更新标签或者删除标签,则确定所述目标接口的读写属性为写属性。If the operation tag is an insert tag, an update tag, or a delete tag, it is determined that the read-write attribute of the target interface is a write attribute.

具体而言,若所提取的操作标签为选择标签,则可确定目标数据库访问指令仅用于获取目标数据库中的数据,不涉及对目标数据库中的数据进行增添删改,即不涉及写操作,因此可确定目标接口的读写属性为读属性。当所提取的操作标签为插入标签、更新标签或者删除标签时,可以确定目标数据库访问指令的执行会对目标数据库中的数据进行增加、删除或者修改,也即,目标数据库访问指令在执行过程中涉及数据库写操作,因此可确定目标接口的读写属性为写属性。Specifically, if the extracted operation label is a selection label, it can be determined that the target database access instruction is only used to obtain data in the target database, and does not involve adding or deleting data in the target database, that is, does not involve write operations, so The read-write attribute of the target interface may be determined as a read attribute. When the extracted operation label is insert label, update label or delete label, it can be determined that the execution of the target database access command will add, delete or modify the data in the target database, that is, the target database access command involves in the execution process Database write operation, so it can be determined that the read-write attribute of the target interface is the write attribute.

本申请实施例中,通过从指令信息中提取目标数据库访问指令的操作标签,从而可根据该操作标签快速确定目标接口的读写属性。In the embodiment of the present application, by extracting the operation label of the target database access instruction from the instruction information, the read-write attribute of the target interface can be quickly determined according to the operation label.

在一个实施例中,所述在监听到待测试应用调用指令信息获取函数的情况下,获取所述指令信息获取函数所返回的指令信息,以及获取所述指令信息获取函数在本次调用中所对应的调用栈的步骤之前,还包括:In one embodiment, when it is detected that the application to be tested calls the instruction information acquisition function, the instruction information returned by the instruction information acquisition function is obtained, and the instruction information obtained by the instruction information acquisition function in this call is obtained. Before the steps of the corresponding call stack, it also includes:

利用程序插桩技术在所述待测试应用中插入测试函数,以通过所述测试函数监听所述待测试应用是否调用所述指令信息获取函数。A test function is inserted into the application under test by using a program insertion technology, so as to monitor whether the application under test calls the instruction information acquisition function through the test function.

可以理解,本申请可以通过任意类型的程序插桩技术来实现测试函数的插入,在其中一个实施例中,程序插桩技术可以为JVM-Sandbox(Java虚拟机沙箱)技术。It can be understood that the application can use any type of program insertion technology to implement the insertion of test functions. In one embodiment, the program insertion technology can be JVM-Sandbox (Java Virtual Machine Sandbox) technology.

在其中一个实施例中,测试函数可以用于监听待测试应用是否调用指令信息获取函数,以及执行上述任一实施例所述数据库访问日志生成方法的步骤。为确保测试函数在监听到待测试应用调用指令信息获取函数的情况下,能够准确获取指令信息获取函数在本次调用过程中的调用栈,本申请可利用程序插桩技术在待测试应用的指定位置处插入所述测试函数,该指定位置为使得所述测试函数与所述指令信息获取函数在同一线程中运行的位置。In one of the embodiments, the test function can be used to monitor whether the application to be tested calls the instruction information acquisition function, and execute the steps of the database access log generation method described in any of the above embodiments. In order to ensure that the test function can accurately obtain the call stack of the instruction information acquisition function in this call process when it detects that the application to be tested calls the instruction information acquisition function, this application can use the program instrumentation technology in the specified application to be tested. The test function is inserted at a position where the test function and the instruction information acquisition function run in the same thread.

下面对本申请实施例提供的数据库访问日志生成装置进行描述,下文描述的数据库访问日志生成装置与上文描述的数据库访问日志生成方法可相互对应参照。The database access log generation device provided by the embodiment of the present application is described below, and the database access log generation device described below and the database access log generation method described above can be referred to in correspondence.

在一个实施例中,本申请提供了一种数据库访问日志生成装置200。如图2所示,该装置200具体包括调用信息获取模块210、接口名称获取模块220和日志生成模块230,其中:In one embodiment, the present application provides an apparatus 200 for generating a database access log. As shown in FIG. 2 , the device 200 specifically includes a call information acquisition module 210, an interface name acquisition module 220, and a log generation module 230, wherein:

调用信息获取模块210,用于在监听到待测试应用调用指令信息获取函数的情况下,获取所述指令信息获取函数所返回的指令信息,以及获取所述指令信息获取函数在本次调用中所对应的调用栈;所述指令信息获取函数用于获取数据库访问指令的指令信息;The call information acquisition module 210 is configured to acquire the instruction information returned by the instruction information acquisition function when the application to be tested is detected to call the instruction information acquisition function, and to acquire the instruction information obtained by the instruction information acquisition function in this call. Corresponding call stack; the instruction information obtaining function is used to obtain the instruction information of the database access instruction;

接口名称获取模块220,用于按照从栈顶到栈底的方向,依次对所述调用栈中各级调用函数的函数信息进行匹配,以确定目标接口的接口名称;所述目标接口为发送与所述指令信息相对应的数据库访问指令的接口函数;The interface name acquisition module 220 is used to match the function information of the calling functions at all levels in the call stack in turn according to the direction from the top of the stack to the bottom of the stack, so as to determine the interface name of the target interface; The interface function of the database access instruction corresponding to the instruction information;

日志生成模块230,用于根据所述指令信息及所述目标接口的接口名称生成所述指令信息获取函数在本次调用中的日志信息,并将所述日志信息写入所述待测试应用的数据库访问日志中。The log generating module 230 is configured to generate the log information of the instruction information acquisition function in this call according to the instruction information and the interface name of the target interface, and write the log information into the application to be tested in the database access log.

在一个实施例中,接口名称获取模块220包括目标函数信息获取单元及接口名称确定单元。其中,目标函数信息获取单元用于按照从栈顶到栈底的方向,依次将各级调用函数的函数信息作为当前待匹配函数信息,直至所述当前待匹配函数信息所包括的类名存在预设的关键字段,并将所述当前待匹配函数信息作为目标函数信息。接口名称确定单元用于根据所述目标函数信息所包括的类名和函数名,确定所述目标接口的接口名称。In one embodiment, the interface name acquisition module 220 includes an objective function information acquisition unit and an interface name determination unit. Wherein, the target function information acquisition unit is used to sequentially use the function information of the calling functions at all levels as the current function information to be matched according to the direction from the top of the stack to the bottom of the stack, until the class name included in the current function information to be matched has a predetermined Set the key field, and use the current function information to be matched as the target function information. The interface name determination unit is configured to determine the interface name of the target interface according to the class name and function name included in the target function information.

在一个实施例中,日志生成模块230包括目标指令获取单元和第一日志信息生成单元。其中,目标指令获取单元用于按照预设的数据库访问指令格式对所述指令信息进行组装,以得到目标数据库访问指令;所述目标数据库访问指令为与所述指令信息相对应的数据库访问指令。第一日志信息生成单元用于基于所述目标数据库访问指令及所述目标接口的接口名称生成所述指令信息获取函数在本次调用中的日志信息,以使所述日志信息包括所述目标数据库访问指令及所述接口名称。In one embodiment, the log generation module 230 includes a target instruction acquisition unit and a first log information generation unit. Wherein, the target instruction acquisition unit is configured to assemble the instruction information according to a preset database access instruction format to obtain a target database access instruction; the target database access instruction is a database access instruction corresponding to the instruction information. The first log information generation unit is configured to generate the log information of the instruction information acquisition function in this call based on the target database access instruction and the interface name of the target interface, so that the log information includes the target database Access instructions and the name of the interface.

在一个实施例中,第一日志信息生成单元包括读写属性获取单元和第二日志信息生成单元。其中,读写属性获取单元用于从所述指令信息中提取所述目标数据库访问指令中的操作标签,并根据所述操作标签确定所述目标接口的读写属性。第二日志信息生成单元用于基于所述目标数据库访问指令、所述目标接口的接口名称和所述目标接口的读写属性生成所述指令信息获取函数在本次调用中的日志信息,以使所述日志信息包括所述目标数据库访问指令、所述接口名称及所述读写属性。In one embodiment, the first log information generation unit includes a read/write attribute acquisition unit and a second log information generation unit. Wherein, the read-write attribute acquisition unit is configured to extract the operation label in the target database access instruction from the instruction information, and determine the read-write attribute of the target interface according to the operation label. The second log information generation unit is configured to generate the log information of the instruction information acquisition function in this call based on the target database access instruction, the interface name of the target interface, and the read-write attribute of the target interface, so that The log information includes the target database access command, the interface name and the read-write attribute.

在一个实施例中,读写属性获取单元包括读属性确定单元和写属性确定单元。其中,读属性确定单元用于若所述操作标签为选择标签,则确定所述目标接口的读写属性为读属性。写属性确定单元用于若所述操作标签为插入标签、更新标签或者删除标签,则确定所述目标接口的读写属性为写属性。In one embodiment, the read-write attribute acquisition unit includes a read-attribute determination unit and a write-attribute determination unit. Wherein, the read attribute determining unit is configured to determine that the read/write attribute of the target interface is a read attribute if the operation tag is a selection tag. The write attribute determining unit is configured to determine that the read-write attribute of the target interface is a write attribute if the operation tag is an insert tag, an update tag or a delete tag.

在一个实施例中,所述装置200还包括函数插入模块,该函数插入模块用于利用程序插桩技术在所述待测试应用中插入测试函数,以通过所述测试函数监听所述待测试应用是否调用所述指令信息获取函数。In one embodiment, the apparatus 200 further includes a function insertion module, which is used to insert a test function into the application under test by using the program insertion technology, so as to listen to the application under test through the test function Whether to call the command information acquisition function.

在一个实施例中,该函数插入模块包括第一插入单元,该第一插入单元用于利用程序插桩技术在所述待测试应用的指定位置处插入所述测试函数,所述指定位置为使得所述测试函数与所述指令信息获取函数在同一线程中运行的位置。In one embodiment, the function insertion module includes a first insertion unit, and the first insertion unit is used to insert the test function at a designated position of the application to be tested by using a program insertion technology, and the designated position is such that The position where the test function and the instruction information acquisition function run in the same thread.

在一个实施例中,本申请还提供了一种存储介质,所述存储介质中存储有计算机可读指令,所述计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行如上述实施例中任一项所述数据库访问日志生成方法的步骤。In one embodiment, the present application also provides a storage medium, in which computer-readable instructions are stored, and when the computer-readable instructions are executed by one or more processors, one or more processing The server executes the steps of the database access log generation method described in any one of the above-mentioned embodiments.

在一个实施例中,本申请还提供了一种计算机设备。所述计算机设备中存储有计算机可读指令,所述计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行如上述实施例中任一项所述数据库访问日志生成方法的步骤。In an embodiment, the present application also provides a computer device. Computer-readable instructions are stored in the computer device, and when the computer-readable instructions are executed by one or more processors, one or more processors are executed to generate database access logs as described in any one of the above-mentioned embodiments. method steps.

示意性地,图3为本申请实施例提供的一种计算机设备的内部结构示意图,在一个示例中,该计算机设备可以为服务器。参照图3,计算机设备900包括处理组件902,其进一步包括一个或多个处理器,以及由存储器901所代表的存储器资源,用于存储可由处理组件902的执行的指令,例如应用程序。存储器901中存储的应用程序可以包括一个或一个以上的每一个对应于一组指令的模块。此外,处理组件902被配置为执行指令,以执行上述任意实施例所述数据库访问日志生成方法的步骤。Schematically, FIG. 3 is a schematic diagram of an internal structure of a computer device provided in an embodiment of the present application. In an example, the computer device may be a server. Referring to FIG. 3 , computer device 900 includes processing component 902 , which further includes one or more processors, and a memory resource represented by memory 901 for storing instructions executable by processing component 902 , such as application programs. The application program stored in memory 901 may include one or more modules each corresponding to a set of instructions. In addition, the processing component 902 is configured to execute instructions to execute the steps of the database access log generation method described in any of the above embodiments.

计算机设备900还可以包括一个电源组件903被配置为执行计算机设备900的电源管理,一个有线或无线网络接口904被配置为将计算机设备900连接到网络,和一个输入输出(I/O)接口905。计算机设备900可以操作基于存储在存储器901的操作系统,例如WindowsServer TM、Mac OS XTM、Unix TM、Linux TM、Free BSDTM或类似。The computer device 900 may also include a power supply component 903 configured to perform power management of the computer device 900, a wired or wireless network interface 904 configured to connect the computer device 900 to a network, and an input output (I/O) interface 905 . The computer device 900 can operate based on an operating system stored in the memory 901, such as Windows Server™, Mac OS X™, Unix™, Linux™, Free BSD™ or the like.

本领域技术人员可以理解,本申请示出的计算机设备的内部结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。Those skilled in the art can understand that the internal structure of the computer equipment shown in this application is only a block diagram of a part of the structure related to the solution of this application, and does not constitute a limitation on the computer equipment on which the solution of this application is applied. The computer device may include more or fewer components than shown in the figures, or combine certain components, or have a different arrangement of components.

最后,还需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。本文中,“一”、“一个”、“所述”、“该”和“其”也可以包括复数形式,除非上下文清楚指出另外的方式。多个是指至少两个的情况,如2个、3个、5个或8个等。“和/或”包括相关所列项目的任何及所有组合。Finally, it should also be noted that in this text, relational terms such as first and second etc. are only used to distinguish one entity or operation from another, and do not necessarily require or imply that these entities or operations, any such actual relationship or order exists. Furthermore, the term "comprises", "comprises" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article, or apparatus comprising a set of elements includes not only those elements, but also includes elements not expressly listed. other elements of or also include elements inherent in such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article or apparatus comprising said element. As used herein, "a", "an", "the", "the" and "it" may also include plural forms unless the context clearly dictates otherwise. A plurality refers to at least two situations, such as 2, 3, 5 or 8 and so on. "And/or" includes any and all combinations of the associated listed items.

本说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间可以根据需要进行组合,且相同相似部分互相参见即可。Each embodiment in this specification is described in a progressive manner. Each embodiment focuses on the difference from other embodiments. The various embodiments can be combined as needed, and the same and similar parts can be referred to each other. .

对所公开的实施例的上述说明,使本领域专业技术人员能够实现或使用本申请。对这些实施例的多种修改对本领域的专业技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本申请的精神或范围的情况下,在其它实施例中实现。因此,本申请将不会被限制于本文所示的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。The above description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the application. Therefore, the present application will not be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A method of generating a database access log, the method comprising:
under the condition that the application to be tested calls the instruction information acquisition function, acquiring instruction information returned by the instruction information acquisition function and acquiring a call stack corresponding to the instruction information acquisition function in the call; the instruction information acquisition function is used for acquiring instruction information of a database access instruction;
sequentially matching function information of calling functions at all levels in the calling stack according to the direction from the top of the stack to the bottom of the stack to determine the interface name of a target interface; the target interface is an interface function for sending a database access instruction corresponding to the instruction information;
and generating log information of the instruction information acquisition function in the current call according to the instruction information and the interface name of the target interface, and writing the log information into a database access log of the application to be tested.
2. The method according to claim 1, wherein the step of sequentially matching function information of call functions at each level in the call stack in a direction from the stack top to the stack bottom to determine an interface name of the target interface comprises:
according to the direction from the stack top to the stack bottom, sequentially taking function information of calling functions at all levels as current function information to be matched until a preset key field exists in a class name included in the current function information to be matched, and taking the current function information to be matched as target function information;
and determining the interface name of the target interface according to the class name and the function name included in the target function information.
3. The method according to claim 1, wherein the step of generating log information of the instruction information obtaining function in the current call according to the instruction information and the interface name of the target interface includes:
assembling the instruction information according to a preset database access instruction format to obtain a target database access instruction; the target database access instruction is a database access instruction corresponding to the instruction information;
and generating log information of the instruction information acquisition function in the current call based on the target database access instruction and the interface name of the target interface, so that the log information comprises the target database access instruction and the interface name.
4. The method according to claim 3, wherein the step of generating log information of the instruction information obtaining function in the current call based on the target database access instruction and the interface name of the target interface so that the log information includes the target database access instruction and the interface name includes:
extracting an operation label in the target database access instruction from the instruction information, and determining the read-write attribute of the target interface according to the operation label;
and generating log information of the instruction information acquisition function in the current call based on the target database access instruction, the interface name of the target interface and the read-write attribute of the target interface, so that the log information comprises the target database access instruction, the interface name and the read-write attribute.
5. The method according to claim 4, wherein the step of determining the read-write attribute of the target interface according to the operation tag comprises:
if the operation tag is a selection tag, determining the read-write attribute of the target interface as a read attribute;
and if the operation tag is an insertion tag, an update tag or a deletion tag, determining the read-write attribute of the target interface as a write attribute.
6. The method according to any one of claims 1 to 5, wherein before the steps of obtaining the instruction information returned by the instruction information obtaining function and obtaining the call stack corresponding to the instruction information obtaining function in the current call, in the case that it is monitored that the application to be tested calls the instruction information obtaining function, the method further comprises:
and inserting a test function into the application to be tested by utilizing a program instrumentation technology so as to monitor whether the application to be tested calls the instruction information acquisition function or not through the test function.
7. The method of claim 6, wherein the step of using program instrumentation techniques to insert test functions into the application under test comprises:
and inserting the test function at a specified position of the application to be tested by utilizing a program instrumentation technology, wherein the specified position is a position at which the test function and the instruction information acquisition function run in the same thread.
8. An apparatus for generating a database access log, the apparatus comprising:
the call information acquisition module is used for acquiring the instruction information returned by the instruction information acquisition function and acquiring a call stack corresponding to the instruction information acquisition function in the call under the condition that the application to be tested calls the instruction information acquisition function; the instruction information acquisition function is used for acquiring instruction information of a database access instruction;
the interface name acquisition module is used for sequentially matching function information of calling functions at all levels in the call stack according to the direction from the stack top to the stack bottom so as to determine the interface name of the target interface; the target interface is an interface function for sending a database access instruction corresponding to the instruction information;
and the log generation module is used for generating the log information of the instruction information acquisition function in the calling according to the instruction information and the interface name of the target interface, and writing the log information into the database access log of the application to be tested.
9. A storage medium having stored therein computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the database access log generation method of any of claims 1 to 7.
10. A computer device, comprising: one or more processors, and a memory;
the memory has stored therein computer readable instructions which, when executed by the one or more processors, perform the steps of the database access log generation method of any of claims 1 to 7.
CN202211054139.5A 2022-08-31 2022-08-31 Database access log generation method, device, storage medium and computer device Pending CN115328801A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211054139.5A CN115328801A (en) 2022-08-31 2022-08-31 Database access log generation method, device, storage medium and computer device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211054139.5A CN115328801A (en) 2022-08-31 2022-08-31 Database access log generation method, device, storage medium and computer device

Publications (1)

Publication Number Publication Date
CN115328801A true CN115328801A (en) 2022-11-11

Family

ID=83929034

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211054139.5A Pending CN115328801A (en) 2022-08-31 2022-08-31 Database access log generation method, device, storage medium and computer device

Country Status (1)

Country Link
CN (1) CN115328801A (en)

Similar Documents

Publication Publication Date Title
CN110928772B (en) A test method and device
US10055338B2 (en) Completing functional testing
US8150674B2 (en) Automated testing platform for event driven systems
US8782609B2 (en) Test failure bucketing
CN110287696B (en) Detection method, device and equipment for rebound shell process
CN111158741B (en) Method and device for monitoring dependency relationship change of service module on third party class library
US20100131315A1 (en) Resolving incident reports
CN110716539B (en) Fault diagnosis and analysis method and device
CN108319711A (en) Transaction consistency test method, device, storage medium and the equipment of database
CN107003931B (en) Decoupling test validation from test execution
CN110063042A (en) A kind of response method and its terminal of database failure
CN115658452B (en) Buried point verification method, buried point verification device, readable storage medium, and electronic device
CN108959454B (en) Prompting clause specifying method, device, equipment and storage medium
CN112579456B (en) Web automatic testing method and device
CN115328801A (en) Database access log generation method, device, storage medium and computer device
CN110147313A (en) A kind of log-output method and device
CN115168124A (en) Stability test method and device for concurrently executing multiple files on hard disk, computer equipment and medium
CN116414587A (en) Fault data acquisition method, fault processing method, electronic device and storage medium
CN114968725A (en) Task dependency relationship correction method and device, computer equipment and storage medium
CN111352824B (en) Test method, device and computer equipment
CN115328799A (en) Database operation testing method, device, storage medium and computer equipment
CN114116765B (en) Mybatis framework SQL statement anomaly detection method, server and system
CN112099838A (en) Method, device and storage medium for determining version difference
CN117873870B (en) A yum source integrity test method
CN115658551B (en) Code testing method, storage medium, electronic device and apparatus

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination