[go: up one dir, main page]

CN104598348B - A kind of method and system of the long-range external system interface performance of analysis in real time - Google Patents

A kind of method and system of the long-range external system interface performance of analysis in real time Download PDF

Info

Publication number
CN104598348B
CN104598348B CN201510090613.3A CN201510090613A CN104598348B CN 104598348 B CN104598348 B CN 104598348B CN 201510090613 A CN201510090613 A CN 201510090613A CN 104598348 B CN104598348 B CN 104598348B
Authority
CN
China
Prior art keywords
interface
log
analysis
performance
time
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.)
Active
Application number
CN201510090613.3A
Other languages
Chinese (zh)
Other versions
CN104598348A (en
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.)
Nanjing Tuniu Technology Co Ltd
Original Assignee
Nanjing Tuniu Technology 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 Nanjing Tuniu Technology Co Ltd filed Critical Nanjing Tuniu Technology Co Ltd
Priority to CN201510090613.3A priority Critical patent/CN104598348B/en
Publication of CN104598348A publication Critical patent/CN104598348A/en
Application granted granted Critical
Publication of CN104598348B publication Critical patent/CN104598348B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

本发明公开了一种远程实时分析外部系统接口性能的方法和系统,能够将每次进行外部接口访问时的接口信息记录为内存日志,在应用程序执行之后即开始进行日志分析,并在浏览器调试页面窗口中输出展示各接口性能分析报告,实现了外部接口性能的远程实时分析。由于日志存储在内存中,并不利用服务器上的磁盘存储空间,充分节约了服务器硬盘资源,还避免了从远程服务器上拖取日志信息进行人工查看带来的网络资源浪费和效率低下问题。此外,能够根据应用程序的输出内容格式显示接口分析报告,提升了用户体验。

The invention discloses a method and system for analyzing the interface performance of an external system remotely and in real time, which can record the interface information each time the external interface is accessed as a memory log, start log analysis after the application program is executed, and log in the browser Output and display the performance analysis report of each interface in the debugging page window, realizing the remote real-time analysis of the performance of the external interface. Since the logs are stored in the memory and do not use the disk storage space on the server, the hard disk resources of the server are fully saved, and the waste of network resources and inefficiency caused by dragging and fetching log information from a remote server for manual viewing are avoided. In addition, the interface analysis report can be displayed according to the output content format of the application program, which improves user experience.

Description

一种远程实时分析外部系统接口性能的方法及系统A method and system for remote real-time analysis of external system interface performance

技术领域technical field

本发明属于数据处理与分析技术领域,具体涉及一种远程实时分析外部系统数据层接口性能的方法。The invention belongs to the technical field of data processing and analysis, in particular to a method for remote real-time analysis of the performance of an external system data layer interface.

背景技术Background technique

随着科技的迅速发展,信息全球化共享速度也日益加快,这与网络技术的大规模普及应用密不可分,而网络性能、稳定性都对信息是否能够通畅交互起关键作用。在网络应用中经常需要通过http请求访问外部系统的接口获取数据,随着外部系统接口使用日渐频繁,系统的性能及稳定性会越来越受到外部系统的影响,这就需要对外部系统的接口进行分析,获取外部系统接口状况。With the rapid development of science and technology, the speed of information globalization and sharing is also accelerating, which is inseparable from the large-scale popularization and application of network technology, and network performance and stability play a key role in whether information can be exchanged smoothly. In network applications, it is often necessary to access the interface of the external system to obtain data through http requests. As the interface of the external system is used more and more frequently, the performance and stability of the system will be more and more affected by the external system, which requires the interface of the external system Perform analysis to obtain external system interface status.

但目前,现有的技术方案只能做到实时分析或远程分析,无法两者兼得。现有的实时分析是在开发阶段中通过在代码中输出中间值的方式做,只适用于本地开发环境,不适用于远程生产环境;而现有的远程分析是在远程接口代码中输出中间值在远程文件中,一定时间后下载远程文件进行手动查看,并不实时,且查看不便利。上述记录外部系统接口状态的文件会占用较大的磁盘空间,远程传输时也会占用较大的网络资源,此外记录的信息太多,可能会存在敏感信息,技术上亦存在安全风险。But at present, existing technical solutions can only achieve real-time analysis or remote analysis, and cannot achieve both. The existing real-time analysis is done by outputting intermediate values in the code during the development stage, which is only applicable to the local development environment, not the remote production environment; while the existing remote analysis is to output intermediate values in the remote interface code In remote files, downloading remote files after a certain period of time for manual viewing is not real-time, and viewing is inconvenient. The above-mentioned files that record the interface status of the external system will take up a lot of disk space, and will also take up a lot of network resources during remote transmission. In addition, there are too many recorded information, which may contain sensitive information, and there are also security risks in technology.

发明内容Contents of the invention

为解决上述问题,本发明公开了一种分析数据层接口的方法,能够在远程环境下做到外部系统接口性能的实时分析。In order to solve the above problems, the present invention discloses a method for analyzing data layer interfaces, which can perform real-time analysis of the performance of external system interfaces in a remote environment.

为了达到上述目的,本发明提供如下技术方案:In order to achieve the above object, the present invention provides the following technical solutions:

一种远程实时分析外部系统接口性能的方法,包括如下步骤:A method for remotely analyzing the performance of an external system interface in real time, comprising the following steps:

步骤A,通过浏览器打开远程环境中的待调试网页;Step A, open the webpage to be debugged in the remote environment through a browser;

步骤B,验证当前用户是否有访问权限,只针对有权限的用户进行后续步骤;Step B, verify whether the current user has access rights, and only perform subsequent steps for authorized users;

