In specific implementation, the codes dynamic monitor mode such as preferable BTrace, byteman or javaagent, in order to
The pre-set code is injected to application business system.Here AOP (Aspect Oriented is injected in a manner of BTrace
Programming, towards tangent plane programming) mode carries out code injection explanation, and injecting principle is as shown in figure 3, be related to script, tracking
Client (btrace-client) and distal end (remote).Wherein, the pre-set code is write completion for developer by script
Btrace script script file, for example be named as script.java script file;Btrace-client is used
The native virtual machine of local API (Application Programming Interface) starting of btrace, such as using bin/btrace in local boot
One btrace jvm (Java Virtual Machine, Java Virtual Machine), is formed in virtual machine internal in this way
Complier (compiler), Vm (virtual machine) and a local socket;Tracking agent (btrace-agent) is remote
In virtual protocol.In this way, dynamically script file is compiled automatically in generation by the compiler in btrace-client
Interim class file in depositing, then by Vm dynamically by the jvm of class file attach to distal end (java virtual machine), so
Deactivation btrace-agent afterwards, i.e., the btrace-agent being implanted on target jvm, i.e. by asm and instrument
It may be implemented in the local injecting codes of the beginning and end of each function call in remote, wherein asm is a global function
Java bytecode operation and analytical framework, instrument is for constructing a broker program independently of application program
(Agent), for monitoring and assist to operate in the program on jvm.In addition, btrace-agent passes through starting one
Seversocket is communicated with the local socket of btrace-client, for example btrace-client is by the class of monitoring
File is sent to btrace-agent, can also be when jvm starts by communicating directly specified corresponding local monitoring class text
Part will need the information back printed to print to btrace-client to realize as monitoring script, btrace-agent
It collecting and calls log, btrace-agent can traverse current all class classes loaded after receiving monitoring instruction,
It is checked one by one, and generates corresponding monitoring bytecode (i.e. monitoring method) to realize that injection is monitored.
By code injection, so that the application business system each of will be called in handling the service request
The executive condition of function and the function, which generates, calls log, wherein the calling log carrys out Series Sheet with TraceID above-mentioned
All calling of secondary applied business record.
It should be noted that the calling log can be by concrete scene needs come according to the corresponding pre-set code of scene
It generates and returns.
In one preferred embodiment, when scene needs to go out deeper calling according to the calling log acquisition
When situation, for example, the ability for needing callee to have identifying call person, in the case where same parameter, a method is by class A's
1 is returned when m1 method call, returns to 0 in the m2 method call of class B, it is necessary to which the calling log includes the tune of the function
With stack information, at this moment, the code that will can be used to monitor the stack information of called function is arranged in the pre-set code, than
Such as, the code of current allocating stack information is obtained using Throwable.
In another preferred embodiment, when scene needs the service request according to the calling log acquisition
When rough call relation, it is necessary to the calling log includes the calling station of the corresponding each function of the service request, this
When, the code that will be used to monitor the calling station of called function is arranged in the pre-set code, wherein the calling station
It may include calling starting position and the calling end position of the function, the calling end position of the function may include having executed
At, return (return), throw abnormal three kinds of situations.
In another preferred embodiment, when scene needs the service request according to the calling log acquisition
Process performance, such as when the execution time, it is necessary to the calling log includes the tune of the corresponding each function of the service request
With position, allocating time, the information such as time are executed, at this moment, by the recalls information for being used to monitor called function, executes the time
Code is arranged in the pre-set code, and wherein recalls information may include the calling station of function and the time of the calling station
Stamp, and then can be obtained out by the timestamp and execute the time, wherein the calling that the calling station includes the function starts
Position and calling end position, the calling end position of the function may include executing completion, return (return), throwing abnormal three
Kind situation.
In another preferred embodiment, when scene need it is deeper out according to the calling log acquisition,
When having the allocating stack of nest relation, for example need to restore allocating stack, or needing to identify asynchronous call, it is necessary to described
Calling log includes the thread identification of the function, and wherein thread identification includes father's thread identification and own thread mark, i.e. line
Journey mark includes that first thread mark and the second thread identification, the first thread identify father's line for identifying the function
At this moment journey, the own thread that second thread identification is used to identify the function will can be used to monitor the function of each calling
Thread identification code be arranged in the pre-set code.
In specific implementation, it can be communicated by aforementioned socket and complete the collection for calling log.
Step S106, the set membership of each function is determined according to the calling log.
In the present embodiment, the calling log contains the recalls information of the corresponding each function of the service request, from
And the set membership between function and function can be determined according to the recalls information for being included.
In one preferred embodiment, when the calling log includes the allocating stack information of the function,
Wherein Throwable above-mentioned can be used to be obtained for the allocating stack information of each function, the allocating stack information obtained out
Result schematic diagram as shown in figure 5, at this moment just would know that each function from the prefix relationship of allocating stack information obtained
Set membership.It therefore, can be according to the calling heap when determining the set membership of each function according to the calling log
Stack information determines the set membership of each function, i.e., is determined by the prefix matching relationship of the allocating stack information
The set membership of function.
In another preferred embodiment, when the calling log includes the calling station of the function, i.e. institute
Stating and calling log includes position and function position calling after of the function before calling, due to the tune of subfunction
With starting position to the calling starting position to the period called between end position for calling end position to be respectively positioned on father's function
It is interior, when at this moment determining the set membership of each function according to the calling log, it can be determined according to the calling station
The set membership of each function.
In another preferred embodiment, when the calling log includes the calling station of the function and described
When the timestamp of calling station, the set membership of function can more acurrate by timestamp, be quickly determined, wherein the time
Stamp is the time for currently printing the log of the calling station.Specifically, each letter is being determined according to the calling log
When several set memberships, first the calling station in the calling log can be ranked up according to the timestamp, then
The set membership of each function is determined according to the calling station after the sequence.
In one preferred embodiment, when there are asynchronous call, its thread identification when due to function asynchronous call
(i.e. Thread Id) is different, so as to distinguish the branch of asynchronous call by thread identification, and then according to the level of thread identification
Relationship determines the call-tree in same thread, that is, determines the set membership of same thread inner function.Specifically, when the tune
It include first thread mark and when the second thread identification with log, wherein first thread mark is for identifying the function
Father's thread, second thread identification is used to identify the own thread of the function, at this moment according to callings log determination
When the set membership of each function, it can be identified according to the first thread and second thread identification is from the calling day
The set membership of each function is determined in will.
It should be noted that described call included in log for characterizing the recalls information of called function, can wrap
Include the timestamp and the thread mark of the allocating stack information above-mentioned, the calling station of the function, the calling station
One or more of knowledge, also each recalls information use priority can be preset according to actual needs.
In one preferred embodiment, when the calling log includes the allocating stack information, the function
Calling station, the calling station timestamp and the thread identification, each institute is at this moment determined according to the calling log
When stating the set membership of function, matching process as shown in FIG. 6 can be used, i.e., first match the log before and after function call, so
The set membership of function call is matched afterwards, and the call-tree of asynchronous thread is subsequently matched according to thread identification, is finally determined
The set membership of all functions out, specifically, according to timestamp ordering, the function tune parsed according to allocating stack information
Log with information, before the calling to match each function and after calling;Then function is determined according to the log matched
Set membership;The call-tree in same thread is also subsequently determined by thread identification, that is, determines the call-tree of asynchronous thread,
Finally determine the set membership of all functions.Wherein, following four can be used in the set membership for determining function to sentence
Disconnected rule: a) there is the TraceID of the function of set membership consistent;If b) aiming at the day of a function printing start and ending node
Between, the beginning and end node of the log of another function is also had printed, then there are set memberships for the two functions;If c) adjusting
There is prefix matching relationship with stack information, then there is set membership;If d) having father's thread identification and own thread mark, father
The function of function and the own thread mark of thread identification has set membership.
Step S108, the corresponding calling link of the link identification is generated according to the set membership.
After obtaining the set membership, that is, the calling hierarchical relationship between function is obtained, it can be according to calling hierarchical relationship
Call-tree is generated, thus using the call-tree as the calling link of the link identification (i.e. TraceID).
It is different from static parsing, S102~108 through the above steps, due to being dynamically to be injected into the pre-set code
In application business system in production environment, to operation system without invasive, by collecting application business system according to
The calling log of the corresponding each function of the service request that pre-set code is generated and returned can get in most true system
Function call situation, it is ensured that the accuracy of link.
In one preferred embodiment, in order to facilitate customer analysis, the understanding executive condition for calling link, also
The call parameters of each function in the calling link can be counted, wherein call parameters may include indicating call chain
The essential information on road, for example, method of calling: far call (RPC, Remote Procedure Call Protocol), process
Between call;Call parameters may also include the multidate information for indicating to call link, for example, calling time of origin, calling time-consuming, call
Source-information etc..According to the call parameters of statistics, developer can carry out accident analysis, positioning and exclusion on line, may be used also
With between system link parsing is combined, construct the link calling figure that method rank is accurate under SOA (service-oriented) framework, survey
Examination personnel, which can carry out validity and change, influences surface analysis.
In one preferred embodiment, in order to facilitate user query, analysis, the calling link can also be stored
In database.When it is implemented, key-value also can be used to data storage is carried out, wherein key value can be above-mentioned
TraceID, value value can be the calling link.
In one preferred embodiment, the calling link is browsed for the ease of user, it can also be by the call chain
Road is shown by way of illustration.In specific implementation, it can call(a kind of skin mode, can be in subsystem for interface
All kinds of (or structure and methods) provides a consistent interface of simplicity, hides the complexity of subsystem, is more easier subsystem
Using) be shown the calling link, the schematic diagram of result is shown as shown in fig. 7, personnel newly developed in this way can pass through institute
The calling link of displaying can intuitively understand the operation logic of application business system.
Based on the same inventive concept, a kind of calling link construction device is provided in this specification embodiment.
It should be noted that detailed description is had been carried out to the calling link construction method in view of in previous embodiment,
Corresponding contents involved in the calling link construction device will not be described in great detail in the present embodiment.
As shown in figure 8, wherein dashed rectangle indicates optional module, the calling link construction device includes injection module
10, collection module 20, determining module 30 and generation module 40.Wherein, injection module 10 is used for service request is corresponding default
To application business system, the pre-set code returns in operation for the application business system and handles the clothes code injection
The calling log of each function called when business request, the calling log includes link identification;Collection module 20 is for receiving
Collect the calling log;Determining module 30 is used to determine the set membership of each function according to the calling log;It generates
Module 40 is used to generate the corresponding calling link of the link identification according to the set membership.
Optionally, injection module 10 is for the corresponding pre-set code of service request to be injected into described in application business system
The execution starting position of the corresponding each function of service request and execution end position.
Optionally, the calling log further includes the allocating stack information of the function, and at this moment determining module 30 is used for root
The set membership of each function is determined according to the allocating stack information.
Optionally, the calling log further includes the calling station of the function, and at this moment determining module 30 is used for according to institute
State the set membership that calling station determines each function.
Optionally, the calling log further includes the timestamp of the calling station, at this moment the calling link building dress
Setting further includes sorting module 50.Wherein sorting module 50 is used for according to the timestamp to the calling in the calling log
Position is ranked up;Determining module 30 is used to determine that the father and son of each function is closed according to the calling log after the sequence
System.
Optionally, the time precision of the timestamp includes the time precision of 1 nanosecond.
Optionally, the calling log further includes first thread mark and the second thread identification, the first thread mark
For identifying father's thread of each function, second thread identification is used to identify the own thread of the function, at this moment
The determining module is used for according to first thread mark and second thread identification from the calling log after the sequence
The set membership of the middle each function of determination.
Optionally, the calling link construction device further includes statistical module 60, and wherein statistical module 60 is for counting institute
State the call parameters for calling each function in link.
Optionally, the calling link construction device further includes memory module 70, and wherein memory module 70 will be for will be described
Link is called to be stored in database.
Optionally, the calling link construction device further includes display module 80, and wherein display module 80 is for showing institute
State calling link.
Based on the same inventive concept, this specification embodiment provides a kind of corresponding with the calling link construction method
Link is called to construct equipment, the electronic equipment includes: at least one processor;And it is logical at least one described processor
Believe the memory of connection;Wherein, the memory is stored with the instruction that can be executed by least one described processor, described instruction
It is executed by least one described processor, so that at least one described processor is able to carry out following steps:
The corresponding pre-set code of service request is injected into application business system, the pre-set code applies industry for described
Business system returns to the calling log of each function called when handling the service request, the calling log packet in operation
Link identification is included, the link identification is for service request described in overall identification;
Collect the calling log;
The set membership of each function is determined according to the calling log;
The corresponding calling link of the link identification is generated according to the set membership.
Based on same thinking, this specification embodiment provides a kind of corresponding with the calling link construction method non-easy
The property lost computer storage medium is stored with computer executable instructions, the computer executable instructions setting are as follows:
The corresponding pre-set code of service request is injected into application business system, the pre-set code applies industry for described
Business system returns to the calling log of each function called when handling the service request, the calling log packet in operation
Link identification is included, the link identification is for service request described in overall identification;
Collect the calling log;
The set membership of each function is determined according to the calling log;
The corresponding calling link of the link identification is generated according to the set membership.
It is above-mentioned that this specification specific embodiment is described.Other embodiments are in the scope of the appended claims
It is interior.In some cases, the movement recorded in detail in the claims or step can be come according to the sequence being different from embodiment
It executes and desired result still may be implemented.In addition, process depicted in the drawing not necessarily require show it is specific suitable
Sequence or consecutive order are just able to achieve desired result.In some embodiments, multitasking and parallel processing be also can
With or may be advantageous.
All the embodiments in this specification are described in a progressive manner, same and similar portion between each embodiment
Dividing may refer to each other, and each embodiment focuses on the differences from other embodiments.Especially for device,
For equipment, nonvolatile computer storage media embodiment, since it is substantially similar to the method embodiment, so the ratio of description
Relatively simple, the relevent part can refer to the partial explaination of embodiments of method.
Each embodiment in the present specification, it should be appreciated by those skilled in the art " first " and "
Two " do not have practical limiting meaning, only to facilitate distinguishing, prevent confusion of concepts.
Device that this specification embodiment provides, equipment, nonvolatile computer storage media with method be it is corresponding, because
This, device, equipment, nonvolatile computer storage media also have the advantageous effects similar with corresponding method, due to upper
Face is described in detail the advantageous effects of method, therefore, which is not described herein again corresponding intrument, equipment, it is non-easily
The advantageous effects of the property lost computer storage medium.
In the 1990s, the improvement of a technology can be distinguished clearly be on hardware improvement (for example,
Improvement to circuit structures such as diode, transistor, switches) or software on improvement (improvement for method flow).So
And with the development of technology, the improvement of current many method flows can be considered as directly improving for hardware circuit.
Designer nearly all obtains corresponding hardware circuit by the way that improved method flow to be programmed into hardware circuit.Cause
This, it cannot be said that the improvement of a method flow cannot be realized with hardware entities module.For example, programmable logic device
(Programmable Logic Device, PLD) (such as field programmable gate array (Field Programmable Gate
Array, FPGA)) it is exactly such a integrated circuit, logic function determines device programming by user.By designer
Voluntarily programming comes a digital display circuit " integrated " on a piece of PLD, designs and makes without asking chip maker
Dedicated IC chip.Moreover, nowadays, substitution manually makes IC chip, this programming is also used instead mostly " is patrolled
Volume compiler (logic compiler) " software realizes that software compiler used is similar when it writes with program development,
And the source code before compiling also write by handy specific programming language, this is referred to as hardware description language
(Hardware Description Language, HDL), and HDL is also not only a kind of, but there are many kind, such as ABEL
(Advanced Boolean Expression Language)、AHDL(Altera Hardware Description
Language)、Confluence、CUPL(Cornell University Programming Language)、HDCal、JHDL
(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL(Ruby
Hardware Description Language) etc., VHDL (Very-High-Speed is most generally used at present
Integrated Circuit Hardware Description Language) and Verilog.Those skilled in the art also answer
This understands, it is only necessary to method flow slightly programming in logic and is programmed into integrated circuit with above-mentioned several hardware description languages,
The hardware circuit for realizing the logical method process can be readily available.
Controller can be implemented in any suitable manner, for example, controller can take such as microprocessor or processing
The computer for the computer readable program code (such as software or firmware) that device and storage can be executed by (micro-) processor can
Read medium, logic gate, switch, specific integrated circuit (Application Specific Integrated Circuit,
ASIC), the form of programmable logic controller (PLC) and insertion microcontroller, the example of controller includes but is not limited to following microcontroller
Device: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20 and Silicone Labs C8051F320 are deposited
Memory controller is also implemented as a part of the control logic of memory.It is also known in the art that in addition to
Pure computer readable program code mode is realized other than controller, can be made completely by the way that method and step is carried out programming in logic
Controller is obtained to come in fact in the form of logic gate, switch, specific integrated circuit, programmable logic controller (PLC) and insertion microcontroller etc.
Existing identical function.Therefore this controller is considered a kind of hardware component, and to including for realizing various in it
The device of function can also be considered as the structure in hardware component.Or even, it can will be regarded for realizing the device of various functions
For either the software module of implementation method can be the structure in hardware component again.
System, device, module or the unit that above-described embodiment illustrates can specifically realize by computer chip or entity,
Or it is realized by the product with certain function.It is a kind of typically to realize that equipment is computer.Specifically, computer for example may be used
Think personal computer, laptop computer, cellular phone, camera phone, smart phone, personal digital assistant, media play
It is any in device, navigation equipment, electronic mail equipment, game console, tablet computer, wearable device or these equipment
The combination of equipment.
For convenience of description, it is divided into various units when description apparatus above with function to describe respectively.Certainly, implementing this
The function of each unit can be realized in the same or multiple software and or hardware when application.
It should be understood by those skilled in the art that, the embodiment of the present invention can provide as method, system or computer program
Product.Therefore, complete hardware embodiment, complete software embodiment or reality combining software and hardware aspects can be used in the present invention
Apply the form of example.Moreover, it wherein includes the computer of computer usable program code that the present invention, which can be used in one or more,
The computer program implemented in usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.) produces
The form of product.
The present invention be referring to according to the method for the embodiment of the present invention, the process of equipment (system) and computer program product
Figure and/or block diagram describe.It should be understood that every one stream in flowchart and/or the block diagram can be realized by computer program instructions
The combination of process and/or box in journey and/or box and flowchart and/or the block diagram.It can provide these computer programs
Instruct the processor of general purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices to produce
A raw machine, so that being generated by the instruction that computer or the processor of other programmable data processing devices execute for real
The device for the function of being specified in present one or more flows of the flowchart and/or one or more blocks of the block diagram.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works, so that it includes referring to that instruction stored in the computer readable memory, which generates,
Enable the manufacture of device, the command device realize in one box of one or more flows of the flowchart and/or block diagram or
The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device, so that counting
Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, thus in computer or
The instruction executed on other programmable devices is provided for realizing in one or more flows of the flowchart and/or block diagram one
The step of function of being specified in a box or multiple boxes.
In a typical configuration, calculating equipment includes one or more processors (CPU), input/output interface, net
Network interface and memory.
Memory may include the non-volatile memory in computer-readable medium, random access memory (RAM) and/or
The forms such as Nonvolatile memory, such as read-only memory (ROM) or flash memory (flash RAM).Memory is computer-readable medium
Example.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method
Or technology come realize information store.Information can be computer readable instructions, data structure, the module of program or other data.
The example of the storage medium of computer includes, but are not limited to phase change memory (PRAM), static random access memory (SRAM), moves
State random access memory (DRAM), other kinds of random access memory (RAM), read-only memory (ROM), electric erasable
Programmable read only memory (EEPROM), flash memory or other memory techniques, read-only disc read only memory (CD-ROM) (CD-ROM),
Digital versatile disc (DVD) or other optical storage, magnetic cassettes, tape magnetic disk storage or other magnetic storage devices
Or any other non-transmission medium, can be used for storage can be accessed by a computing device information.As defined in this article, it calculates
Machine readable medium does not include temporary computer readable media (transitory media), such as the data-signal and carrier wave of modulation.
It should also be noted that, the terms "include", "comprise" or its any other variant are intended to nonexcludability
It include so that the process, method, commodity or the equipment that include a series of elements not only include those elements, but also to wrap
Include other elements that are not explicitly listed, or further include for this process, method, commodity or equipment intrinsic want
Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including described want
There is also other identical elements in the process, method of element, commodity or equipment.
The application can describe in the general context of computer-executable instructions executed by a computer, such as program
Module.Generally, program module includes routines performing specific tasks or implementing specific abstract data types, programs, objects, group
Part, data structure etc..The application can also be practiced in a distributed computing environment, in these distributed computing environments, by
Task is executed by the connected remote processing devices of communication network.In a distributed computing environment, program module can be with
In the local and remote computer storage media including storage equipment.
All the embodiments in this specification are described in a progressive manner, same and similar portion between each embodiment
Dividing may refer to each other, and each embodiment focuses on the differences from other embodiments.Especially for system reality
For applying example, since it is substantially similar to the method embodiment, so being described relatively simple, related place is referring to embodiment of the method
Part explanation.
The above description is only an example of the present application, is not intended to limit this application.For those skilled in the art
For, various changes and changes are possible in this application.All any modifications made within the spirit and principles of the present application are equal
Replacement, improvement etc., should be included within the scope of the claims of this application.