前言
在前一篇文章中,我们探讨了collector 的数据处理,这一篇中我们将讲讲如何构建javascript、golang agent。
golang
如图所示我们将pinpoint的协议进行改造,并生成go语言版本的agent
type TSpan struct {
AgentId string `thrift:"agentId,1" json:"agentId"`
ApplicationName string `thrift:"applicationName,2" json:"applicationName"`
AgentStartTime int64 `thrift:"agentStartTime,3" json:"agentStartTime"`
TransactionId []byte `thrift:"transactionId,4" json:"transactionId"`
// unused fields # 5 to 6
SpanId int64 `thrift:"spanId,7" json:"spanId"`
ParentSpanId int64 `thrift:"parentSpanId,8" json:"parentSpanId"`
StartTime int64 `thrift:"startTime,9" json:"startTime"`
Elapsed int32 `thrift:"elapsed,10" json:"elapsed"`
Rpc *string `thrift:"rpc,11" json:"rpc"`
ServiceType int16 `thrift:"serviceType,12" json:"serviceType"`
EndPoint *string `thrift:"endPoint,13" json:"endPoint"`
RemoteAddr *string `thrift:"remoteAddr,14" json:"remoteAddr"`
Annotations []*TAnnotation `thrift:"annotations,15" json:"annotations"`
Flag int16 `thrift:"flag,16" json:"flag"`
Err *int32 `thrift:"err,17" json:"err"`
SpanEventList []*TSpanEvent `thrift:"spanEventList,18" json:"spanEventList"`
ParentApplicationName *string `thrift:"parentApplicationName,19" json:"parentApplicationName"`
ParentApplicationType *int16 `thrift:"parentApplicationType,20" json:"parentApplicationType"`
AcceptorHost *string `thrift:"acceptorHost,21" json:"acceptorHost"`
// unused fields # 22 to 24
ApiId *int32 `thrift:"apiId,25" json:"apiId"`
ExceptionInfo *TIntStringValue `thrift:"exceptionInfo,26" json:"exceptionInfo"`
// unused fields # 27 to 29
ApplicationServiceType *int16 `thrift:"applicationServiceType,30" json:"applicationServiceType"`
LoggingTransactionInfo *int8 `thrift:"loggingTransactionInfo,31" json:"loggingTransactionInfo"`
}
我们将Agent发送的数据发送到mecury,mecury再次进行数据解析,数据压缩,发送到collector。
javascript
javascript 我们将新增 GetWay网关层。我们见agent数据提供websocket发送到高性能GetWay层。GetWay将网页的监控数据链路数据错误信息,进行预处理,压缩发送到collector。自此将全链路数据打通,同时也收集了前端的性能数据。
总结
javascript/golang agent改造到此结束。不过后续还有很多问题需要处理:
1.如何处理离线数据,并能在web端实时高效的展示。
2.如何结合全链路监控和系统监控,做业务监控,服务监控