步骤C,执行当前应用功能逻辑,当执行过程中需要请求外部系统接口时,在执行接口请求前后在内存中存储日志数据,所述日志数据中包括外部系统接口的以下信息:唯一标识、请求的开始时间、请求的结束时间、外部接口描述信息、外部接口状态信息;Step C: Execute the current application function logic. When the external system interface needs to be requested during the execution process, store log data in the memory before and after executing the interface request. The log data includes the following information of the external system interface: unique identifier, requested Start time, end time of request, external interface description information, external interface status information;

步骤D,读取所有日志,将各类日志按照不同的唯一标识合并到一起,得到不同外部接口的日志记录,根据预先制定的分析规则针对每个外部接口分析性能,得到各外部接口性能分析报告;Step D, read all logs, merge various logs according to different unique identifiers, obtain log records of different external interfaces, analyze the performance of each external interface according to the pre-established analysis rules, and obtain the performance analysis report of each external interface ;

步骤E,在页面上输出应用原本输出的内容,并按照与内容一致的格式输出步骤D得到的性能报告。Step E, output the content originally output by the application on the page, and output the performance report obtained in step D in a format consistent with the content.

进一步的,所述步骤C中请求外部接口过程中包括如下步骤:Further, the process of requesting the external interface in step C includes the following steps:

步骤C-1,将接口名、接口入参、随机数和/或当前时间进行转换后得到一个字符串,针对该字符串生成有限长度的准唯一标识或唯一标识;Step C-1, convert the interface name, interface input parameters, random number and/or current time to obtain a string, and generate a quasi-unique or unique identifier of limited length for the string;

步骤C-2,将接口名、接口入参进行转换后得到一个字符串,然后与唯一标识一起,按照“唯一标识::描述标识::转换后的描述信息”的格式存储日志;Step C-2, convert the interface name and interface input parameters to obtain a character string, and then store the log together with the unique identifier in the format of "unique identifier::description identifier::converted description information";

步骤C-3,在开始访问外部接口时,按照“唯一标识::开始标识::当前时间”的格式存储在日志中;Step C-3, when starting to access the external interface, store in the log according to the format of "unique identifier::start identifier::current time";

步骤C-4,执行接口请求;Step C-4, execute the interface request;

步骤C-5,在外部接口访问结束时,按照“唯一标识::结束标识::当前时间”的格式存储日志;Step C-5, at the end of the external interface access, store the log in the format of "unique identifier::end identifier::current time";

步骤C-6,将执行接口请求时的状态信息进行转换后得到一个字符串,按照“唯一标识::状态标识::转换后的状态信息”的格式存储日志。Step C-6: Convert the state information when executing the interface request to obtain a character string, and store the log in the format of "unique identifier::state identifier::converted state information".

进一步的,所述唯一标识通过以下步骤生成:将接口名、接口入参、随机数和/或当前时间进行转换后得到一个字符串,其后对该字符串生成有限长度的准唯一标识。Further, the unique identifier is generated through the following steps: convert the interface name, interface input parameters, random numbers and/or current time to obtain a character string, and then generate a quasi-unique identifier of limited length for the character string.

进一步的,所述转换方法为json编码。Further, the conversion method is json encoding.

进一步的,所述对字符串生成有限长度的准唯一标识的方法为对字符串求md5值。Further, the method for generating a limited-length quasi-unique identifier for a character string is to calculate an md5 value for the character string.

进一步的,所述步骤E中输出的性能报告与原本输出的内容格式相同。Further, the performance report output in the step E is in the same format as the original output content.

进一步的,所述性能报告包括接口名称、接口入参、接口耗时、接口状态。Further, the performance report includes interface name, interface input parameters, interface time consumption, and interface status.

进一步的,所述方法通过PHP语言进行应用,在步骤A与步骤C之间还包括如下步骤:进行缓冲,获得PHP输出的所有内容。Further, the method is applied through the PHP language, and further includes the following steps between step A and step C: performing buffering to obtain all contents output by PHP.

一种远程实时分析外部系统接口性能的系统,包括鉴权模块、数据层公共接口模块、日志存储模块、日志分析模块、输出展示模块,所述鉴权模块用于对用户鉴权,并控制具备权限的用户才能进行访问;所述数据层公共接口模块提供了请求外部系统接口的封装,并在执行接口请求的前后记录请求的开始时间、描述信息、结束时间和状态信息至日志存储模块;所述日志存储模块用于存储数据层公共接口模块访问外部接口时生成的日志;所述日志分析模块用于读出日志存储模块中的日志数据,并进行解析合并后对日志数据进行分析,最终得到各接口分析报告;所述输出展示模块用于在浏览器中输出原功能内容并按照内容格式输出各接口性能分析报告。A system for remote real-time analysis of external system interface performance, including an authentication module, a data layer public interface module, a log storage module, a log analysis module, and an output display module. The authentication module is used to authenticate users and control Only authorized users can access; the data layer public interface module provides the encapsulation of the request external system interface, and records the start time, description information, end time and status information of the request to the log storage module before and after executing the interface request; The log storage module is used to store the log generated when the data layer public interface module accesses the external interface; the log analysis module is used to read the log data in the log storage module, analyze and merge the log data, and finally obtain Each interface analysis report; the output display module is used to output the original function content in the browser and output each interface performance analysis report according to the content format.

进一步的,所述日志存储模块为全局可访问的PHP数组,PHP数组仅在PHP程序执行时存在于内存中,网页生成后消失。Further, the log storage module is a globally accessible PHP array, and the PHP array only exists in the memory when the PHP program is executed, and disappears after the webpage is generated.

有益效果:Beneficial effect:

