Summary of the invention
The embodiment of the present application provides the method and device that a kind of interface calls statistics, can be quickly in accurate statistical server
The called number of special interface.
In a first aspect, the embodiment of the present application provides a kind of method that interface calls statistics.This method comprises:
When first server detects that the first application programming api interface is called by system, generates and call described the
The journal file of one api interface, first api interface is one in multiple api interfaces of the first server, described
Journal file includes interface identifier;
First server obtains the first statistics request, and the first statistics request includes that first api interface identifies, the first system
Meter request is used to indicate the number being called to first api interface and counts;
First server is searched and the matched M journal file of mark of the first api interface, M >=1 and be integer;
First server determines the called number of first api interface according to the M journal file.
Implement the embodiment of the present invention, first server detects that api interface is called to generate journal file, to journal file into
Row statistics unites to the API of application program without creating individually detection program so that it is determined that the number that api interface is called
Meter, so as to quickly accurately count the called number of specific api interface.
Optionally, journal file further includes that log generates the time, and the first statistics request further includes statistical time section, institute
State the matched M journal file of mark of first server lookup and first api interface, comprising:
First server determines the mark of first api interface from the corresponding journal file of the multiple api interface
Corresponding N number of journal file, N >=M, and the N are integer;
First server is located in the first statistical time section from N number of journal file lookup log generation time
M journal file.
Specifically, first server is searched from multiple interfaces identifies matched N number of journal file with the first api interface,
This N number of journal file is all journal files generated after the first api interface is called.Then it is looked into from N number of journal file
It looks for and generates the time in M journal file of statistical time section.
Implement the embodiment of the present invention, first server can be across Soviet Union's essence according to statistical time section and api interface mark statistics
The really number that statistics api interface is called in special time period.
Optionally, the statistical time section includes multiple periods;First server is determined according to the M journal file
After the called number of first api interface, further includes:
First server counts first api interface in corresponding called number of the multiple period;
First server is generated according to multiple periods and the first api interface in corresponding called number of multiple periods
Frequency statistics table, the frequency statistics table are used to compare what first api interface was called in correspondence of the multiple period
Number size.
Specifically, first server counts the number that same api interface is called in multiple periods, difference can be compared
Time segment interface is called number size.
Optionally, first server is called according to multiple periods and the first api interface in correspondence of multiple periods
Number generates after frequency statistics table, further includes:
First server counts the number that the second api interface is called in the multiple period;
The number and described second that first server is called according to first api interface in the multiple period
Api interface generates interface contrast table in the number that the multiple period is called, and the interface contrast table is for comparing first
The number size that api interface and the second api interface are called in the same period.
Optionally, first server obtains the journal file that second server is sent, and the journal file is described second
The journal file generated after multiple api interfaces of server are called, the first server and the second server are same
Server in one server cluster;
First server obtains the second statistics request, and the second statistics request is used to indicate the second api interface of statistics and exists
The total degree being called in the server cluster;
First server is searched and second api interface from the journal file of storage according to the second request statistics
The Q journal file of mark matching and generation time in the second statistical time section, the journal file of the storage include
The journal file that the journal file and the first server that the second server is sent generate, the Q >=M and be integer;
First server determines second api interface quilt in the server cluster according to the Q journal file
The total degree of calling.
Specifically, including multiple servers in server cluster, first server receives each service in server cluster
The journal file that device is sent.When need a certain server statistics some api interface from server cluster in the cluster by
The total degree of calling needs institute's Servers-all in statistical server cluster to generate the journal file for calling the api interface, then
The called total degree of the api interface is counted according to all journal files.
Implement the embodiment of the present invention, the journal file that server is sent according to other servers in husband's server cluster can
Quickly accurately to count the total degree that specific api interface is called in server cluster.
Optionally, after the journal file that first server acquisition second server is sent, further includes:
First server carries out signature to the journal file that the second server is sent, after obtaining signature
Journal file, it is that the second server is sent that the signature, which is used to indicate the journal file,;
First server stores the journal file after the signature to data space.
Specifically, first server obtains the log text that multiple server calls api interfaces in server cluster generate
Part, it is therefore desirable to signature be carried out to the journal file of acquisition, the corresponding server of journal file is sent for characterizing, be convenient for
Later period counts the total degree that API is called in each server.
Second aspect, the embodiment of the present application provide the device that a kind of interface calls statistics, comprising:
First generation unit, for generating and calling when detecting that the first application programming api interface is called by system
The journal file of first api interface, first api interface are one in multiple api interfaces of first server, institute
Stating journal file includes interface identifier;
First acquisition unit, for obtaining the first statistics request, the first statistics request includes first api interface
Mark, the first statistics request are used to indicate the number being called to first api interface and count;
First searching unit, for search with the matched M journal file of the mark of first api interface, the M >=
1 and be integer;
First determination unit, for determining the called number of first api interface according to the M journal file.
Optionally, the journal file further includes that log generates the time, and the first statistics request further includes the first statistics
Period, first searching unit include:
Second determination unit, for determining first api interface from the corresponding journal file of the multiple api interface
The corresponding N number of journal file of mark, N >=M, and the N be integer;
Second searching unit generates the time positioned at first system for searching the log from N number of journal file
Count M journal file in the period.
The first statistical time section includes multiple periods, described device further include:
Statistic unit, for counting first api interface in corresponding called number of the multiple period;
Second generation unit was used for according to the multiple period and first api interface in the multiple period pair
The number that should be called generates frequency statistics table, and the frequency statistics table is for comparing first api interface the multiple
Period corresponding called number size.
Optionally, the device further include:
Second acquisition unit, for obtaining the journal file of second server transmission, the journal file is described second
The journal file generated after multiple api interfaces of server are called, the first server and the second server are same
Server in one server cluster;
Third acquiring unit, for obtaining the second statistics request, the second statistics request is used to indicate the 2nd API of statistics
The total degree that interface is called in the server cluster, the second statistics request are used to indicate the second api interface of statistics
The total degree being called in the server cluster;
Third determination unit, for being searched and described second from the journal file of storage according to the second request statistics
The Q journal file of the matching of api interface mark and generation time in the second statistical time section, the log text of the storage
Part includes the journal file that the second server is sent and the journal file that the first server generates, and the Q >=M and is
Integer;
4th determination unit, for determining second api interface in the server set according to the Q journal file
The total degree being called in group.
Optionally, the device further include:
Marking unit, for after the journal file that the second acquisition unit obtains that the second server is sent,
Signature is carried out to the journal file, the journal file after obtaining signature, the signature is used to indicate described
Journal file is that the second server is sent;
Storage unit, for storing the journal file after the signature to data space.
The third aspect, the embodiment of the present application provide a kind of server, call for executing the provided interface of first aspect
The method of statistics.The server can include: processor, communication interface and memory, processor, communication interface and memory are mutual
Connection.Wherein, communication interface with other network equipments (such as terminal) for being communicated, and memory is for storing first aspect
The realization code for the method that provided maintenance program provides, processor is for executing the program code stored in memory, i.e.,
Execute the method that interface provided by first aspect calls statistics.
Fourth aspect, the embodiment of the present application provide a kind of computer readable storage medium, are stored on readable storage medium storing program for executing
Instruction, when it runs on a processor, so that processor executes the method that the interface of above-mentioned first aspect description calls statistics.
5th aspect, the embodiment of the present application provides a kind of computer program product comprising instruction, when it is in processor
When upper operation, so that processor executes the method that the interface of above-mentioned second aspect description calls statistics.
Specific embodiment
The embodiment of the present application provides the method and device that a kind of interface calls, can be quickly specific in accurate statistical server
The called number of interface.
In the description of this specification, reference term " one embodiment ", " some embodiments ", " example ", " specifically show
The description of example " or " some examples " etc. means specific features, structure, material or spy described in conjunction with this embodiment or example
Point is included at least one embodiment or example of the invention.In the present specification, schematic expression of the above terms are not
It must be directed to identical embodiment or example.Moreover, particular features, structures, materials, or characteristics described can be in office
It can be combined in any suitable manner in one or more embodiment or examples.In addition, without conflicting with each other, the skill of this field
Art personnel can tie the feature of different embodiments or examples described in this specification and different embodiments or examples
It closes and combines.
The term " includes " and " having " and their any changes occurred in present specification, claims and attached drawing
Shape, it is intended that cover and non-exclusive include.Such as contain the process, method of a series of steps or units, system, product or
Equipment is not limited to listed step or unit, but optionally further comprising the step of not listing or unit or optional
Ground further includes the other step or units intrinsic for these process, methods, product or equipment.In addition, term " first ", " the
Two " and " third " etc. are and to be not intended to describe specific sequence for distinguishing different objects.Below in conjunction with of the invention real
The attached drawing in example is applied, technical solution in the embodiment of the present invention is described.
Referring to Figure 1, Fig. 1 be the invention relates to a kind of communication system configuration diagram, the communication system
Including server cluster and terminal.It include multiple servers in server cluster, the embodiment of the present invention is for ease of description to take
It is illustrated for first server and second server in business device cluster.The terminal referred in the embodiment of the present application is for example
It can be mobile phone, tablet computer, laptop, palm PC, mobile internet device or other mobile terminals.
Api interface in first server detection service device is called, generates the journal file of calling interface.First service
Device obtains the statistics request for target api interface call number, and the mode of acquisition can be to be obtained from terminal, is also possible to straight
It obtains and takes.First server searches the journal file of invocation target api interface generation from data space, according to what is found
Journal file determines the called number of target api interface.
Multiple servers (such as first server) in server cluster send journal file to first server, are used for
First server counts the total degree that target api interface is called in server cluster.
Fig. 2 is referred to, Fig. 2 shows a kind of server provided by the embodiments of the present application, the servers 200 can include: deposit
Reservoir 201, communication interface 202 and one or more processors 203.These components can be connected by bus 204 or other modes
It connects, Fig. 2 by bus for being connected.Wherein:
Memory 201 can be coupled with processor 203 by bus 204 or input/output port, and memory 201 can also
To be integrated with processor 203.Memory 201 is for storing various software programs and/or multiple groups instruction.Specifically, depositing
Reservoir 201 may include the memory of high random access, and may also comprise nonvolatile memory, such as one or more magnetic
Disk storage device, flash memory device or other non-volatile solid-state memory devices.Memory 201 can also store network communication journey
Sequence, the network communication program can be used for and one or more optional equipments, one or more terminals, one or more network equipments
It is communicated.
Processor 203 can be general processor, such as central processing unit (central processing unit,
CPU), it can also be digital signal processor (digital signal processing, DSP), specific integrated circuit
(application specific integrated circuit, ASIC), or be arranged to implement the embodiment of the present application
One or more integrated circuits.Processor 203 can handle the data received by communication interface 202.
Communication interface 202 is communicated for server 200 with other network equipments, such as terminal is communicated.Communication
Interface 202 can be transceiver, transmission circuit etc., wherein communication interface is to be referred to as, and may include one or more interfaces, example
Such as the interface between terminal and server.Communication interface 202 may include wireline interface and wireless interface, such as standard interface,
Ethernet, Multi-Machine Synchronous interface.
Processor 203 can be used for reading and executing computer-readable instruction.It is deposited specifically, processor 203 can be used for calling
The data being stored in memory 201.Optionally, when processor 203 sends any message or data, especially by driving or
Control communication interface 202 does the transmission.Optionally, when processor 203 receives any message or data, especially by drive
Dynamic or control communication interface 202 does the reception.Therefore, processor 203 can be considered to be the control for executing and sending or receiving
Center, communication interface 202 are to send and receive the specific actor of operation.
In the embodiment of the present application, communication interface 202 is specifically used for executing the receipts of data involved in following methods embodiment
The step of hair, processor 203 are specifically used for the step of implementing the data processing in addition to data transmit-receive.It should be noted that clothes
The structure of business device 200 can be the structure of any server in first server or server cluster.
Server as shown in connection with fig. 2, the embodiment of the present application provide a kind of method that interface calls statistics, referring to Fig. 3,
Fig. 3 is the flow diagram for the method that a kind of interface that one embodiment of the application provides calls statistics.Wherein, such as Fig. 3 institute
Show, a kind of interface calling statistical method that one embodiment of the application provides may include:
S301: it when first server detects that the first application programming api interface is called by system, generates and calls first
The journal file of api interface, the first api interface are one in multiple api interfaces of the first server, journal file packet
Include interface identifier.
Optionally, journal file further includes that log generates the time, and the log generation time is used to indicate what api interface was called
Time.
Specifically, first server includes multiple api interfaces, each api interface has corresponding interface identifier.When the first clothes
Business device detects that a certain api interface is called, generates the corresponding journal file of the api interface, journal file includes log
Time and interface identifier are generated, the api interface called time can be characterized.
S302: first server obtains the first statistics request, and the first statistics request includes that the first api interface identifies, and first
Statistics request is used to indicate the number being called to the first api interface and counts.
Optionally, the mode of the first statistics of acquisition request can be a variety of, can be first server and is obtained by terminal
Take be also possible to first server directly acquire the first statistics request.
S303: first server is searched and the matched M journal file of mark of the first api interface, M >=1 and be integer.
Optionally, first statistics request include the first statistical time section, first server according to the first api interface identify from
Multiple api interfaces of the first server determine that N number of journal file, N >=M, and the N are integer;
First server searches the log from N number of journal file and generates M of the time in the first statistical time section
A journal file.
Specifically, first server calls the first API to connect according to the first api interface identifier lookup in the first statistics request
N (such as 256) a journal file of mouth, N number of journal file include the journal file that any time calls the first api interface.So
Afterwards according to the statistical time section in the first statistics request, such as on December 12nd, 2018, it is raw that first server searches journal file
At M (such as 50) a journal file of time on December 12nd, 2018.
S304: first server determines the called number of the first api interface according to M journal file.
Specifically, if the M journal file that first server obtains is 50 journal files, first server judgement the
The called number of one api interface is 50.
Optionally, the first statistical time section includes multiple periods, and first server is determined according to the M journal file
After the called number of first api interface, further includes:
First server counts the first api interface in corresponding called number of the multiple period;
First server is generated according to multiple periods and the first api interface in corresponding called number of multiple periods
Frequency statistics table.
Optionally, frequency statistics table is used to compare the first api interface in corresponding called number of the multiple period
Size.First server counts the number that same api interface is called in multiple periods, can compare different time segment interface
Called number size.The content of the frequency statistics table of first api interface can be such as, but not limited to as shown in table 1:
Table 1
Optionally, first server is called according to multiple periods and the first api interface in correspondence of multiple periods
Number generates after frequency statistics table, further includes:
First server counts the number that the second api interface is called in the multiple period;
The number and described second that first server is called according to first api interface in the multiple period
Api interface generates interface contrast table in the number that the multiple period is called.
Specifically, interface contrast table is used to compare what the first api interface and the second api interface were called in the same period
Number size.The content of interface contrast table can be such as, but not limited to as shown in table 2:
Table 2
Statistical time section |
First api interface is called number |
Second api interface is called number |
2018-1-1 9:00-11:00 |
256 |
313 |
2018-1-1 11:00-13:00 |
355 |
369 |
2018-1-1 13:00-15:00 |
479 |
452 |
…… |
…… |
…… |
Optionally, first server is a server in server cluster, and server cluster includes multiple servers,
Such as second server.Referring to fig. 4, Fig. 4 is to apply for that another interface that embodiment provides calls the process of statistical method to illustrate
Figure, as shown in figure 4, a kind of interface calling statistical method that one embodiment of the application provides may include:
S401: first server obtains the journal file that second server is sent, and first server and second server are
Server in same cluster.
Optionally, the file journalization that first server is sent is to generate after multiple api interfaces of second server are called
Journal file, first server receives the journal file that multiple servers are sent in server cluster.
Optionally, first server obtains in server cluster after the journal file of multiple servers transmissions, further includes:
First server carries out signature to the journal file that second server is sent, the log after obtaining signature
File, it is that the second server is sent that signature, which is used to indicate the journal file,;
First server stores the journal file after the signature to data space.
Optionally, signature can be physical address, IP address or other characteristic characters of second server, the application
It does not limit this.
Specifically, first server obtains the log text that multiple server calls api interfaces in server cluster generate
Part, it is therefore desirable to signature be carried out to the journal file of acquisition, the corresponding server of journal file is sent for characterizing, be convenient for
Later period counts the total degree that API is called in each server.
S402: first server obtains the second statistics request, and the second statistics request is used to indicate the second api interface of statistics and exists
The total degree being called in the server cluster.
Specifically, time that first statistics request special interface on individual server in statistical server cluster is called
Number, second statistics request called number of special interface on Servers-all in statistical server cluster.
S403: first server is searched and the second api interface mark from the journal file of storage according to the second statistics request
Know matching and generates Q journal file of the time in the second statistical time section.
Specifically, first service refers to above-mentioned steps according to the method that corresponding journal file is searched in the second statistics request
S303, details are not described herein again.
S404: first server determines that the second api interface is called total in server cluster according to Q journal file
Number.
Optionally, first server is according to the signature of Q journal file, to the server for sending Q journal file
It is recognized, generates the second api interface call number statistical form.For example, having three servers in server cluster is respectively
One server, second server and third server, the second api interface are called in this day of 2018-1-1 in server cluster
Number is 14015, wherein the second api interface is 4134 in the number that first server is called, it is called in second server
Number be 4345, third server be called number be 5536.For example, the second api interface call number statistical form can
With such as, but not limited to as shown in table 3:
Table 3
Show referring to Fig. 5, Fig. 5 and give a kind of structural schematic diagram of device that maintenance program is recommended, as shown in figure 5, the dimension
The device 500 for repairing scheme offer includes: the first generation unit 501, first acquisition unit 502, the first searching unit 503 and first
Determination unit 504.
Wherein, the first generation unit 501, for when detecting that the first application programming api interface is called by system,
The journal file for calling first api interface is generated, first api interface is in multiple api interfaces of first server
One, the journal file includes interface identifier;First acquisition unit 502 is requested, described first for obtaining the first statistics
Statistics request includes that first api interface identifies, and the first statistics request, which is used to indicate, adjusts first api interface
Number is counted;First searching unit 503, for searching and the matched M log of the mark of first api interface
File, M >=1 and be integer;First determination unit 504, for determining the first API according to the M journal file
The called number of interface.
Optionally, the journal file further includes that log generates the time, and the first statistics request further includes the first statistics
Period, first searching unit include:
Second determination unit, for multiple api interfaces according to first api interface mark from the first server
Determine that N number of journal file, N >=M, and the N are integer;
Second searching unit generates the time in first statistics for searching the log from N number of journal file
M journal file in period.
The first statistical time section includes multiple periods, described device further include:
Statistic unit, for counting first api interface in corresponding called number of the multiple period;
Second generation unit was used for according to the multiple period and first api interface in the multiple period pair
The number that should be called generates frequency statistics table, and the frequency statistics table is for comparing first api interface the multiple
Period corresponding called number size.
Optionally, the device further include:
Second acquisition unit, for obtaining the journal file of second server transmission, the journal file is described second
The journal file generated after multiple api interfaces of server are called, the first server and the second server are same
Server in one server cluster;
Third acquiring unit, for obtaining the second statistics request, the second statistics request is used to indicate the 2nd API of statistics
The total degree that interface is called in the server cluster, the second statistics request are used to indicate the second api interface of statistics
The total degree being called in the server cluster;
Third determination unit, for being searched and described second from the journal file of storage according to the second request statistics
The Q journal file of the matching of api interface mark and generation time in the second statistical time section, the log text of the storage
Part includes the journal file that the second server is sent and the journal file that the first server generates, and the Q >=M and is
Integer;
4th determination unit, for determining second api interface in the server set according to the Q journal file
The total degree being called in group.
Optionally, the device further include:
Marking unit, for after the journal file that the second acquisition unit obtains that the second server is sent,
Signature is carried out to the journal file, the journal file after obtaining signature, the signature is used to indicate described
Journal file is that the second server is sent;
Storage unit, for storing the journal file after the signature to data space.
A kind of computer readable storage medium, the computer-readable storage medium are provided in another embodiment of the application
Matter is stored with computer program, and the computer program includes program instruction, realization when described program instruction is executed by processor.
If the integrated unit is realized in the form of SFU software functional unit and sells or use as independent product
When, it can store in a computer readable storage medium.Based on this understanding, technical solution of the present invention is substantially
The all or part of the part that contributes to existing technology or the technical solution can be in the form of software products in other words
It embodies, which is stored in a storage medium, including some instructions are used so that a computer
Equipment (can be personal computer, server or the network equipment etc.) executes the complete of each embodiment the method for the application
Portion or part steps.And storage medium above-mentioned include: USB flash disk, mobile hard disk, read-only memory (read-only memory,
ROM), random access memory (random access memory, RAM), magnetic or disk etc. are various can store program
The medium of code.
In the above-described embodiments, can come wholly or partly by software, hardware, firmware or any combination thereof real
It is existing.When implemented in software, it can entirely or partly realize in the form of a computer program product.The computer program
Product includes one or more computer instructions.When loading on computers and executing the computer program instructions, all or
It partly generates according to process or function described in the embodiment of the present application.The computer can be general purpose computer, dedicated meter
Calculation machine, computer network or other programmable devices.The computer instruction can store in computer readable storage medium
In, or from a computer readable storage medium to the transmission of another computer readable storage medium, for example, the computer
Instruction can pass through wired (such as coaxial cable, optical fiber, number from a web-site, computer, server or data center
User's line (digital subscriber line, DSL) or wireless (such as infrared, wireless, microwave etc.) mode are to another net
Website, computer, server or data center are transmitted.The computer readable storage medium can be computer can
Any usable medium of access either includes the data storage such as one or more usable mediums integrated server, data center
Equipment.The usable medium can be magnetic medium, (for example, floppy disk, hard disk, tape), optical medium (such as digital multi light
Disk (digital versatile disc, DVD), semiconductor medium (such as solid state hard disk solid state disk, SSD)
Deng.
Above-described specific embodiment carries out the purpose of the embodiment of the present invention, technical scheme and beneficial effects
It is further described, it should be understood that the foregoing is merely the specific embodiments of the embodiment of the present invention, and does not have to
In limit the embodiment of the present invention protection scope, it is all on the basis of the technical solution of the embodiment of the present invention, done it is any
Modification, equivalent replacement, improvement etc. should all include within the protection scope of the embodiment of the present invention.