pinpoint，不用侵入到用户代码，在JVM插入agent实现调用链。与鹰眼，zipkin等白盒方式不同的是，pinpoint不要侵入代码，可以称之为灰盒（论文将调用链分为三种，白盒灰盒，黑盒）。

# agent说明

Pinpoint Agent attaches itself to a host application (such as Tomcat) as a java agent to instrument various classes for tracing. When a class marked for tracing is loaded into the JVM, the Agent injects code around pre-defined methods to collect and send trace data to the Collector.
In addition to trace data, the agent also collects various information about the host application such as JVM arguments, loaded libraries, CPU usage, Memory Usage and Garbage Collection.

• 从FrountEnd出来的原始message之外被agent加上了transaction ID, span ID等等trace data，关于这些ID的作用，可以查看dapper的定义
• BackEnd收到消息后，先由agent把trace data解析出来，然后再把原始message交给BackEnd的方法

## 原理

To wire up the agent, pass $AGENT_PATH/pinpoint-bootstrap-$VERSION.jar to the -javaagent JVM argument when running the application:

• -javaagent:$AGENT_PATH/pinpoint-bootstrap-$VERSION.jar
Additionally, Pinpoint Agent requires 2 command-line arguments in order to identify itself in the distributed system:
• -Dpinpoint.agentId - uniquely identifies the application instance in which the agent is running on
• -Dpinpoint.applicationName - groups a number of identical application instances as a single service

## 插件示例

Sample_13_RPC_Client.java

Interceptor有两个方法before和after

本博客欢迎转发,但请保留原作者信息
github:codejuan