本发明能够将每次进行外部接口访问时的接口信息记录为内存日志,在应用程序执行之后即开始进行日志分析,并在浏览器调试页面窗口中输出展示各接口性能分析报告,实现了外部接口性能的远程实时分析。由于日志存储在内存中,并不利用服务器上的磁盘存储空间,充分节约了服务器硬盘资源,还避免了从远程服务器上拖取日志信息进行人工查看带来的网络资源浪费和效率低下问题。此外,能够根据应用程序的输出内容格式显示接口分析报告,提升了用户体验。The present invention can record the interface information of each external interface access as a memory log, start log analysis after the application program is executed, and output and display the performance analysis report of each interface in the browser debugging page window, realizing the external interface Remote real-time analysis of performance. Since the logs are stored in the memory and do not use the disk storage space on the server, the hard disk resources of the server are fully saved, and the waste of network resources and inefficiency caused by dragging and fetching log information from a remote server for manual viewing are avoided. In addition, the interface analysis report can be displayed according to the output content format of the application program, which improves user experience.

附图说明Description of drawings

图1为本发明提供的远程实时分析外部系统接口性能的方法流程示意图;Fig. 1 is the schematic flow chart of the method for remote real-time analysis of external system interface performance provided by the present invention;

图2为在请求外部系统接口前后记录日志的流程示意图;Fig. 2 is a schematic flow chart of recording logs before and after requesting an external system interface;

图3为对日志进行解析合并的流程示意图;FIG. 3 is a schematic flow chart of parsing and merging logs;

图4为日志分析结果示例图;Figure 4 is an example diagram of log analysis results;

图5为日志分析结果的页面截图;Figure 5 is a screenshot of the log analysis results page;

图6为本发明提供的远程实时分析外部系统接口性能的系统结构示意图。FIG. 6 is a schematic structural diagram of a system for remote real-time analysis of external system interface performance provided by the present invention.

具体实施方式Detailed ways

以下将结合具体实施例对本发明提供的技术方案进行详细说明,应理解下述具体实施方式仅用于说明本发明而不用于限制本发明的范围。The technical solutions provided by the present invention will be described in detail below in conjunction with specific examples. It should be understood that the following specific embodiments are only used to illustrate the present invention and are not intended to limit the scope of the present invention.

由于PHP是最受欢迎的WEB开发语言之一,应用非常广泛,本发明以PHP语言为环境基础,实现了对PHP外部系统接口性能进行远程实时分析的方法,如图1所示,具体包括以下步骤:Because PHP is one of the most popular WEB development languages, it is widely used. The present invention uses the PHP language as the environment basis to realize a method for remote real-time analysis of the interface performance of the PHP external system, as shown in Figure 1, specifically including the following step:

Step1:通过浏览器打开待调试网页,其中,待调试网页能够调用各远程外部接口。远程环境是指提供PHP服务的机器与浏览器所在的机器不是同一台机器,PHP代码无法通过编辑的方式进行变更,每变更一次PHP代码都需要进行一次发布。Step1: Open the webpage to be debugged through a browser, wherein the webpage to be debugged can call various remote external interfaces. The remote environment means that the machine that provides the PHP service and the machine where the browser is located are not the same machine, and the PHP code cannot be changed by editing, and every time the PHP code is changed, it needs to be released once.

Step2:运行应用功能,首先进行鉴权,没有权限的用户将不能访问,只允许有权限的用户访问。Step2: To run the application function, first perform authentication, users without authorization will not be able to access, and only authorized users are allowed to access.

Step3:内容缓冲,取得PHP输出的所有内容:当PHP应用是一个网页时,内容缓冲的就是这个网页的全部html,当PHP应用是一个ajax接口,内容缓冲的就是接口响应的内容。当使用其他语言如java语言开发时,则无需包含这个步骤。Step3: content buffering, get all the content output by PHP: when the PHP application is a web page, the content buffered is the entire html of the web page; when the PHP application is an ajax interface, the content buffered is the content of the interface response. When developing in other languages such as java, this step does not need to be included.

Step4:执行功能逻辑并在请求外部系统接口前后记录日志:功能逻辑为应用本身需要执行的代码,在执行过程当中可能会向外部系统多个接口发出数次访问请求,在请求接口的前后将请求的开始时间、结束时间、描述信息、状态信息写入日志,日志记录在内存中,不占用物理硬盘空间。本发明不需要存储日志文件,仅需看到访问时当前网页的日志,当前网页存储的日志是页面级的、请求级的,这样就保证了日志足够小,并避免了存储敏感信息。Step4: Execute the functional logic and record logs before and after requesting the external system interface: the functional logic is the code that needs to be executed by the application itself. During the execution process, several access requests may be sent to multiple interfaces of the external system, and the request will be sent before and after the request interface The start time, end time, description information, and status information of the system are written into the log, and the log is recorded in the memory without occupying physical hard disk space. The present invention does not need to store log files, but only needs to see the log of the current web page when accessing, and the log stored in the current web page is page-level and request-level, thus ensuring that the log is small enough and avoiding storing sensitive information.

每条日志数据中应存储入关于该接口的唯一标识来作为各接口日志之间的区分,具体的说,在请求外部系统接口前后记录日志的具体流程(请参阅图2)如下:Each log data should store the unique identifier of the interface as a distinction between the interface logs. Specifically, the specific process of recording logs before and after requesting the external system interface (see Figure 2) is as follows:

4-1,首先生成外部系统接口的唯一标识,具体的说,该唯一标识的生成算法为:将接口名、接口入参、随机数、当前时间(精确到微秒,在生成唯一标识时,随机数和当前时间应至少取其一)依次放入一个临时PHP数组中,并将该数组进行json编码后得到一个字符串,其后对该字符串求md5值就是唯一标识,求md5值仅仅作为示例,只要是能够将一个字符串生成有限长度的准唯一标识都可以应用到本步骤中。4-1. First generate the unique identifier of the external system interface. Specifically, the unique identifier generation algorithm is: interface name, interface input parameters, random number, current time (accurate to microseconds, when generating the unique identifier, At least one of the random number and the current time) should be put into a temporary PHP array in turn, and the array is json-encoded to obtain a string, and then the md5 value of the string is the unique identifier, and the md5 value is only As an example, any quasi-unique identifier that can generate a character string with a limited length can be applied to this step.

