|
|
@@ -38,49 +38,49 @@ type apmTraceSpan tracesdk.ReadOnlySpan
|
|
|
|
|
|
// GO:0:10154813500555812:5450531005555981:5610250100539899:ee022542c3940f1b:1001025098564810:888ceb3df1bdbe2c:110
|
|
|
type RootDataT struct {
|
|
|
- AccountId int `json:"account_id"`
|
|
|
- AgentId int64 `json:"agent_id"`
|
|
|
- AgentVersion string `json:"agent_version"`
|
|
|
- AppId int64 `json:"app_id"`
|
|
|
- AppIdFrom int64 `json:"app_id_from"` // from header app_id
|
|
|
- AppName string `json:"app_name"`
|
|
|
- CalledId int64 `json:"called_id"` // from header assumed_app_id
|
|
|
- ClientIp string `json:"client_ip"`
|
|
|
- CollTime uint64 `json:"coll_time"`
|
|
|
- Cpu int `json:"cpu"`
|
|
|
- Custom string `json:"custom"`
|
|
|
- HostId int64 `json:"host_id"`
|
|
|
- HostName string `json:"host_name"`
|
|
|
- HttpCode int64 `json:"http_code"`
|
|
|
- HttpMethod string `json:"http_method"`
|
|
|
- InstanceId int64 `json:"instance_id"`
|
|
|
- InstanceIdFrom int64 `json:"instance_id_from"` // from header instance_id
|
|
|
- LocalPort int64 `json:"local_port"`
|
|
|
- Maps []MapInfoT `json:"maps"`
|
|
|
- MemU int `json:"mem_u"`
|
|
|
- MemUP int `json:"mem_u_p"`
|
|
|
- OperType string `json:"oper_type"`
|
|
|
- Parameters []interface{} `json:"parameters"`
|
|
|
- ParentTaskName int `json:"parent_task_name"`
|
|
|
- Period int `json:"period"`
|
|
|
- RespTime uint64 `json:"resp_time"`
|
|
|
- Sampling int `json:"sampling"`
|
|
|
- ServiceName string `json:"service_name"`
|
|
|
- ServiceType string `json:"service_type"`
|
|
|
- Sip string `json:"sip"`
|
|
|
- Sn string `json:"sn"`
|
|
|
- SpanIdFrom string `json:"span_id_from"` // from header span_id
|
|
|
- Sport int64 `json:"sport"`
|
|
|
- TId int `json:"t_id"`
|
|
|
- TName string `json:"t_name"`
|
|
|
- TraceId string `json:"trace_id"` // from header trace_id
|
|
|
- TransIds []interface{} `json:"trans_ids"`
|
|
|
- TypeFrom string `json:"type_from"`
|
|
|
- Uri string `json:"uri"`
|
|
|
- UserDir int `json:"user_dir"`
|
|
|
- VipIds []interface{} `json:"vip_ids"`
|
|
|
- SrcAddr string `json:"src_addr"`
|
|
|
- DestinationAddr string `json:"destination_addr"`
|
|
|
+ AccountId int `json:"account_id"`
|
|
|
+ AgentId int64 `json:"agent_id"`
|
|
|
+ AgentVersion string `json:"agent_version"`
|
|
|
+ AppId int64 `json:"app_id"`
|
|
|
+ AppIdFrom int64 `json:"app_id_from"` // from header app_id
|
|
|
+ AppName string `json:"app_name"`
|
|
|
+ CalledId int64 `json:"called_id"` // from header assumed_app_id
|
|
|
+ ClientIp string `json:"client_ip"`
|
|
|
+ CollTime uint64 `json:"coll_time"`
|
|
|
+ Cpu int `json:"cpu"`
|
|
|
+ Custom string `json:"custom"`
|
|
|
+ HostId int64 `json:"host_id"`
|
|
|
+ HostName string `json:"host_name"`
|
|
|
+ HttpCode int64 `json:"http_code"`
|
|
|
+ HttpMethod string `json:"http_method"`
|
|
|
+ InstanceId int64 `json:"instance_id"`
|
|
|
+ InstanceIdFrom int64 `json:"instance_id_from"` // from header instance_id
|
|
|
+ LocalPort int64 `json:"local_port"`
|
|
|
+ Maps []MapInfoT `json:"maps"`
|
|
|
+ MemU int `json:"mem_u"`
|
|
|
+ MemUP int `json:"mem_u_p"`
|
|
|
+ OperType string `json:"oper_type"`
|
|
|
+ Parameters []interface{} `json:"parameters"`
|
|
|
+ ParentTaskName int `json:"parent_task_name"`
|
|
|
+ Period int `json:"period"`
|
|
|
+ RespTime uint64 `json:"resp_time"`
|
|
|
+ Sampling int `json:"sampling"`
|
|
|
+ ServiceName string `json:"service_name"`
|
|
|
+ ServiceType string `json:"service_type"`
|
|
|
+ Sip string `json:"sip"`
|
|
|
+ Sn string `json:"sn"`
|
|
|
+ SpanIdFrom string `json:"span_id_from"` // from header span_id
|
|
|
+ Sport int64 `json:"sport"`
|
|
|
+ TId int `json:"t_id"`
|
|
|
+ TName string `json:"t_name"`
|
|
|
+ TraceId string `json:"trace_id"` // from header trace_id
|
|
|
+ TransIds []interface{} `json:"trans_ids"`
|
|
|
+ TypeFrom string `json:"type_from"`
|
|
|
+ Uri string `json:"uri"`
|
|
|
+ UserDir int `json:"user_dir"`
|
|
|
+ VipIds []interface{} `json:"vip_ids"`
|
|
|
+ SrcAddr string `json:"src_addr"`
|
|
|
+ DestinationAddr string `json:"destination_addr"`
|
|
|
}
|
|
|
|
|
|
type MapInfoT struct {
|
|
|
@@ -397,47 +397,47 @@ func initRootDataFromEvent() RootDataT {
|
|
|
accountID := utils.GetAccountID()
|
|
|
data := RootDataT{
|
|
|
// todo AccountId
|
|
|
- AccountId: accountID,
|
|
|
- AgentId: 0, // 基于 ip:port + process_name + exe路径生成
|
|
|
- AgentVersion: "2.1.0",
|
|
|
- AppId: 0, // 基于appname生成
|
|
|
- AppIdFrom: -1,
|
|
|
- AppName: "eBPF-agent", // server配置
|
|
|
- CalledId: -1,
|
|
|
- ClientIp: "",
|
|
|
- CollTime: 0,
|
|
|
- Cpu: 0,
|
|
|
- Custom: "",
|
|
|
- HostId: hostID,
|
|
|
- HostName: "localhost",
|
|
|
- HttpCode: 0,
|
|
|
- HttpMethod: "",
|
|
|
- InstanceId: 0, // 基于ip:port
|
|
|
- InstanceIdFrom: -1,
|
|
|
- Maps: []MapInfoT{},
|
|
|
- MemU: 0,
|
|
|
- MemUP: 0,
|
|
|
- OperType: "",
|
|
|
- Parameters: []interface{}{},
|
|
|
- ParentTaskName: 0,
|
|
|
- Period: -1,
|
|
|
- RespTime: 0,
|
|
|
- Sampling: 0,
|
|
|
- ServiceName: "",
|
|
|
- ServiceType: APP_SERVICE_TYPE,
|
|
|
- Sip: "",
|
|
|
- Sn: "",
|
|
|
- SpanIdFrom: "",
|
|
|
- Sport: 0,
|
|
|
- TId: -1,
|
|
|
- TName: "",
|
|
|
- TraceId: "",
|
|
|
- TransIds: []interface{}{},
|
|
|
- TypeFrom: "",
|
|
|
- Uri: "",
|
|
|
- UserDir: 0,
|
|
|
- VipIds: []interface{}{},
|
|
|
- SrcAddr: "",
|
|
|
+ AccountId: accountID,
|
|
|
+ AgentId: 0, // 基于 ip:port + process_name + exe路径生成
|
|
|
+ AgentVersion: "2.1.0",
|
|
|
+ AppId: 0, // 基于appname生成
|
|
|
+ AppIdFrom: -1,
|
|
|
+ AppName: "eBPF-agent", // server配置
|
|
|
+ CalledId: -1,
|
|
|
+ ClientIp: "",
|
|
|
+ CollTime: 0,
|
|
|
+ Cpu: 0,
|
|
|
+ Custom: "",
|
|
|
+ HostId: hostID,
|
|
|
+ HostName: "localhost",
|
|
|
+ HttpCode: 0,
|
|
|
+ HttpMethod: "",
|
|
|
+ InstanceId: 0, // 基于ip:port
|
|
|
+ InstanceIdFrom: -1,
|
|
|
+ Maps: []MapInfoT{},
|
|
|
+ MemU: 0,
|
|
|
+ MemUP: 0,
|
|
|
+ OperType: "",
|
|
|
+ Parameters: []interface{}{},
|
|
|
+ ParentTaskName: 0,
|
|
|
+ Period: -1,
|
|
|
+ RespTime: 0,
|
|
|
+ Sampling: 0,
|
|
|
+ ServiceName: "",
|
|
|
+ ServiceType: APP_SERVICE_TYPE,
|
|
|
+ Sip: "",
|
|
|
+ Sn: "",
|
|
|
+ SpanIdFrom: "",
|
|
|
+ Sport: 0,
|
|
|
+ TId: -1,
|
|
|
+ TName: "",
|
|
|
+ TraceId: "",
|
|
|
+ TransIds: []interface{}{},
|
|
|
+ TypeFrom: "",
|
|
|
+ Uri: "",
|
|
|
+ UserDir: 0,
|
|
|
+ VipIds: []interface{}{},
|
|
|
+ SrcAddr: "",
|
|
|
DestinationAddr: "",
|
|
|
}
|
|
|
return data
|
|
|
@@ -823,7 +823,7 @@ func buildMysqlMapEvent(mNode *MapInfoT, event tracesdk.Event) {
|
|
|
mNode.Dbn = "unknown"
|
|
|
mNode.ServiceName = MYSQL_SERVICE_NAME
|
|
|
mNode.ServiceType = SQL_SERVICE_TYPE
|
|
|
- mNode.MethodName = "database/sql.Query()"
|
|
|
+ //mNode.MethodName = "database/sql.Query()"
|
|
|
for _, attr := range event.Attributes {
|
|
|
//fmt.Println(attr.Key, ":", attr.Value.AsInterface())
|
|
|
switch attr.Key {
|
|
|
@@ -833,6 +833,7 @@ func buildMysqlMapEvent(mNode *MapInfoT, event tracesdk.Event) {
|
|
|
mNode.Port = attr.Value.AsInt64()
|
|
|
case "db.statement":
|
|
|
query := attr.Value.AsString()
|
|
|
+ mNode.MethodName = query
|
|
|
mNode.Ps = []string{query}
|
|
|
words := strings.Fields(query)
|
|
|
if len(words) > 0 {
|
|
|
@@ -898,7 +899,7 @@ func buildRedisMapEvent(mNode *MapInfoT, event tracesdk.Event) {
|
|
|
mNode.ServiceName = REDIS_SERVICE_NAME
|
|
|
mNode.ServiceType = NOSQL_SERVICE_TYPE
|
|
|
//mNode.MethodName = span(sd).Name + " query"
|
|
|
- mNode.MethodName = "redis.Do()"
|
|
|
+ //mNode.MethodName = "redis.Do()"
|
|
|
for _, attr := range event.Attributes {
|
|
|
//fmt.Println(attr.Key, ":", attr.Value.AsInterface())
|
|
|
switch attr.Key {
|
|
|
@@ -908,6 +909,7 @@ func buildRedisMapEvent(mNode *MapInfoT, event tracesdk.Event) {
|
|
|
mNode.Port = attr.Value.AsInt64()
|
|
|
case "db.statement":
|
|
|
query := attr.Value.AsString()
|
|
|
+ mNode.MethodName = query
|
|
|
mNode.Ps = []string{query}
|
|
|
words := strings.Fields(query)
|
|
|
if len(words) > 0 {
|