APM agent发送的消息

TcpDataSender:

Thrift client发送;

TAgentInfo:每天发送一次,失败时重试间隔300秒(配置文件),最大重试3次

hostname:localhost.localdomain,  // InetAddress.getLocalHost().getHostName();  
ip:127.0.0.1,  //InetAddress.getLocalHost().getHostAddress();
ports:,//agentInfo.setPorts("");// 固定置空
agentId:spring-sample,
applicationName:spring-sample,
serviceType:1010,  //if ApplicationTypeDetector.detect then return ApplicationTypeDetector.getApplicationType()
pid:11323, // ManagementFactory.getRuntimeMXBean().getName();取@前的内容
agentVersion:1.5.2-SNAPSHOT,// 写死的
vmVersion:1.7.0_75,// jvmVersion:ManagementFactory.getRuntimeMXBean().getSystemProperties().get("java.version");
startTimestamp:1463647809677,//ManagementFactory.getRuntimeMXBean().getStartTime();
serverMetaData:TServerMetaData( 
serverInfo:Apache Tomcat/7.0.47,// 目前只有tomcat plugin里有设置:traceContext.getServerMetaDataHolder().setServerName(serverInfo),取org.apache.catalina.util.ServerInfo.getServerInfo()
vmArgs:[xxxx],//ManagementFactory.getRuntimeMXBean().getInputArguments();
serviceInfos:[TServiceInfo(// 目前只有spring和tomcat plugin里有设置:traceContext.getServerMetaDataHolder().addServiceInfo(contextKey, libJars);
serviceName:Tomcat/localhost/spring-sample,
serviceLibs:[xxx])
]
),  

jvmInfo:TJvmInfo(version:0,//未设置,默认为0
vmVersion:1.7.0_75, //ManagementFactory.getRuntimeMXBean().getSystemProperties().get("java.version")
gcType:PARALLEL)// 使用开源组件获得:com.codahale.metrics

)
TApiMetaData:在Interceptor里调用TraceContext. cacheApi(MethodDescriptor methodDescriptor),在TraceContext里构造并使用TcpDataSender发送。
agentId:spring-sample,
agentStartTime:1463647809677,
apiId:-1, // 使用zigzag编码缩短二进制长度,实际上是1开始增长的序列
apiInfo:org.apache.catalina.core.StandardHostValve.invoke(org.apache.catalina.connector.Request request, org.apache.catalina.connector.Response response),
line:135,
type:0

UdpDataSender:

使用原生DiagramSocket发送;

TSpan:在DefaultTrace里构造,在调用SpanStorage.store(span)时,设置spancEventList。SpanStorage每次store(spanEvent)时,保存spanEvent到spanEventList

Pinpoint finds out caller-callee relation by matching destinationId of client trace and acceptorHost of server trace. Therefore the client plugin has to record destinationId and the server plugin has to record acceptorHost with the same value. If server cannot acquire the value by itself, client plugin has to pass it to server.
agentId:spring-sample,
applicationName:spring-sample,
agentStartTime:1463647809677,
transactionId:00 01 8D E1 D4 C1 CC 2A 01,
spanId:-2997437362046041524,// 随机数
startTime:1463647877869,
elapsed:277,// 创建span时记录startTime,span close时记录afterTime,elapsed=afterTime-startTime
rpc:/spring-sample/,
serviceType:1010,
endPoint:10.63.212.87:8082,// client端:Target server address;server端:Server(current node) address
remoteAddr:10.60.56.150,// 只在server端设置:Client address
flag:0,// spanRecorder.recordTraceId(TraceId traceId)-->span.recordTraceId(traceId),其中把traceId.flag赋予span.flag,整个pinpoint中没有地方用这个flag
spanEventList:[

■  TSpanEvent(sequence:3,// traceBlockBegin时,callStack.push(spanEvent)-->spanEvent.setSequence(sequence++); sequence在1个span中从0开始递增

startElapsed:202,// traceBlockBegin中创建SpanEvent时,设置startElapsed = System.currentTimeMillis() - span.getStartTime()

endElapsed:17,// traceBlockEnd时,设置endElapsed = System.currentTimeMillis() - span.getStartTime() - startElapsed

serviceType:9055,// TODO 是否可以设计为业务分类?

annotations:[TAnnotation(key:40, value:<TAnnotationValue stringValue:http://10.63.212.87:8081/spring-mvc-showcase/simple>)],// TODO 界面上有什么作用?

depth:4,// 一直递增,实际上depth=sequence+1

nextSpanId:-1955855237325378592,

destinationId:10.63.212.87:8081, // 只在client端设置:Logical name of the target;

apiId:7),

■  TSpanEvent(sequence:2, startElapsed:87, endElapsed:134, serviceType:5071, depth:3, apiId:-4),

■  TSpanEvent(sequence:1, startElapsed:51, endElapsed:222, serviceType:5051, depth:2, apiId:2),

■  TSpanEvent(sequence:0, startElapsed:10, endElapsed:267, serviceType:1011, depth:1, apiId:-1)],
apiId:-2,
applicationServiceType:1010

※ TAgentStatBatch:在AgentStatMonitor里构造,AgentStatMonitor每?秒收集一次Agent信息(TAgentStat),在攒够一批数量(根据配置)后,一次发出。

agentId:spring-sample,
startTimestamp:1463647809677,

•   agentStats:[

■  TAgentStat(timestamp:1463651115704, collectInterval:5000,

gc:TJvmGc(type:PARALLEL, jvmMemoryHeapUsed:103827208, jvmMemoryHeapMax:1823473664, jvmMemoryNonHeapUsed:46605392, jvmMemoryNonHeapMax:224395264, jvmGcOldCount:0, jvmGcOldTime:0),// 使用com.codahale.metrics

cpuLoad:TCpuLoad(jvmCpuLoad:5.02008032128514E-4, systemCpuLoad:0.006027122049221497),// java version>=7时,从OperatingSystemMXBean获取;否则从ManagementFactory.getRuntimeMXBean()中计算;

transaction:TTransaction(sampledNewCount:0, sampledContinuationCount:0, unsampledNewCount:0, unsampledContinuationCount:0),

activeTrace:TActiveTrace(histogram:TActiveTraceHistogram(version:0, histogramSchemaType:2, activeTraceCount:[0, 0, 0, 0]))),

■  TAgentStat(……

总结:

  1. 从发送信息使用的协议来看,TCP用来发送静态数据,例如agent相关的信息、api、sql相关的信息;UDP用来发送动态数据,例如agent状态和负载、app调用产生的跟踪数据;

  2. 从对应的thrift定义的结构来看,APM.thrift中定义的是agent层面的结构,例如agent信息、jvm信息、cpu信息等;Trace.thrift中定义的是跟踪层面的结构,例如跟踪数据、代码信息、sql信息等;

  3. Commond.thrift:将web请求路由到agent。从 1.5.0 版本开始, APM可以通过collector从web直接发送请求到agent(反之亦然). 为此需要使用Zookeeper 来协调agent和collector之间和collectors 和 web 之间的通讯通道. 在此之上,实时通讯(例如活动线程数量监控)才变的可能.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值