4-2,记录外部系统接口的描述信息,将接口名、接口入参放入一个临时的PHP数组中,进行json编码,然后与唯一标识一起,按照“唯一标识::d::编码后的描述信息”的格式,添加到日志的最后。4-2. Record the description information of the external system interface, put the interface name and interface input parameters into a temporary PHP array, perform json encoding, and then, together with the unique identifier, follow the "unique identifier::d::encoded Description" format, added to the end of the log.

4-3,记录外部系统接口的开始时间,即在开始访问外部接口时,按照“唯一标识::b::精确到毫秒的当前时间”的格式,添加到日志的最后。4-3. Record the start time of the external system interface, that is, add it to the end of the log in the format of "unique identifier::b::current time accurate to milliseconds" when accessing the external interface is started.

4-4,执行接口请求。4-4, Execute the interface request.

4-5,记录外部系统接口的结束时间,即在外部接口访问结束时,按照“唯一标识::e::精确到毫秒的当前时间”的格式,添加到日志的最后。4-5. Record the end time of the external system interface, that is, at the end of the external interface access, add it to the end of the log according to the format of "unique identifier::e::current time accurate to milliseconds".

4-6,记录接口的执行状态:首先查询到执行接口请求时的状态信息,当请求成功时,记录实际执行的请求和表示“请求成功”的字符;当请求失败时,记录失败的具体步骤和失败的原因;此外还要记录实际执行的接口地址。再将上述信息进行json编码,按照“唯一标识::s::编码后的状态信息”的格式,添加到日志的最后一行。4-6. Record the execution status of the interface: first query the status information when executing the interface request, when the request is successful, record the actual executed request and the character indicating "request successful"; when the request fails, record the specific steps of the failure and the reason for the failure; in addition, the address of the interface that was actually executed should be recorded. Then encode the above information into json, and add it to the last line of the log according to the format of "unique identifier::s::encoded status information".

每条日志数据都具有当前请求的外部系统接口的唯一标识,并采用中间位来标识不同种类的日志存储数据,如“d”表示接口描述信息,“b”表示接口开始时间,“e”表示接口结束时间,“s”表示接口执行状态,这些字符容易记忆和区分,当然也可以根据需要采用其他字符或数字。当日志数据中具有复杂数据时(如描述信息和状态信息),应采用类似json编码的方法把复杂数据序列化为字符串,当然也可以采取其他能够实现同样功能的方法;但当仅需存储时间数据时,则无需进行字符转化过程。Each log data has a unique identifier of the currently requested external system interface, and uses intermediate bits to identify different types of log storage data, such as "d" indicates interface description information, "b" indicates interface start time, and "e" indicates The end time of the interface, "s" indicates the execution status of the interface, these characters are easy to remember and distinguish, of course, other characters or numbers can also be used as needed. When there is complex data in the log data (such as description information and status information), a method similar to json encoding should be used to serialize the complex data into strings. Of course, other methods that can achieve the same function can also be used; but when only storage When time data is used, no character conversion process is required.

以下为在请求某外部接口时生成的日志记录:The following is the log record generated when requesting an external interface:

1402546486e137ee98216701bba3ae26::d::{"header":[],"serviceName":"TBS.city.CityContoller.queryBookingCity","params":{"name":null,"letter":null,"code":null,"hasBranch":null,"delFlag":0,"start":null,"limit":null,"sortname":"","sortorder":null}}1402546486e137ee98216701bba3ae26::d::{"header":[],"serviceName":"TBS.city.CityContoller.queryBookingCity","params":{"name":null,"letter":null,"code":null ,"hasBranch":null,"delFlag":0,"start":null,"limit":null,"sortname":"","sortorder":null}}

1402546486e137ee98216701bba3ae26::b::1422004699.29841402546486e137ee98216701bba3ae26::b::1422004699.2984

1402546486e137ee98216701bba3ae26::e::1422004699.47631402546486e137ee98216701bba3ae26::e::1422004699.4763

1402546486e137ee98216701bba3ae26::s::{"curlTime":null,"exception":null,"time":"2015-01-2317:18:19","info":{"url":"Http:\/\/10.10.10.232:12602\/tbs\/city\/booking-city\/query?eyJuYW1lIjpudWxsLCJsZXR0ZXIiOm51bGwsImNvZGUiOm51bGwsImhhc0JyYW5jaCI6bnVsbCwiZGVsRmxhZyI6MCwic3RhcnQiOm51bGwsImxpbWl0IjpudWxsLCJzb3J0bmFtZSI6IiIsInNvcnRvcmRlciI6bnVsbH0=","content_type":"application\/json;charset=UTF-8","http_code":200,"header_size":189,"request_size":326,"filetime":-1,"ssl_verify_result":0,"redirect_count":0,"total_time":0.16215,"namelookup_time":1.9e-5,"connect_time":0.000511,"pretransfer_time":0.000555,"size_upload":0,"size_download":107392,"speed_download":662300,"speed_upload":0,"download_content_length":-1,"upload_content_length":0,"starttransfer_time":0.153267,"redirect_time":0,"redirect_url":"","primary_ip":"10.10.10.232","certinfo":[],"primary_port":12602,"local_ip":"172.30.111.47","local_port":54031,"error_code":0,"error_string":""}}1402546486e137ee98216701bba3ae26::s::{"curlTime":null,"exception":null,"time":"2015-01-2317:18:19","info":{"url":"Http:\/\ /10.10.10.232:12602\/tbs\/city\/booking-city\/query?eyJuYW1lIjpudWxsLCJsZXR0ZXIiOm51bGwsImNvZGUiOm51bGwsImhhc0JyYW5jaCI6bnVsbCwiZGVsRmxhZyI6MCwic3RhcnQiOm51bGwsImxpbWl0IjpudWxsLCJzb3J0bmFtZSI6IiIsInNvcnRvcmRlciI6bnVsbH0=","content_type":"application\/json;charset=UTF-8","http_code":200,"header_size ":189,"request_size":326,"filetime":-1,"ssl_verify_result":0,"redirect_count":0,"total_time":0.16215,"namelookup_time":1.9e-5,"connect_time":0.000511, "pretransfer_time":0.000555,"size_upload":0,"size_download":107392,"speed_download":662300,"speed_upload":0,"download_content_length":-1,"upload_content_length":0,"starttransfer_time":0.153267," redirect_time":0,"redirect_url":"","primary_ip":"10.10.10.232","certinfo":[],"primary_port":12602,"local_ip":"172.30.111.47","local_port":54031 ,"error_code":0,"error_string":""}}

