Pinpoint 数据结构详解-TCP

Pinpoint 数据结构详解-TCP

Wed Nov 28, 2018

800 Words|Read in about 2 Min
Tags: 监控   apm   trace  

本文基于pinpoint 1.8版本探索

pinpoint Tcp端口主要上传一些Agent信息,服务信息,API、SQL等信息。 有些信息只上报一次,so如果collector不去做存储可能就丢失了,在全链路展示的时候就会出现数字替代接口信息!

TAgentInfo

type TAgentInfo struct {
	Hostname        string `thrift:"hostname,1" db:"hostname" json:"hostname"`
	IP              string `thrift:"ip,2" db:"ip" json:"ip"`
	Ports           string `thrift:"ports,3" db:"ports" json:"ports"`
	AgentId         string `thrift:"agentId,4" db:"agentId" json:"agentId"`
	ApplicationName string `thrift:"applicationName,5" db:"applicationName" json:"applicationName"`
	ServiceType     int16  `thrift:"serviceType,6" db:"serviceType" json:"serviceType"`
	Pid             int32  `thrift:"pid,7" db:"pid" json:"pid"`
	AgentVersion    string `thrift:"agentVersion,8" db:"agentVersion" json:"agentVersion"`
	VmVersion       string `thrift:"vmVersion,9" db:"vmVersion" json:"vmVersion"`
	StartTimestamp  int64  `thrift:"startTimestamp,10" db:"startTimestamp" json:"startTimestamp"`
	EndTimestamp    *int64 `thrift:"endTimestamp,11" db:"endTimestamp" json:"endTimestamp,omitempty"`
	EndStatus       *int32 `thrift:"endStatus,12" db:"endStatus" json:"endStatus,omitempty"`
	// unused fields # 13 to 19
	ServerMetaData *TServerMetaData `thrift:"serverMetaData,20" db:"serverMetaData" json:"serverMetaData,omitempty"`
	// unused fields # 21 to 29
	JvmInfo *TJvmInfo `thrift:"jvmInfo,30" db:"jvmInfo" json:"jvmInfo,omitempty"`
	// unused fields # 31 to 39
	Container bool `thrift:"container,40" db:"container" json:"container,omitempty"`
}

上报Agent相关信息,简单字段不介绍,主要介绍里面多几个struct

* ServerMetaData 服务信息
* JvmInfo jvm信息
* Container 是否部署容器
type TServerMetaData struct {
	ServerInfo *string  `thrift:"serverInfo,1" db:"serverInfo" json:"serverInfo,omitempty"`
	VmArgs_    []string `thrift:"vmArgs,2" db:"vmArgs" json:"vmArgs,omitempty"`
	// unused fields # 3 to 9
	ServiceInfos []*TServiceInfo `thrift:"serviceInfos,10" db:"serviceInfos" json:"serviceInfos,omitempty"`
}
* ServerInfo 服务名,比如 *Apache Tomcat/8.5.34*
* VmArgs_ 启动参数
* ServiceInfos 提供服务信息
type TServiceInfo struct {
	ServiceName *string  `thrift:"serviceName,1" db:"serviceName" json:"serviceName,omitempty"`
	ServiceLibs []string `thrift:"serviceLibs,2" db:"serviceLibs" json:"serviceLibs,omitempty"`
}
* ServiceName 提供服务名,如tomcat提供了paasServices服务,上报信息为:*Catalina/localhost/paasServices*
* ServiceLibs 服务包含jar包等信息, 如: *[ejob-sdk-1.0.0.jar spring-data-commons-1.7.0.RELEASE.jar mail-1.4.7.jar velocity-tools-2.0.jar spring-expression-4.3.1.RELEASE.jar activation-1.1.jar]...*
type TJvmInfo struct {
	Version   int16      `thrift:"version,1" db:"version" json:"version"`
	VmVersion *string    `thrift:"vmVersion,2" db:"vmVersion" json:"vmVersion,omitempty"`
	GcType    TJvmGcType `thrift:"gcType,3" db:"gcType" json:"gcType,omitempty"`
}

JVM信息(ps:Java大神应该比我懂,我非Java系就不班门弄斧了)

* Version  版本
* VmVersion  vm类型
* GcType gc类型

pinpoint中定义的几种GC类型如下:

type TJvmGcType int64

const (
	TJvmGcType_UNKNOWN  TJvmGcType = 0
	TJvmGcType_SERIAL   TJvmGcType = 1
	TJvmGcType_PARALLEL TJvmGcType = 2
	TJvmGcType_CMS      TJvmGcType = 3
	TJvmGcType_G1       TJvmGcType = 4
)

友情链接gc介绍

type TSqlMetaData struct {
	AgentId        string `thrift:"agentId,1" db:"agentId" json:"agentId"`
	AgentStartTime int64  `thrift:"agentStartTime,2" db:"agentStartTime" json:"agentStartTime"`
	// unused field # 3
	SqlId int32  `thrift:"sqlId,4" db:"sqlId" json:"sqlId"`
	Sql   string `thrift:"sql,5" db:"sql" json:"sql"`
}
* SqlId sql语句ID
* Sql sql语句
type TApiMetaData struct {
	AgentId        string `thrift:"agentId,1" db:"agentId" json:"agentId"`
	AgentStartTime int64  `thrift:"agentStartTime,2" db:"agentStartTime" json:"agentStartTime"`
	// unused field # 3
	ApiId   int32  `thrift:"apiId,4" db:"apiId" json:"apiId"`
	ApiInfo string `thrift:"apiInfo,5" db:"apiInfo" json:"apiInfo"`
	Line    *int32 `thrift:"line,6" db:"line" json:"line,omitempty"`
	// unused fields # 7 to 9
	Type *int32 `thrift:"type,10" db:"type" json:"type,omitempty"`
}
* ApiId apiID
* ApiInfo api信息
* Line  行数(我猜测)
* Type Api类型
type TStringMetaData struct {
	AgentId        string `thrift:"agentId,1" db:"agentId" json:"agentId"`
	AgentStartTime int64  `thrift:"agentStartTime,2" db:"agentStartTime" json:"agentStartTime"`
	// unused field # 3
	StringId    int32  `thrift:"stringId,4" db:"stringId" json:"stringId"`
	StringValue string `thrift:"stringValue,5" db:"stringValue" json:"stringValue"`
}

字面也是理解,就是string上报。

上面三种类型都是为了监控全链路数据上报时减少报文大小,用ID来代替string,所以很好理解。所以这里我也不过多做介绍。

See Also

Wed Nov 28, 2018

800 Words|Read in about 2 Min
Tags: 监控   apm   trace