Pinpoint the process of sending data to each port in the agent, continuously updating __java

Source: Internet
Author: User
Tags thread class
When the agent starts, it calls the constructs in Defaultagent to create a lot of initialization, and the data initialization process sent by the agent starts here. Defaultagent.java
Defaultagent loads the agent information ( agentinformation): This.agentinformation = Agentinformationfactory.createagentinformation (Typeresolver.resolve ()); 195 lines agentinformationContains: | |-Agentid Agentid | ApplicationName own configuration Application name |-starttime Java Virtual machine startup time |-PID Java Virtual machine implementation name, @ Front string | machinen AME Host name |-hostip Native IP address |-jvmversion JVM Version |-ServerType servicetype-for example, describe this is a Tomcat |-agentversion agent version information this. Spandatasender = Createudpspandatasender (This.profilerConfig.getCollectorSpanServerPort (), " Pinpoint-udpspandataexecutor ", This.profilerConfig.getSpanDataSenderWriteQueueSize (), This.profilerConfig.getSpanDataSenderSocketTimeout (), this.profilerConfig.getSpanDataSenderSocketSendBufferSize ()); 200 lines-SPAN data send module initialization, parameter is "port, thread name, write queue size default 1024 * 5, set timeout default 1000 * 3, send buffer size default 1024 * 64 * 16"-these values are from the Pinpoint.config The default value in the Defaultprofilerconfig.java file. This.statdatasender = Createudpstatdatasender (This.profilerConfig.getCollectorStatServerPort (), " Pinpoint-udpstatdataexecutor ", This.profilerConfig.getStatDataSenderWriteQueueSize (), This.profilerConfig.getStatDataSenderSocketTimeout (), this.profilerConfig.getStatDataSenderSocketSendBufferSize ()); 203Row--Agentstatmonitor the initialization of the module of the data sending module Defaulttracecontext defaulttracecontext = Createtracecontext (); ---Create TraceContext | |-Get Trace currentrpctraceobject ()--> plug-in developed by the interceptor in the use of | | Get configuration file profilerconfig Getprofilerconfig () --> plug-in to get some pinpoint.config configuration content
This.tcpdatasender = Createtcpdatasender (Commandservice); --TCP Data Sender
This.agentinfosender = new Agentinfosender.builder (Tcpdatasender, This.agentinformation, Jvminformationfactory.createjvminformation ()). Sendinterval (Profilerconfig.getagentinfosendretryinterval ()). Build (); Agentinfo data Sender This.agentinfosender. Start (), you can create a periodic send Agentinfo. TCP is used.
--The real code to send agentinfo data, TCP port send, and is a timed to send Datasender.request (This.agentinfo, This.agentinfosenderlistener); The Agentinfosender 200 line this.agentinfo is obtained by Createtagentinfo (). Agentinfosender 110 Line Tagentinfo one contains the agentinformation "Agent Information"+ Servermetadata"Service meta-data" + jvminformation "JVM Information"The class of information, which is the thrift object that can be serialized and deserialized. |--IP IP, through agentinformation To get in. |--hostname host name, through agentinformation To get in. |--Ports port, default is empty string | |-Agentid Agentid, through agentinformation To get in. |--ApplicationName application name, through agentinformation To get in. |--servicetype Just ServiceType code, through agentinformation obtained inGetservertype ().GetCode (). |--PID Java Virtual machine implementation name before the integer value, by agentinformation To get in. |--Agentversion agent version, through Version.version Get|--vmversion virtual machine version, through agentinformation To get in. |--Starttimestamp NO settings |-endtimestamp no set | | endstatus | servermetadata tservermetadata, called by Createtserviceinfo (). The servermetadata is not set when it is not empty, and the default is no Servermetadata setting is implemented through Publishservermetadata (Servermetadata servermetadata). | ServerInfo server information, through the Servermetadata.getserverinfo () get | | Vmargs server parameters, through Servermetadata.getvmargs () get | Serviceinfos List < Tserviceinfo > |-- The name of the ServiceName service |-- Servicelibs Lib of the List<string> service
Servermetadata The main thing is to convert a servermetadata into a tservermetadata,tservermetadata is an instance object that can be serialized. The following Serviceinfos is also true. | |-Jvminfo This is the basic information of a JVM, Createtjvminfo () to handle. This is also the same as the above, but also a common Jvminfo object to Tjvminfo object. |-Version |--vmversion virtual Machine version | |-Gctype garbage collection mechanism type
This.agentstatmonitor = new Agentstatmonitor (This.statdatasender, This.agentInformation.getAgentId (), This.agentInformation.getStartTime (), agentstatcollectorfactory); --the creation of Agentstatmonitor, through This.statdatasender to send data, Agentstatmonitor is mainly an agent state listener, used to detect agent information. This.agentStatMonitor.start () starts. The Defaultagent 451 line calls after Start (). Wear piece collectjob This is a thread class collectjob job = new Collectjob (this.numcollectionsperbatch);//Agentstatmonitor 88 line Add this thread class to a timer to execute. The data is starting to collect.
Tagentstat This is a collection of ways to send, the default is to 6 tagentstat after the unified send package of objects is Tagentstatbatch, call sent by the method is Sendagentstats (); Agentstatmonitor 159 Rows Tagentstatbatch | | Agentid Agentid | | starttimestamp Agent Information | | agentstats LIST&LT;TAGENTST At> Tagentstat Collection | |--TJVMGC garbage collection mechanism final TJVMGC GC = Garbagecollector.collect (); Agentstatmonitor 148 in line to get | | Tjvmgctype GC type unknown (0), serial (1), PARALLEL (2), CMS (3), G1 (4); |--jvmmemoryheapused Use of the heap |--| jvmmemoryheapmax | jvmmemorynonheapused | jvmmemorynonheapmax |-jvmgcoldcount | jvmgcoldtime |-TJVMGC Detailed garbage Recycling Mechanism Detail |-jvmgcnewcount | jvmgcnewtime | jvmpoolcodecacheused | | jvmpoolnewgenused | jvmpoololdgenused | |-jvmpoolsurvivorspaceused | jvmpoolpermgenused |--jvmpoolmetaspaceused |-tcpuload CPU Information | |-jvmcpuload | systemC Puload | | ttransaction | samplednewcount | | sampledcontinuationcount | unsamplednewcount | Unsampledcontinuationcount | tactivetrace | tactivetracehistogram | | version | histogramschematype |-ActiveTRacecount |-Timestamp Current TIME |-collectinterval collection interval data send code is: Datasender.send (agentstatbatch);//Agentstatmonitor 174 lines