Step5:读取Step4中记录的各条日志,并逐条解析合并,解析是将存储的每条日志数据中的经过序列化的内容反序列化成PHP数组,由于Step4中进行序列化的内容为接口的描述信息和执行状态,因此在本步骤中首先需要将这些内容反序列化,合并是根据接口的唯一标识将具有同一标识的日志内容合并到一起。然后,针对合并后的日志数据,依次分析每一个接口的性能,最终得出接口的描述、性能分析报告。Step5: Read each log recorded in Step4, and analyze and merge them one by one. The analysis is to deserialize the serialized content in each stored log data into a PHP array, because the serialized content in Step4 is an interface Describe information and execution status, so in this step, these contents need to be deserialized first, and merging is to merge log contents with the same identifier together according to the unique identifier of the interface. Then, according to the merged log data, the performance of each interface is analyzed in turn, and finally the description of the interface and the performance analysis report are obtained.

具体地说,解析合并的过程如图3所示,具体为:Specifically, the process of parsing and merging is shown in Figure 3, specifically:

读取日志;read log;

建立一个空数组记录接口信息,本例中将该数组记为apilnfo;Create an empty array to record the interface information. In this example, the array is recorded as apilnfo;

逐条解析日志:Parse the log item by item:

首先取得日志的前32位md5串;First obtain the first 32 md5 strings of the log;

在apilnfo中以md5串为数组的key初始化一个空的单元;In apilnfo, an empty unit is initialized with the md5 string as the key of the array;

如果日志以前述取得的md5串::d::开头则说明该条日志记录的是接口描述信息,将描述信息进行json反解析后存入apilnfo的对应单元中;If the log starts with the md5 string ::d:: obtained above, it means that the log records the interface description information, and the description information is stored in the corresponding unit of apilnfo after json reverse parsing;

如果日志以前述取得的md5串::b::开头则说明该条日志记录的是接口开始时间,将开始时间存入apilnfo的对应单元中;If the log starts with the md5 string ::b:: obtained above, it means that the log records the interface start time, and the start time is stored in the corresponding unit of apilnfo;

如果日志以前述取得的md5串::e::开头则说明该条日志记录的是接口结束时间,将结束时间存入apilnfo的对应单元中;If the log starts with the md5 string ::e:: obtained above, it means that the log records the end time of the interface, and the end time is stored in the corresponding unit of apilnfo;

如果日志以前述取得的md5串::s::开头则说明该条日志记录的是接口状态信息,将状态信息进行json反解析后存入apilnfo的对应单元中;If the log starts with the md5 string ::s:: obtained above, it means that the log records the interface status information, and the status information is stored in the corresponding unit of apilnfo after json deparsing;

根据上述规则将所有日志记录解析合并,由此得到各不同请求中各外部接口的描述和状态数据。All log records are parsed and merged according to the above rules, so as to obtain the description and status data of each external interface in each different request.

随后,根据预先设定的分析规则和数据项目,针对各个接口依次进行性能分析,本例中根据Step4中生成的日志记录实例进行性能分析的结果报告如图4所示,其中:Then, according to the pre-set analysis rules and data items, perform performance analysis on each interface in turn. In this example, the performance analysis report based on the logging instance generated in Step4 is shown in Figure 4, where:

Time为接口执行时间(通过日志中的开始时间、结束时间相减所得)Time is the interface execution time (obtained by subtracting the start time and end time in the log)

ServiceName&HttpUrl为接口名称(从日志的描述信息中提取)&实际执行的接口(从日志的状态信息中提取)ServiceName&HttpUrl is the interface name (extracted from the description information of the log) & the actually executed interface (extracted from the status information of the log)

Params&Header为接口入参(从日志的描述信息中提取)Params&Header is the input parameter of the interface (extracted from the description information of the log)

Exception为接口状态,null表示没有错误,正确响应;否则显示响应的错误信息Exception is the status of the interface, null means there is no error and the response is correct; otherwise, the error message of the response is displayed

上述接口分析中给出接口名称、接口入参、接口耗时、接口状态,以便查看人可以复现接口问题。In the above interface analysis, the interface name, interface input parameters, interface time consumption, and interface status are given, so that the viewer can reproduce the interface problem.

根据需要,可以采用其他规则分析各外部系统接口的其他性能,例如分析同一接口在各个时段的状态,或分析用户在时间维度上对各个接口的访问量等等。According to needs, other rules can be used to analyze other performances of the external system interfaces, such as analyzing the status of the same interface at various time periods, or analyzing the number of user visits to each interface in the time dimension, and so on.

Step6:将Step5生成的性能分析报告在待调试页面中进行输出展示:首先通过PHP的缓冲区临时存储原功能的输出内容(在非PHP环境中——例如java则无需进行缓冲),然后根据原内容的格式显示性能报告,性能报告和缓冲区中的内容一起输出。本发明输出的性能报告根据原内容格式进行显示,因此需要先识别原来内容的格式,如果原来内容的输出格式为html,则在原html最后添加一段html表格的代码显示接口分析报告;如果原内容是json_encode、base64编码的,则解码后,将接口分析报告置于原来内容的末尾,再按照原内容格式进行编码。通过浏览器打开待调试页面时,在输出原本应用内容的基础上,还输出如图5所示的与应用内容格式一致的性能分析报告。Step6: Output and display the performance analysis report generated by Step5 on the page to be debugged: First, temporarily store the output content of the original function through the PHP buffer (in a non-PHP environment—such as java, there is no need to buffer), and then according to the original The format of the content shows the performance report, and the performance report is output together with the content in the buffer. The performance report output by the present invention is displayed according to the original content format, so it is necessary to identify the format of the original content first, if the output format of the original content is html, then add a section of html table code at the end of the original html to display the interface analysis report; if the original content is json_encode, base64 encoding, after decoding, put the interface analysis report at the end of the original content, and then encode according to the original content format. When the page to be debugged is opened through the browser, in addition to outputting the original application content, a performance analysis report in the same format as the application content is also output as shown in FIG. 5 .

针对上述方法,本发明还提供了一种远程实时分析外部系统接口性能的系统,如图6所示,包括鉴权模块、数据层公共接口模块、日志存储模块、日志分析模块、输出展示模块。For the above method, the present invention also provides a system for remote real-time analysis of external system interface performance, as shown in Figure 6, including an authentication module, a data layer public interface module, a log storage module, a log analysis module, and an output display module.

其中,鉴权模块用于对用户鉴权,并控制具备权限的用户才能进行访问,具体实现的功能可参照方法中Step2步骤;数据层公共接口模块提供了请求外部系统接口的封装,并在执行接口请求的前记录请求的开始时间、描述信息,执行请求后记录请求的结束时间和状态信息至日志存储模块中,具体实现的功能可参照方法中Step4步骤,应用程序模块通过数据层公共接口模块访问外部系统接口并获得返回数据,应用功能模块是编写好的PHP应用功能逻辑模块;日志存储模块用于存储数据层公共接口模块访问外部接口时生成的日志,在PHP环境中日志数据采用一个全局可访问的PHP数组实现,PHP数组仅在PHP程序执行时存在于内存中,网页生成后PHP进程生命周期结束,PHP数组消失,添加日志时直接在该数组最后压入一个单元;日志分析模块用于读出日志存储模块中的日志数据,并进行解析合并,得到每一个请求每一个接口的日志数据,并对日志数据进行分析,最终得到各接口分析报告,具体实现的功能可参照方法中Step5步骤;输出展示模块用于在浏览器中输出原功能内容和各接口性能分析报告,接口性能分析报告输出的格式与原功能内容格式一致,具体实现的功能可参照方法中Step6步骤。Among them, the authentication module is used to authenticate the user and control the access of the user who has the authority. The specific function can refer to Step 2 in the method; the data layer public interface module provides the encapsulation of the request external system interface, and executes the Before the interface request, record the start time and description information of the request, and record the end time and status information of the request to the log storage module after the request is executed. For the specific functions, please refer to the Step4 step in the method. The application module passes the public interface module of the data layer Access the external system interface and obtain the returned data. The application function module is a well-written PHP application function logic module; the log storage module is used to store the logs generated when the data layer public interface module accesses the external interface. In the PHP environment, the log data adopts a global Accessible PHP array implementation, the PHP array only exists in the memory when the PHP program is executed, after the web page is generated, the life cycle of the PHP process ends, and the PHP array disappears. When adding a log, directly push a unit at the end of the array; the log analysis module uses Read out the log data in the log storage module, analyze and combine them, get the log data of each request and each interface, and analyze the log data, and finally get the analysis report of each interface. For the specific functions, please refer to Step5 in the method Step: The output display module is used to output the original function content and the performance analysis report of each interface in the browser. The output format of the interface performance analysis report is consistent with the original function content format. The specific realized function can refer to Step 6 in the method.

本发明中提到的PHP数组仅仅是在PHP环境中引用时的优选示例,不应作为本发明的限制,当应用在其他web语言环境中时,应适应性地采用其他数组或存储格式进行数据的临时存储。The PHP array mentioned in the present invention is only a preferred example when quoted in the PHP environment, and should not be used as a limitation of the present invention. When applied in other web language environments, other arrays or storage formats should be adaptively used for data storage. temporary storage.

本发明方案所公开的技术手段不仅限于上述实施方式所公开的技术手段,还包括由以上技术特征任意组合所组成的技术方案。应当指出,对于本技术领域的普通技术人员来说,在不脱离本发明原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也视为本发明的保护范围。The technical means disclosed in the solutions of the present invention are not limited to the technical means disclosed in the above embodiments, but also include technical solutions composed of any combination of the above technical features. It should be pointed out that for those skilled in the art, some improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications are also regarded as the protection scope of the present invention.

Claims (10)