Tapimetadata data sending process, this mainly is encapsulates the API information, sends through the TCP data. Simply explain the role of this data send, we have a apiid in the Tspan, and we finally have to find the API name description and so on, we are through this to achieve. Through TRACECONTEXT.CACHEAPI ( Methoddescriptor methoddescriptor)You can send the API information Servletasyncmethoddescriptor is a custom-defined class that implements Methoddescriptor. This class is mainly used to describe the information of the API, such as: Apiid, type, method name, class name, parameter type, line number, full name, description, etc. can be referenced in the Tomcat plug-in com . Navercorp . Pinpoint . plugin . Tomcat . ServletasyncmethoddescriptorFor example, in Tomcat's plug-in, this class of standardhostvalveinvokeinterceptor uses this plugin. 82,83 Line
public int CacheAPI (final methoddescriptor methoddescriptor) {final String fullName = Methoddescriptor.getfullname (); Get full name final result result = This.apiCache.put (fullName); The main goal is to get a apiid of the method name, starting with a value of 1 from the increased data, which uses a cache to handle, the result is the incoming object to do the key, results do the value. Can see com . Navercorp . Pinpoint . Profiler . metadata . simplecache< T >
Methoddescriptor.setapiid (Result.getid ()); Set the Apiid of the method
if (Result.isnewvalue ()) {//Determine if the API Galaxy is the new final tapimetadata apimetadata = newer tapimetadata ();//serializable object, API metadata Apimetadata.setagentid (Getagentid ()); To obtain Agentid Apimetadata.setagentstarttime (Getagentstarttime ()) by TraceContext; To get start time by TraceContext
Apimetadata.setapiid (Result.getid ()); The ID apimetadata.setapiinfo (Methoddescriptor.getapidescriptor ()) of the method, and/or the description information for the method Apimetadata.setline ( Methoddescriptor.getlinenumber ()); Line number Apimetadata.settype (Methoddescriptor.gettype ()); Type of method
This.priorityDataSender.request (Apimetadata); Send, pass TCP, because before creating TraceContext, the sending data object is set up by the following methods Defaulttracecontext.setprioritydatasender ( This.tcpdatasender); }
return Result.getid (); Finally, the ID of the API is returned.}
Tapimetadata | | Agentid Agentid | | agentstarttime tracecontext to get agent start Time | |-apiid Method ID | |-apiinfo Description Information | Line number | |-type
Tstringmetadata data sending process, this and tapimetadata are the same. Record String Metadata Tstringmetadata |-| Agentid Agentid | | agentstarttime tracecontext to get agent start Time | | Stringid string ID | stringval Value of the UE string
Tsqlmetadata data sending process, this and tapimetadata are the same. Log SQL metadata, or simply to log SQL statements public boolean cachesql (Parsingresult parsingresult) {if (Parsingresult = = null) {return false; }//Lazy SQL parsing Boolean isnewvalue = THIS.CACHINGSQLNORMALIZER.NORMALIZEDSQL (Parsingresult); Parsingresult is parsed to verify that the Parsingresult is a new if (Isnewvalue) {if (isdebug) {logger.debug}. Parsingresult); Final Tsqlmetadata sqlmetadata = new Tsqlmetadata (); Sqlmetadata.setagentid (Getagentid ()); Set Agentid sqlmetadata.setagentstarttime (Getagentstarttime ()); Set Agent start time
Sqlmetadata.setsqlid (Parsingresult.getid ()); Set Sqlid Sqlmetadata.setsql (Parsingresult.getsql ()); Set SQL string
This.priorityDataSender.request (SqlMetaData); Data send} return isnewvalue; By returning the value we can know if there is a log of this SQL
Boolean com . Navercorp . Pinpoint . Profiler . Context . Defaultcachingsqlnormalizer . Normalizedsql ( Parsingresult Parsingresult)The effect of this method is simply to turn a parsingresult into a generic parsingresultinternal intermediate set through the Normalizedsql can be seen in this way Normalizedsql com . Navercorp . Pinpoint . Common . util . Defaultsqlparser . Normalizedsql ( String sql)Used to parse. Tsqlmetadata | | Agentid Agentid | | agentstarttime tracecontext to get agent start time | | sqlid SQL alert ID | SQL corresponding SQL string


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.