1.一种远程实时分析外部系统接口性能的方法,其特征在于,包括如下步骤:1. A method for remote real-time analysis of external system interface performance, characterized in that, comprising the steps: 步骤A,通过浏览器打开远程环境中的待调试网页;Step A, open the webpage to be debugged in the remote environment through a browser; 步骤B,验证当前用户是否有访问权限,只针对有权限的用户进行后续步骤;Step B, verify whether the current user has access rights, and only perform subsequent steps for authorized users; 步骤C,执行当前应用功能逻辑,当执行过程中需要请求外部系统接口时,在执行接口请求前后在内存中存储日志数据,所述日志数据中包括外部系统接口的以下信息:唯一标识、请求的开始时间、请求的结束时间、外部接口描述信息、外部接口状态信息;Step C: Execute the current application function logic. When the external system interface needs to be requested during the execution process, store log data in the memory before and after executing the interface request. The log data includes the following information of the external system interface: unique identifier, requested Start time, end time of request, external interface description information, external interface status information; 步骤D,读取所有日志,根据接口的唯一标识将具有同一标识的日志内容合并到一起,得到不同外部接口的日志记录,根据预先制定的分析规则针对每个外部接口分析性能,得到各外部接口性能分析报告;Step D, read all the logs, merge the log contents with the same identifier according to the unique identifier of the interface to obtain the log records of different external interfaces, analyze the performance of each external interface according to the pre-established analysis rules, and obtain each external interface performance analysis report; 步骤E,在页面上输出应用原本输出的内容,并输出步骤D得到的性能报告。Step E, output the content originally output by the application on the page, and output the performance report obtained in step D. 2.根据权利要求1所述的远程实时分析外部系统接口性能的方法,其特征在于,所述步骤C中请求外部接口过程中包括如下步骤:2. the method for remote real-time analysis external system interface performance according to claim 1, is characterized in that, in the described step C, requesting external interface process comprises the following steps: 步骤C-1,将接口名、接口入参、随机数和/或当前时间进行转换后得到一个字符串,针对该字符串生成有限长度的准唯一标识或唯一标识;Step C-1, convert the interface name, interface input parameters, random number and/or current time to obtain a string, and generate a quasi-unique or unique identifier of limited length for the string; 步骤C-2,将接口名、接口入参进行转换后得到一个字符串,然后与唯一标识一起,按照“唯一标识::描述标识::转换后的描述信息”的格式存储日志;Step C-2, convert the interface name and interface input parameters to obtain a character string, and then store the log together with the unique identifier in the format of "unique identifier::description identifier::converted description information"; 步骤C-3,在开始访问外部接口时,按照“唯一标识::开始标识::当前时间”的格式存储在日志中;Step C-3, when starting to access the external interface, store in the log according to the format of "unique identifier::start identifier::current time"; 步骤C-4,执行接口请求;Step C-4, execute the interface request; 步骤C-5,在外部接口访问结束时,按照“唯一标识::结束标识::当前时间”的格式存储日志;Step C-5, at the end of the external interface access, store the log in the format of "unique identifier::end identifier::current time"; 步骤C-6,将执行接口请求时的状态信息进行转换后得到一个字符串,按照 “唯一标识::状态标识::转换后的状态信息”的格式存储日志。Step C-6: Convert the state information when executing the interface request to obtain a character string, and store the log in the format of "unique identifier::state identifier::converted state information". 3.根据权利要求2所述的远程实时分析外部系统接口性能的方法,其特征在于,所述唯一标识通过以下步骤生成:将接口名、接口入参、随机数和/或当前时间进行转换后得到一个字符串,其后对该字符串生成有限长度的准唯一标识。3. The method for remote real-time analysis of external system interface performance according to claim 2, wherein the unique identifier is generated through the following steps: after converting the interface name, interface input parameter, random number and/or current time Get a string, and then generate a finite-length quasi-unique identifier for the string. 4.根据权利要求2或3所述的远程实时分析外部系统接口性能的方法,其特征在于:所述转换方法为json编码。4. The method for remote real-time analysis of external system interface performance according to claim 2 or 3, characterized in that: the conversion method is json encoding. 5.根据权利要求2或3所述的远程实时分析外部系统接口性能的方法,其特征在于:所述对字符串生成有限长度的准唯一标识的方法为对字符串求md5值。5. according to the method for remote real-time analysis external system interface performance described in claim 2 or 3, it is characterized in that: the method for generating the quasi-unique identification of limited length to character string is to ask md5 value to character string. 6.根据权利要求1所述的远程实时分析外部系统接口性能的方法,其特征在于:所述步骤E中输出的性能报告与原本输出的内容格式相同。6. The method for remote real-time analysis of external system interface performance according to claim 1, characterized in that: the performance report output in the step E is in the same format as the original output content. 7.根据权利要求1所述的远程实时分析外部系统接口性能的方法,其特征在于:所述性能报告包括接口名称、接口入参、接口耗时、接口状态。7. The method for remote real-time analysis of external system interface performance according to claim 1, wherein the performance report includes interface name, interface input parameters, interface time consumption, and interface status. 8.根据权利要求1所述的远程实时分析外部系统接口性能的方法,其特征在于:所述方法通过PHP语言进行应用,在步骤A与步骤C之间还包括如下步骤:进行缓冲,获得PHP输出的所有内容。8. The method for remote real-time analysis of external system interface performance according to claim 1, characterized in that: said method is applied by PHP language, and also includes the following steps between step A and step C: buffering, obtaining PHP Everything that is output. 9.一种远程实时分析外部系统接口性能的系统,其特征在于:包括鉴权模块、数据层公共接口模块、日志存储模块、日志分析模块、输出展示模块,所述鉴权模块用于对用户鉴权,并控制具备权限的用户才能进行访问;所述数据层公共接口模块提供了请求外部系统接口的封装,并在执行接口请求的前后记录请求的开始时间、描述信息、结束时间和状态信息至日志存储模块;所述日志存储模块用于存储数据层公共接口模块访问外部接口时生成的日志;所述日志分析模块用于读出日志存储模块中的日志数据,并进行解析合并后对日志数据进行分析,最终得到各接口分析报告;所述输出展示模块用于在浏览器中输出原功能内容并输出各接口性能分析报告。9. A system for remote real-time analysis of external system interface performance, characterized in that it includes an authentication module, a data layer public interface module, a log storage module, a log analysis module, and an output display module, and the authentication module is used for user Authentication, and only authorized users can access; the data layer public interface module provides the encapsulation of the request external system interface, and records the start time, description information, end time and status information of the request before and after the interface request is executed To the log storage module; the log storage module is used to store the log generated when the data layer public interface module accesses the external interface; the log analysis module is used to read the log data in the log storage module, and analyze the log after merging The data is analyzed to finally obtain the analysis report of each interface; the output display module is used to output the original function content in the browser and output the performance analysis report of each interface. 10.根据权利要求9所述的远程实时分析外部系统接口性能的系统,其特征在于:所述日志存储模块为全局可访问的PHP数组,PHP数组仅在PHP程序执行时存在于内存中,网页生成后消失。10. The system for remote real-time analysis of external system interface performance according to claim 9, characterized in that: the log storage module is a globally accessible PHP array, and the PHP array only exists in the memory when the PHP program is executed. Disappears after spawning.
CN201510090613.3A 2015-02-28 2015-02-28 A kind of method and system of the long-range external system interface performance of analysis in real time Active CN104598348B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510090613.3A CN104598348B (en) 2015-02-28 2015-02-28 A kind of method and system of the long-range external system interface performance of analysis in real time

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510090613.3A CN104598348B (en) 2015-02-28 2015-02-28 A kind of method and system of the long-range external system interface performance of analysis in real time

Publications (2)

Publication Number Publication Date
CN104598348A CN104598348A (en) 2015-05-06
CN104598348B true CN104598348B (en) 2018-07-13

Family

ID=53124161

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510090613.3A Active CN104598348B (en) 2015-02-28 2015-02-28 A kind of method and system of the long-range external system interface performance of analysis in real time

Country Status (1)

Country Link
CN (1) CN104598348B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108509309B (en) * 2018-02-13 2021-09-28 南京途牛科技有限公司 System and method for performing performance monitoring based on access log
CN109344100A (en) * 2018-08-17 2019-02-15 北京奇虎科技有限公司 Method and device for assisting system interface migration
CN109857623A (en) * 2018-12-13 2019-06-07 深圳壹账通智能科技有限公司 Service performance analysis method, device and electronic equipment based on journal file
CN111382017A (en) * 2018-12-28 2020-07-07 北京字节跳动网络技术有限公司 Fault query method, device, server and storage medium
CN110069464A (en) * 2019-03-16 2019-07-30 平安普惠企业管理有限公司 Log analysis processing method, device, equipment and readable storage medium storing program for executing
CN113760692B (en) * 2020-06-23 2025-02-25 北京沃东天骏信息技术有限公司 Log acquisition method, device and equipment
CN115408211A (en) * 2021-05-28 2022-11-29 北京金山云网络技术有限公司 Function test method, device, electronic device and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101242307A (en) * 2008-02-01 2008-08-13 刘峰 Website access analysis system and method based on built-in code proxy log
CN103023710A (en) * 2011-09-21 2013-04-03 阿里巴巴集团控股有限公司 Safety test system and method

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001291003A (en) * 2000-04-06 2001-10-19 Nec Corp Method for imparting privilege by object selection on web page and server for performing the method
WO2010116586A1 (en) * 2009-03-30 2010-10-14 株式会社野村総合研究所 Operation verification device, operation verification method, and operation verification system
CN101645032B (en) * 2009-08-31 2011-08-10 金蝶软件(中国)有限公司 Performance analysis method of application server and application server
JP5483965B2 (en) * 2009-09-14 2014-05-07 株式会社日立製作所 Web application operation recording / reproducing method and system
US8738712B2 (en) * 2009-12-31 2014-05-27 Verizon Patent And Licensing Inc. Method and system for storing and presenting program messages
CN102857387A (en) * 2011-06-30 2013-01-02 北京新媒传信科技有限公司 Online website monitoring system and method
CN103164333B (en) * 2011-12-16 2016-03-16 京信通信系统(中国)有限公司 Embedded device system WEB adjusting, measuring method and system, WEB server
CN103326930B (en) * 2013-06-24 2016-05-25 青岛海信传媒网络技术有限公司 Open platform interface automatic detecting method and system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101242307A (en) * 2008-02-01 2008-08-13 刘峰 Website access analysis system and method based on built-in code proxy log
CN103023710A (en) * 2011-09-21 2013-04-03 阿里巴巴集团控股有限公司 Safety test system and method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
网站可用性的可测性原则与测试方法;李洛 和 黄达峰;《微计算机信息》;20070525;正文第2.3.1节 *

Also Published As

Publication number Publication date
CN104598348A (en) 2015-05-06

Similar Documents

Publication Publication Date Title
CN104598348B (en) A kind of method and system of the long-range external system interface performance of analysis in real time
CN111930365B (en) Qt-based application program rapid development framework, development method and operation method
US9992166B2 (en) Hierarchical rule development and binding for web application server firewall
CN104158836B (en) A kind of method by data render mobile application interface
US9208054B2 (en) Web service for automated cross-browser compatibility checking of web applications
CN111694749A (en) Automatic interface testing method and device, computer equipment and readable storage medium
CN114398673A (en) Application compliance detection method and device, storage medium and electronic equipment
US8930888B2 (en) Modelling serialized object streams
CN113065048B (en) BMC Web automatic detection method, system and medium based on Web crawler
US8914482B2 (en) Translation of technology-agnostic management commands into multiple management protocols
CN111177089B (en) Log processing code generation method and device, computer system and storage medium
CN104965781A (en) Method and apparatus for generating test case
CN114282204A (en) Method, apparatus, device and medium for determining user's permission to access micro-applications
CN114579533A (en) Method, device, electronic device and storage medium for acquiring user activity index
CN105824647A (en) Form page generating method and device
CN111143310B (en) Log recording method and device and readable storage medium
CN112416801B (en) A test system for an in-memory computing engine based on blockchain technology
CN106293862B (en) A kind of analysis method and device of expandable mark language XML data
US9189299B2 (en) Framework for system communication for handling data
CN114398152B (en) Interface simulation service calling method and device
CN117093798A (en) Rendering abnormality detection method and device, electronic equipment and storage medium
CN112380142A (en) Interface document management method and device and test equipment
CN111581173A (en) Distributed storage method and device for log system, server and storage medium
Huy Build and Deply a High-performance full stack JavaScript Web Application
US20250315545A1 (en) Securing End User Access To Application Databases

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant