瀏覽代碼

Fixed #TASK_QT-9810 appid优化

Carl 1 年之前
父節點
當前提交
f2134ced11
共有 41 個文件被更改,包括 739 次插入495 次删除
  1. 0 19
      common/app_info.go
  2. 23 47
      containers/apm_register_app.go
  3. 3 2
      containers/apm_white_list.go
  4. 15 17
      containers/container.go
  5. 84 77
      containers/container_apm.go
  6. 2 2
      containers/process.go
  7. 37 13
      containers/registry.go
  8. 21 0
      containers/registry_apm.go
  9. 9 9
      containers/util.go
  10. 1 0
      ebpftracer/ebpf/include/socket_trace_common.h
  11. 2 1
      ebpftracer/ebpf/utrace/go/net/client.probe.bpf.c
  12. 2 1
      ebpftracer/ebpf/utrace/java/net/client.probe.bpf.c
  13. 2 2
      ebpftracer/jvm.go
  14. 2 4
      ebpftracer/netcore.go
  15. 14 12
      ebpftracer/tls.go
  16. 23 26
      ebpftracer/tracer.go
  17. 4 3
      ebpftracer/tracer/btf_vmlinux.go
  18. 2 1
      ebpftracer/tracer/offset.go
  19. 5 4
      ebpftracer/tracer/socket.go
  20. 55 3
      flags/flags.go
  21. 5 2
      go.mod
  22. 6 0
      go.sum
  23. 4 0
      main.go
  24. 1 0
      pkg/go.opentelemetry.io/otel/exporters/otlp/otlptrace/apm_exporter.go
  25. 2 3
      pkg/go.opentelemetry.io/otel/exporters/otlp/otlptrace/go.mod
  26. 0 2
      pkg/go.opentelemetry.io/otel/exporters/otlp/otlptrace/go.sum
  27. 3 3
      pkg/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/client_apm.go
  28. 23 2
      pkg/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/go.mod
  29. 141 23
      pkg/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/go.sum
  30. 1 3
      pkg/lumberjack/go.mod
  31. 5 5
      tracing/apm_tracing.go
  32. 1 0
      utils/enums/enums.go
  33. 21 189
      utils/id.go
  34. 22 0
      utils/modelse/app_info.go
  35. 9 10
      utils/modelse/bpf_struct.go
  36. 1 1
      utils/modelse/code_type.go
  37. 59 0
      utils/modelse/id.go
  38. 15 0
      utils/modelse/status.go
  39. 110 0
      utils/try/try.go
  40. 2 7
      utils/util.go
  41. 2 2
      utils/worker/serverWorker.go

+ 0 - 19
common/app_info.go

@@ -1,19 +0,0 @@
-package common
-
-const (
-	APP_NAME    = "app_name"
-	APP_ID      = "app_id"
-	AGENT_ID    = "agent_id"
-	INSTANCE_ID = "instance_id"
-)
-
-type AppInfo struct {
-	AppName     string   `json:"app_name"`
-	AppId       int64    `json:"app_id"`
-	AgentId     int64    `json:"agent_id"`
-	InstanceId  int64    `json:"instance_id"`
-	Sn          string   `json:"sn"`
-	Sport       int      `json:"sport"`
-	ServiceName string   `json:"service_name"`
-	CodeType    CodeType `json:"code_type"`
-}

+ 23 - 47
containers/apm_register_app.go

@@ -5,17 +5,20 @@ import (
 	"github.com/coroot/coroot-node-agent/utils"
 	. "github.com/coroot/coroot-node-agent/utils/modelse"
 	klog "github.com/sirupsen/logrus"
+	"time"
 )
 
 func (c *Container) RegisterAppInfo(r *Registry, pid uint32) error {
 	if c.WhiteSettingInfo.AppName == "" {
-		return fmt.Errorf("AppName is empty")
+		return fmt.Errorf("appname is empty.")
 	}
 	var err error
 	originAppName := c.AppInfo.AppName
 	whiteAppName := c.WhiteSettingInfo.AppName
 	if originAppName != whiteAppName {
-		c.AppInfo.AppId, err = utils.BuildInt64ID(whiteAppName).ToInt64()
+		//c.AppInfo.AppId, err = utils.BuildInt64ID(whiteAppName).ToInt64()
+		c.AppInfo.AppIdHash.IntVal, err = utils.BuildInt64ID(whiteAppName).ToInt64()
+		c.AppInfo.AppIdHash.HashtVal = utils.BuildInt64ID(whiteAppName).ToHashByte()
 		if err != nil {
 			return err
 		}
@@ -23,9 +26,10 @@ func (c *Container) RegisterAppInfo(r *Registry, pid uint32) error {
 		// 注册
 		hostId, _ := utils.GetHostID()
 		registerAppReq := RegisterAppReq{
-			AppId:       c.AppInfo.AppId,
-			AppName:     c.WhiteSettingInfo.AppName,
-			AccountId:   110,
+			AppId:   c.AppInfo.AppIdHash.IntVal,
+			AppName: c.WhiteSettingInfo.AppName,
+			// todo AccountId
+			AccountId:   utils.GetAccountID(),
 			AgentId:     c.AppInfo.AgentId,
 			Sn:          c.AppInfo.Sn,
 			Sport:       c.AppInfo.Sport,
@@ -34,56 +38,28 @@ func (c *Container) RegisterAppInfo(r *Registry, pid uint32) error {
 			App_type:    1,
 			HostId:      hostId,
 		}
-		klog.Infof("Register App: %s", registerAppReq.String())
+		klog.Infof("[register] Register App: %s.", registerAppReq.String())
 		err = r.connServer.RegisterApp(registerAppReq)
 		if err != nil {
-			klog.WithError(err).Errorf("Failed Register App %s", registerAppReq.String())
+			klog.WithError(err).Errorf("[register] Failed Register App %s.", registerAppReq.String())
 			return err
 		}
 
 		c.AppInfo.AppName = c.WhiteSettingInfo.AppName
 
-	}
-
-	// ip:port + process_name + exe路径生成
-	//c.instanceID.IntVal + proc.GetExe(pid)
-	//c.AppInfo.AgentId =
-
-	return nil
-}
-
-func (c *Container) TestRegisterAppInfo(r *Registry) error {
-	var err error
-	c.AppInfo.AppName = "eBPF-APP"
-	c.AppInfo.AppId, err = utils.BuildInt64ID(c.AppInfo.AppName).ToInt64()
-	if err != nil {
-		return err
-	}
-	c.AppInfo.ServiceName = c.AppInfo.CodeType.ServiceTypeString()
-	// 注册
-	hostId, _ := utils.GetHostID()
-	registerAppReq := RegisterAppReq{
-		AppId:       c.AppInfo.AppId,
-		AppName:     c.AppInfo.AppName,
-		AccountId:   110,
-		AgentId:     c.AppInfo.AgentId,
-		Sn:          c.AppInfo.Sn,
-		Sport:       c.AppInfo.Sport,
-		ServiceType: c.AppInfo.ServiceName,
-		CodeType:    c.AppInfo.CodeType.Int(),
-		App_type:    1,
-		HostId:      hostId,
-	}
-	registerAppReq.Print()
+		if originAppName == "" {
+			c.AppInfo.RegisterAt = time.Now().Unix()
+		}
 
-	err = r.connServer.RegisterApp(registerAppReq)
-	if err != nil {
-		return err
+		if originAppName != "" && c.checkL7AttachReady() {
+			klog.Infoln("[kprobe] reset kernel proc_info.")
+			err = r.tracer.InitKProcInfo(pid, &c.AppInfo)
+			if err != nil {
+				klog.WithError(err).Errorf("[kprobe] Failed reset KProcInfo.")
+				return err
+			}
+			c.AppInfo.UpdateAt = time.Now().Unix()
+		}
 	}
-
-	// ip:port + process_name + exe路径生成
-	//c.instanceID.IntVal + proc.GetExe(pid)
-	//c.AppInfo.AgentId =
-
 	return nil
 }

+ 3 - 2
containers/apm_white_list.go

@@ -2,13 +2,14 @@ package containers
 
 import (
 	"github.com/coroot/coroot-node-agent/common"
+	"github.com/coroot/coroot-node-agent/utils"
 	. "github.com/coroot/coroot-node-agent/utils/modelse"
 	log "github.com/sirupsen/logrus"
 )
 
 type WhiteListMap map[string][]WhiteSettingInfo
 
-func (r *Registry) getWhiteListByCodeType(codeType common.CodeType) []WhiteSettingInfo {
+func (r *Registry) getWhiteListByCodeType(codeType CodeType) []WhiteSettingInfo {
 	return r.whiteListRules[codeType.WhiteCodeString()]
 }
 
@@ -31,7 +32,7 @@ func (r *Registry) getWhiteList() (bool, error) {
 	//fmt.Println(hostId)
 	whiteListReq := WhiteListReq{
 		HostId:    10154813500555812,
-		AccountId: 110,
+		AccountId: utils.GetAccountID(),
 	}
 	whiteData, err := r.connServer.WhiteList(whiteListReq)
 

+ 15 - 17
containers/container.go

@@ -8,8 +8,6 @@ import (
 	"sync"
 	"time"
 
-	"github.com/coroot/coroot-node-agent/utils"
-
 	"github.com/coroot/coroot-node-agent/cgroup"
 	"github.com/coroot/coroot-node-agent/common"
 	"github.com/coroot/coroot-node-agent/ebpftracer"
@@ -148,8 +146,8 @@ type Container struct {
 
 	done chan struct{}
 
-	traceMap     map[uint64]*tracing.Trace
-	instanceID   utils.ID
+	traceMap map[uint64]*tracing.Trace
+	//instanceID   utils.ID
 	Symbols      []debugelf.Symbol
 	Uprobes      []tracer.Uprobe
 	UprobesMap   map[string]tracer.Uprobe
@@ -158,7 +156,7 @@ type Container struct {
 	// 白名单详情
 	WhiteSettingInfo WhiteSettingInfo
 	// 应用详情
-	AppInfo common.AppInfo
+	AppInfo AppInfo
 }
 
 func NewContainer(id ContainerID, cg *cgroup.Cgroup, md *ContainerMetadata, hostConntrack *Conntrack, pid uint32) (*Container, error) {
@@ -1106,13 +1104,13 @@ func (c *Container) attachUprobes(tracer *ebpftracer.Tracer, pid uint32) error {
 	}
 	var err error
 	switch codeType {
-	case common.CodeTypeJava:
+	case CodeTypeJava:
 		err = c.attachJVMUprobes(tracer, pid)
-	case common.CodeTypeJavaAot:
+	case CodeTypeJavaAot:
 		err = c.attachJVMUprobes(tracer, pid)
-	case common.CodeTypeGo:
+	case CodeTypeGo:
 		err = c.attachTlsUprobes(tracer, pid)
-	case common.CodeTypeNetCoreAot:
+	case CodeTypeNetCoreAot:
 		err = c.attachNetCoreUprobes(tracer, pid)
 	}
 	if err != nil {
@@ -1123,10 +1121,10 @@ func (c *Container) attachUprobes(tracer *ebpftracer.Tracer, pid uint32) error {
 	return nil
 }
 
-func (c *Container) GetCodeTypeFromCache(pid uint32) common.CodeType {
+func (c *Container) GetCodeTypeFromCache(pid uint32) CodeType {
 	p := c.processes[pid]
 	if p == nil {
-		return common.CodeTypeUnknown
+		return CodeTypeUnknown
 	}
 	if p.codeType.IsWaitCheck() {
 		p.codeType = GetExeType(pid)
@@ -1149,7 +1147,7 @@ func (c *Container) attachTlsUprobes(tracer *ebpftracer.Tracer, pid uint32) erro
 	}
 	if !p.goTlsUprobesChecked {
 		codeType := c.GetCodeTypeFromCache(pid)
-		goProbes, err := tracer.AttachGoTlsUprobes(pid, c.instanceID, uint16(codeType))
+		goProbes, err := tracer.AttachGoTlsUprobes(pid, &c.AppInfo, uint16(codeType))
 		if err != nil {
 			return err
 		}
@@ -1169,7 +1167,7 @@ func (c *Container) attachJVMUprobes(tracer *ebpftracer.Tracer, pid uint32) erro
 	}
 	codeType := c.GetCodeTypeFromCache(pid)
 	if !p.jvmUprobesChecked {
-		tracer.InitKProcInfo(pid, c.instanceID, uint16(codeType))
+		tracer.InitKProcInfo(pid, &c.AppInfo)
 
 		libNioProbes, err := tracer.AttachJavaNioReadUprobes(pid, codeType)
 		if err != nil {
@@ -1207,17 +1205,17 @@ func (c *Container) attachNetCoreUprobes(tracer *ebpftracer.Tracer, pid uint32)
 		return nil
 	}
 	if !p.jvmUprobesChecked {
-		codeType := c.GetCodeTypeFromCache(pid)
-		tracer.InitKProcInfo(pid, c.instanceID, uint16(codeType))
+		//codeType := c.GetCodeTypeFromCache(pid)
+		tracer.InitKProcInfo(pid, &c.AppInfo)
 
-		readProbes, err := tracer.AttachNetCoreNetReadUprobes(pid, c.instanceID)
+		readProbes, err := tracer.AttachNetCoreNetReadUprobes(pid)
 		if err != nil {
 			klog.Error(err)
 			return err
 		}
 		p.uprobes = append(p.uprobes, readProbes...)
 
-		WriteProbes, err := tracer.AttachNetCoreNetWriteUprobes(pid, c.instanceID)
+		WriteProbes, err := tracer.AttachNetCoreNetWriteUprobes(pid)
 		if err != nil {
 			klog.Error(err)
 			return err

+ 84 - 77
containers/container_apm.go

@@ -4,13 +4,13 @@ import (
 	"bufio"
 	"debug/elf"
 	"fmt"
-	"github.com/coroot/coroot-node-agent/common"
 	"github.com/coroot/coroot-node-agent/ebpftracer"
 	"github.com/coroot/coroot-node-agent/ebpftracer/l7"
 	"github.com/coroot/coroot-node-agent/ebpftracer/tracer"
 	"github.com/coroot/coroot-node-agent/proc"
 	"github.com/coroot/coroot-node-agent/tracing"
 	"github.com/coroot/coroot-node-agent/utils"
+	. "github.com/coroot/coroot-node-agent/utils/modelse"
 	"github.com/pkg/errors"
 	klog "github.com/sirupsen/logrus"
 	"inet.af/netaddr"
@@ -21,6 +21,8 @@ import (
 	"time"
 )
 
+const TRACE_STATUS = 1
+
 func (c *Container) getTrace(traceId uint64) (*tracing.Trace, bool) {
 	trace, ok := c.traceMap[traceId]
 	return trace, ok
@@ -86,12 +88,12 @@ func (c *Container) onL7RequestApm(pid uint32, fd uint64, timestamp uint64, r *l
 		return c.onDNSRequest(r)
 	}
 
-	if !c.valuableTrace(r.TraceId) {
-		return nil
-	}
+	//if !c.valuableTrace(r.TraceId) {
+	//	return nil
+	//}
 
-	if r.Protocol == l7.ProtocolTrace {
-		if r.TraceStart == 1 {
+	if r.Protocol == l7.ProtocolTrace && c.l7Attach && c.valuableTrace(r.TraceId) {
+		if r.TraceStart == TRACE_STATUS {
 			klog.Infof("====ProtocolTrace start==== %d %d", pid, r.TraceId)
 			trace, err := c.getOrInitTrace(r.TraceId)
 			if err == nil {
@@ -104,7 +106,7 @@ func (c *Container) onL7RequestApm(pid uint32, fd uint64, timestamp uint64, r *l
 
 			return nil
 		}
-		if r.TraceEnd == 1 {
+		if r.TraceEnd == TRACE_STATUS {
 			klog.Infof("====ProtocolTrace end==== %d %d", pid, r.TraceId)
 			trace, err := c.getOrInitTrace(r.TraceId)
 			if err == nil {
@@ -115,22 +117,16 @@ func (c *Container) onL7RequestApm(pid uint32, fd uint64, timestamp uint64, r *l
 		}
 	}
 	if r.Protocol == l7.ProtocolHTTP {
-		//stats.observe(r.Status.Http(), "", r.Duration)
-		method, path, hostIp, port := l7.ParseHttpHost(r.Payload)
-		//trace.HttpRequest(method, path, r.Status, r.Duration)
-
-		//apmTrace, ok := c.getTrace(r.TraceId)
-		//if ok {
-		//	apmTrace.HttpTraceRequest(method, path, hostIp, port, r)
-		//}
-
-		apmTrace, err := c.getOrInitTrace(r.TraceId)
-		fmt.Println("ProtocolHTTP-----", r.TraceId, err)
-		if err == nil {
-			apmTrace.HttpTraceRequestEvent(method, path, hostIp, port, r)
-			c.SendEvent(apmTrace, r.TraceId)
+		if c.l7Attach && c.valuableTrace(r.TraceId) {
+			method, path, hostIp, port := l7.ParseHttpHost(r.Payload)
+			apmTrace, err := c.getOrInitTrace(r.TraceId)
+			//fmt.Println("ProtocolHTTP-----", r.TraceId, err)
+			if err == nil {
+				apmTrace.HttpTraceRequestEvent(method, path, hostIp, port, r)
+				c.SendEvent(apmTrace, r.TraceId)
+			}
 		}
-		return nil
+		//return nil
 	}
 	conn := c.connectionsByPidFd[PidFd{Pid: pid, Fd: fd}]
 	//fmt.Println("l7.connectionsByPidFd", conn, pid, fd)
@@ -142,19 +138,10 @@ func (c *Container) onL7RequestApm(pid uint32, fd uint64, timestamp uint64, r *l
 		return nil
 	}
 	stats := c.l7Stats.get(r.Protocol, conn.Dest, conn.ActualDest)
-	trace := tracing.NewTrace(string(c.id), conn.ActualDest)
+	//trace := tracing.NewTrace(string(c.id), conn.ActualDest)
 	switch r.Protocol {
 	case l7.ProtocolHTTP:
-		//fmt.Println("l7.ProtocolHTTP", r.TraceId)
-		////stats.observe(r.Status.Http(), "", r.Duration)
-		//method, path, hostIp, port := l7.ParseHttpHost(r.Payload)
-		////trace.HttpRequest(method, path, r.Status, r.Duration)
-		//
-		//apmTrace, ok := c.getTrace(r.TraceId)
-		//if ok {
-		//	apmTrace.HttpTraceRequest(method, path, hostIp, port, r)
-		//}
-
+		stats.observe(r.Status.Http(), "", r.Duration)
 	case l7.ProtocolHTTP2:
 		if conn.http2Parser == nil {
 			conn.http2Parser = l7.NewHttp2Parser()
@@ -162,64 +149,80 @@ func (c *Container) onL7RequestApm(pid uint32, fd uint64, timestamp uint64, r *l
 		requests := conn.http2Parser.Parse(r.Method, r.Payload, uint64(r.Duration))
 		for _, req := range requests {
 			stats.observe(req.Status.Http(), "", req.Duration)
-			trace.Http2Request(req.Method, req.Path, req.Scheme, req.Status, req.Duration)
+			//trace.Http2Request(req.Method, req.Path, req.Scheme, req.Status, req.Duration)
 		}
 	case l7.ProtocolPostgres:
-		//if r.Method != l7.MethodStatementClose {
-		//	stats.observe(r.Status.String(), "", r.Duration)
-		//}
+		if r.Method != l7.MethodStatementClose {
+			stats.observe(r.Status.String(), "", r.Duration)
+		}
 		//if conn.postgresParser == nil {
 		//	conn.postgresParser = l7.NewPostgresParser()
 		//}
 		//query := conn.postgresParser.Parse(r.Payload)
 		//trace.PostgresQuery(query, r.Status.Error(), r.Duration)
 	case l7.ProtocolMysql:
-		//fmt.Println("mysql mysql")
-		//fmt.Println(conn)
 		if r.Method != l7.MethodStatementClose {
 			stats.observe(r.Status.String(), "", r.Duration)
 		}
-		if conn.mysqlParser == nil {
-			conn.mysqlParser = l7.NewMysqlParser()
-		}
-		query := conn.mysqlParser.Parse(r.Payload, r.StatementId)
-		//trace.MysqlQuery(query, r.Status.Error(), r.Duration)
-
-		//apmTrace, ok := c.getTrace(r.TraceId)
-		apmTrace, err := c.getOrInitTrace(r.TraceId)
-		//fmt.Println("mysql r.TraceId:", r.TraceId)
-		//fmt.Println("ok:", ok)
-		//fmt.Println("traceMap:", len(c.traceMap))
-		if err == nil {
-			//apmTrace.MysqlTraceQuery(query, r.Status.Error(), r.Duration, conn.ActualDest)
-			apmTrace.MysqlTraceQueryEvent(query, r, conn.ActualDest)
-			c.SendEvent(apmTrace, r.TraceId)
+		if c.l7Attach && c.valuableTrace(r.TraceId) {
+			if conn.mysqlParser == nil {
+				conn.mysqlParser = l7.NewMysqlParser()
+			}
+			query := conn.mysqlParser.Parse(r.Payload, r.StatementId)
+			//trace.MysqlQuery(query, r.Status.Error(), r.Duration)
+
+			//apmTrace, ok := c.getTrace(r.TraceId)
+			apmTrace, err := c.getOrInitTrace(r.TraceId)
+			//fmt.Println("mysql r.TraceId:", r.TraceId)
+			//fmt.Println("ok:", ok)
+			//fmt.Println("traceMap:", len(c.traceMap))
+			if err == nil {
+				//apmTrace.MysqlTraceQuery(query, r.Status.Error(), r.Duration, conn.ActualDest)
+				apmTrace.MysqlTraceQueryEvent(query, r, conn.ActualDest)
+				c.SendEvent(apmTrace, r.TraceId)
+			}
 		}
 	case l7.ProtocolMemcached:
-		//stats.observe(r.Status.String(), "", r.Duration)
+		stats.observe(r.Status.String(), "", r.Duration)
+		if c.l7Attach && c.valuableTrace(r.TraceId) {
+
+		}
+
 		//cmd, items := l7.ParseMemcached(r.Payload)
 		//trace.MemcachedQuery(cmd, items, r.Status.Error(), r.Duration)
 	case l7.ProtocolRedis:
 		stats.observe(r.Status.String(), "", r.Duration)
-		cmd, args := l7.ParseRedis(r.Payload)
-		fmt.Println("cmd", cmd)
-		fmt.Println("args", args)
-		//apmTrace, ok := c.getTrace(r.TraceId)
-		apmTrace, err := c.getOrInitTrace(r.TraceId)
-		if err == nil {
-			//apmTrace.RedisTraceQuery(cmd, args, r.Status.Error(), r.Duration)
-			apmTrace.RedisTraceQueryEvent(cmd, args, r, conn.ActualDest)
-			c.SendEvent(apmTrace, r.TraceId)
+		if c.l7Attach && c.valuableTrace(r.TraceId) {
+			cmd, args := l7.ParseRedis(r.Payload)
+			//fmt.Println("cmd", cmd)
+			//fmt.Println("args", args)
+			//apmTrace, ok := c.getTrace(r.TraceId)
+			apmTrace, err := c.getOrInitTrace(r.TraceId)
+			if err == nil {
+				//apmTrace.RedisTraceQuery(cmd, args, r.Status.Error(), r.Duration)
+				apmTrace.RedisTraceQueryEvent(cmd, args, r, conn.ActualDest)
+				c.SendEvent(apmTrace, r.TraceId)
+			}
 		}
 		//trace.RedisQuery(cmd, args, r.Status.Error(), r.Duration)
 	case l7.ProtocolMongo:
-		//stats.observe(r.Status.String(), "", r.Duration)
+		stats.observe(r.Status.String(), "", r.Duration)
+		if c.l7Attach && c.valuableTrace(r.TraceId) {
+		}
 		//query := l7.ParseMongo(r.Payload)
 		//trace.MongoQuery(query, r.Status.Error(), r.Duration)
 	case l7.ProtocolKafka, l7.ProtocolCassandra:
-		//stats.observe(r.Status.String(), "", r.Duration)
+		stats.observe(r.Status.String(), "", r.Duration)
+		if c.l7Attach && c.valuableTrace(r.TraceId) {
+		}
 	case l7.ProtocolRabbitmq, l7.ProtocolNats:
-		//stats.observe(r.Status.String(), r.Method.String(), 0)
+		stats.observe(r.Status.String(), r.Method.String(), 0)
+		if c.l7Attach && c.valuableTrace(r.TraceId) {
+		}
+	case l7.ProtocolDubbo2:
+		stats.observe(r.Status.String(), "", r.Duration)
+		if c.l7Attach && c.valuableTrace(r.TraceId) {
+		}
 	}
 	return nil
 }
@@ -241,9 +244,9 @@ func (c *Container) buildIDs(pid uint32) bool {
 				c.AppInfo.Sn = ip.String()
 				c.AppInfo.Sport = int(port)
 				strInstanceID := utils.BuildInt64ID(fmt.Sprintf("%s:%d", ip.String(), port))
-				c.instanceID.IntVal, _ = strInstanceID.ToInt64()
-				c.instanceID.HashtVal = strInstanceID.ToHashByte()
-				c.AppInfo.InstanceId = c.instanceID.IntVal
+				c.AppInfo.InstanceIdHash.IntVal, _ = strInstanceID.ToInt64()
+				c.AppInfo.InstanceIdHash.HashtVal = strInstanceID.ToHashByte()
+				//c.AppInfo.InstanceId = c.instanceID.IntVal
 				strAgentID := utils.BuildInt64ID(fmt.Sprintf("%s:%s", strInstanceID, string(proc.GetExe(pid))))
 				c.AppInfo.AgentId, _ = strAgentID.ToInt64()
 				c.AppInfo.CodeType = c.GetCodeTypeFromCache(pid)
@@ -414,22 +417,24 @@ func (c *Container) GetUprobe(event ebpftracer.StackEvent, tracer *ebpftracer.Tr
 	return
 }
 
-func (c *Container) GetAppInfo() common.AppInfo {
+func (c *Container) GetAppInfo() AppInfo {
 	return c.AppInfo
 }
 
-func (c *Container) eventReady() {
+// 可注入前置
+func (c *Container) checkEventReady() bool {
 	c.lock.Lock()
 	defer c.lock.Unlock()
-	c.l7EventReady = true
+	return c.l7EventReady
 }
 
-func (c *Container) checkEventReady() bool {
+func (c *Container) eventReady() {
 	c.lock.Lock()
 	defer c.lock.Unlock()
-	return c.l7EventReady
+	c.l7EventReady = true
 }
 
+// uprobe前置
 func (c *Container) checkL7AttachReady() bool {
 	c.lock.Lock()
 	defer c.lock.Unlock()
@@ -437,6 +442,8 @@ func (c *Container) checkL7AttachReady() bool {
 }
 
 func (c *Container) l7AttachSuccess() {
+	c.lock.Lock()
+	defer c.lock.Unlock()
 	c.l7Attach = true
 }
 
@@ -467,7 +474,6 @@ func (c *Container) verifyAttachConditions(r *Registry, pid uint32) bool {
 				klog.WithField("pid", pid).
 					WithField("ruleVal", ruleVal).
 					WithField("cmdline", cmdline).
-					WithField("event ready", c.checkEventReady()).
 					Infoln("[verify] check successful.")
 				return true
 			}
@@ -482,9 +488,10 @@ func (c *Container) detachUprobes(pid uint32) {
 	// close uprobe
 	if p := c.processes[pid]; p != nil {
 		if len(p.uprobes) > 0 {
-			fmt.Println("卸载---", pid)
+			klog.Infof("detachUprobes", pid)
 			p.DynamicClose()
 			c.l7Attach = false
+			c.AppInfo = AppInfo{}
 		}
 	}
 }

+ 2 - 2
containers/process.go

@@ -2,7 +2,7 @@ package containers
 
 import (
 	"context"
-	"github.com/coroot/coroot-node-agent/common"
+	. "github.com/coroot/coroot-node-agent/utils/modelse"
 	"os"
 	"time"
 
@@ -29,7 +29,7 @@ type Process struct {
 	jvmUprobesChecked     bool
 	stackUprobesChecked   bool
 
-	codeType common.CodeType
+	codeType CodeType
 	cmdline  string
 }
 

+ 37 - 13
containers/registry.go

@@ -4,6 +4,8 @@ import (
 	"bytes"
 	"fmt"
 	. "github.com/coroot/coroot-node-agent/utils"
+	"github.com/coroot/coroot-node-agent/utils/enums"
+	"github.com/coroot/coroot-node-agent/utils/modelse"
 	"github.com/coroot/coroot-node-agent/utils/try"
 	. "github.com/coroot/coroot-node-agent/utils/worker"
 	log "github.com/sirupsen/logrus"
@@ -184,25 +186,26 @@ func (r *Registry) handleEvents(ch <-chan ebpftracer.Event) {
 			if err != nil {
 				log.WithError(err).Errorf("connWhiteList error")
 			}
+			runtimeApps := make(map[uint32]modelse.AppStatusInfo)
 			for pid, c := range r.containersByPid {
 				if !common.IsOpenFilter() {
 					verifyAttachConditions := c.verifyAttachConditions(r, pid)
 					if verifyAttachConditions {
 						err = c.RegisterAppInfo(r, pid)
 						if err == nil {
-							klog.WithField("pid", pid).Infoln("[Registry] Attach uprobes.")
+							klog.WithField("pid", pid).Infoln("[registry] Attach uprobes.")
 							err = c.attachUprobes(r.tracer, pid)
 							if err != nil {
-								klog.WithField("pid", pid).WithError(err).Errorf("[Registry] Failed attach uprobes error!")
+								klog.WithField("pid", pid).WithError(err).Errorf("[registry] Failed attach uprobes error!")
 							} else {
-								klog.WithField("pid", pid).Infoln("[Registry] Attach uprobes success!")
+								klog.WithField("pid", pid).Infoln("[registry] Attach uprobes success!")
 							}
-							klog.WithField("pid", pid).Infoln("[Registry] Attach app stack.")
+							klog.WithField("pid", pid).Infoln("[registry] Attach app stack.")
 							err = c.stackTrace(r.tracer, pid)
 							if err != nil {
-								klog.WithField("pid", pid).WithError(err).Errorf("[Registry][end] Failed attach stack trace!")
+								klog.WithField("pid", pid).WithError(err).Errorf("[registry][end] Failed attach stack trace!")
 							} else {
-								klog.WithField("pid", pid).Infoln("[Registry] Attach Stack success!")
+								klog.WithField("pid", pid).Infoln("[registry] Attach Stack success!")
 							}
 						}
 					}
@@ -212,6 +215,25 @@ func (r *Registry) handleEvents(ch <-chan ebpftracer.Event) {
 						c.detachUprobes(pid)
 					}
 				}
+				if c.AppInfo.AppName != "" {
+					detail := modelse.AppStatusInfo{
+						Pid:        pid,
+						ProcName:   c.containerName,
+						AppName:    c.AppInfo.AppName,
+						Language:   c.AppInfo.CodeType.String(),
+						AppID:      c.AppInfo.AppIdHash.IntVal,
+						AgentID:    c.AppInfo.AgentId,
+						InstanceID: c.AppInfo.InstanceIdHash.IntVal,
+						Sn:         c.AppInfo.Sn,
+						Sport:      c.AppInfo.Sport,
+						RegisterAt: time.Unix(c.AppInfo.RegisterAt, 0).Format("060102 15:04:05"),
+					}
+					if c.AppInfo.UpdateAt != 0 {
+						detail.UpdateAt = time.Unix(c.AppInfo.UpdateAt, 0).Format("060102 15:04:05")
+					}
+
+					runtimeApps[pid] = detail
+				}
 
 				cg, err := proc.ReadCgroup(pid)
 				if err != nil {
@@ -225,8 +247,9 @@ func (r *Registry) handleEvents(ch <-chan ebpftracer.Event) {
 					delete(r.containersByPid, pid)
 					c.onProcessExit(pid, false)
 				}
-
 			}
+			saveAppInfo(runtimeApps)
+
 			activeIPs := map[netaddr.IP]struct{}{}
 			for id, c := range r.containersById {
 				if !c.Dead(now) {
@@ -309,7 +332,8 @@ func (r *Registry) handleEvents(ch <-chan ebpftracer.Event) {
 						c.eventReady()
 					}
 					if common.IsOpenFilter() && common.IsFilterPid(e.Pid) {
-						c.TestRegisterAppInfo(r)
+						c.WhiteSettingInfo.AppName = enums.TestApp
+						c.RegisterAppInfo(r, e.Pid)
 						c.attachUprobes(r.tracer, e.Pid)
 						err := c.stackTrace(r.tracer, e.Pid)
 						if err != nil {
@@ -325,7 +349,8 @@ func (r *Registry) handleEvents(ch <-chan ebpftracer.Event) {
 					c.onConnectionOpen(e.Pid, e.Fd, e.SrcAddr, e.DstAddr, e.Timestamp, false)
 					c.eventReady()
 					if common.IsOpenFilter() && common.IsFilterPid(e.Pid) {
-						c.TestRegisterAppInfo(r)
+						c.WhiteSettingInfo.AppName = enums.TestApp
+						c.RegisterAppInfo(r, e.Pid)
 						c.attachUprobes(r.tracer, e.Pid)
 						err := c.stackTrace(r.tracer, e.Pid)
 						if err != nil {
@@ -360,15 +385,14 @@ func (r *Registry) handleEvents(ch <-chan ebpftracer.Event) {
 					}
 				}
 			case ebpftracer.EventTypeL7Request:
-				//fmt.Println("EventTypeL7Request")
 				//fmt.Println("e.L7Request Payload:", string(e.L7Request.Payload))
 				if e.L7Request == nil {
 					continue
 				}
 				if c := r.containersByPid[e.Pid]; c != nil {
-					if !c.checkL7AttachReady() {
-						continue
-					}
+					//fmt.Println("EventTypeL7Request", e.Pid, c.checkL7AttachReady())
+					//a, _ := json.Marshal(e.L7Request)
+					//fmt.Println("EventTypeL7Request", e.Pid, string(a))
 					ip2fqdn := c.onL7RequestApm(e.Pid, e.Fd, e.Timestamp, e.L7Request)
 					r.ip2fqdnLock.Lock()
 					for ip, fqdn := range ip2fqdn {

+ 21 - 0
containers/registry_apm.go

@@ -1,8 +1,14 @@
 package containers
 
 import (
+	"encoding/json"
 	"fmt"
+	"github.com/coroot/coroot-node-agent/utils"
+	"github.com/coroot/coroot-node-agent/utils/modelse"
 	"github.com/prometheus/client_golang/prometheus"
+	"github.com/sirupsen/logrus"
+	"os"
+	"path"
 )
 
 const (
@@ -29,3 +35,18 @@ func setK8sTag(c *Container, tag map[string]string, pid uint32) {
 	c.K8sContainer.containerName = tag[ProcessName]
 	c.K8sContainer.pid = sPid
 }
+
+func saveAppInfo(runtimeApps map[uint32]modelse.AppStatusInfo) {
+	appStr, _ := json.Marshal(runtimeApps)
+	dumpPath := path.Join(utils.GetDefaultLogPath(), "memdump")
+	err := os.MkdirAll(dumpPath, 0755)
+	if err != nil {
+		logrus.Error(err)
+	}
+	fileName := fmt.Sprintf("%s.snap", "app")
+	metricsFileName := path.Join(dumpPath, fileName)
+	err = os.WriteFile(metricsFileName, appStr, 0644)
+	if err != nil {
+		logrus.Error(err)
+	}
+}

+ 9 - 9
containers/util.go

@@ -3,7 +3,7 @@ package containers
 import (
 	"debug/elf"
 	"fmt"
-	"github.com/coroot/coroot-node-agent/common"
+	. "github.com/coroot/coroot-node-agent/utils/modelse"
 	klog "github.com/sirupsen/logrus"
 	"io/ioutil"
 	"os"
@@ -15,13 +15,13 @@ import (
 
 var libjvmRegex = regexp.MustCompile(`.*/libjvm\.so`)
 
-func GetExeType(pid uint32) common.CodeType {
+func GetExeType(pid uint32) CodeType {
 	mapsFilePath := fmt.Sprintf("/proc/%d/maps", pid)
 
 	data, err := os.ReadFile(mapsFilePath)
 	if err != nil {
 		klog.WithError(err).Errorf("Failed to read %s: %s", mapsFilePath)
-		return common.CodeTypeUnknown
+		return CodeTypeUnknown
 	}
 
 	content := string(data)
@@ -30,20 +30,20 @@ func GetExeType(pid uint32) common.CodeType {
 		//fmt.Println("is java process")
 		if isJavaAotProcess(pid) {
 			//fmt.Println("is javaAot process")
-			return common.CodeTypeJavaAot
+			return CodeTypeJavaAot
 		}
-		return common.CodeTypeJava
+		return CodeTypeJava
 	} else if isJavaAotProcess(pid) {
 		//fmt.Println("is javaAot process")
-		return common.CodeTypeJavaAot
+		return CodeTypeJavaAot
 	} else if isGoProcess(pid) {
 		//fmt.Println("is go process")
-		return common.CodeTypeGo
+		return CodeTypeGo
 	} else if isNetCoreProcess(pid) {
 		//	fmt.Println("is netcore process")
-		return common.CodeTypeNetCoreAot
+		return CodeTypeNetCoreAot
 	}
-	return common.CodeTypeUnknown
+	return CodeTypeUnknown
 }
 
 // isJavaAotProcess checks if the process with the given PID is a GraalVM native image

+ 1 - 0
ebpftracer/ebpf/include/socket_trace_common.h

@@ -191,6 +191,7 @@ struct ebpf_proc_info {
 	__u64 start_addr;
 	__u64 end_addr;
 	unsigned char instance_id[APM_INSTANCE_ID_SIZE];
+	unsigned char app_id[APM_APP_ID_SIZE];
 	__u16 code_type;
 
 	__u64 method_ptr_pos;

+ 2 - 1
ebpftracer/ebpf/utrace/go/net/client.probe.bpf.c

@@ -647,7 +647,7 @@ int uprobe_Transport_roundTrip(struct pt_regs *ctx) {
 ////			cw_bpf_debug("[Client] host_id:%02x", trace_conf->host_id[i]);
 //		}
 		copy_byte_arrays(trace_conf->host_id, httpReq->apm_sc.host_id, APM_HOST_ID_SIZE);
-		copy_byte_arrays(trace_conf->app_id, httpReq->apm_sc.app_id, APM_APP_ID_SIZE);
+//		copy_byte_arrays(trace_conf->app_id, httpReq->apm_sc.app_id, APM_APP_ID_SIZE);
 	}
 
 	// __u64 pid_tgid = bpf_get_current_pid_tgid();
@@ -660,6 +660,7 @@ int uprobe_Transport_roundTrip(struct pt_regs *ctx) {
 //		}
 //	}
 	copy_byte_arrays(proc_info->instance_id, httpReq->apm_sc.instance_id, APM_APP_ID_SIZE);
+	copy_byte_arrays(proc_info->app_id, httpReq->apm_sc.app_id, APM_APP_ID_SIZE);
 
 	// set assumed_app_id
 	set_assumed_app_id_arrays(httpReq->host, httpReq->apm_sc.assumed_app_id, APM_ASSUMED_APP_ID_STRING_SIZE);

+ 2 - 1
ebpftracer/ebpf/utrace/java/net/client.probe.bpf.c

@@ -89,7 +89,7 @@ static __inline struct apm_span_context *build_sc(struct ebpf_proc_info *proc_in
 //			cw_bpf_debug("[Client] host_id:%02x", trace_conf->host_id[i]);
 //		}
 		copy_byte_arrays(trace_conf->host_id, cw_sc->host_id, APM_HOST_ID_SIZE);
-		copy_byte_arrays(trace_conf->app_id, cw_sc->app_id, APM_APP_ID_SIZE);
+//		copy_byte_arrays(trace_conf->app_id, cw_sc->app_id, APM_APP_ID_SIZE);
 	}
 
 //	__u64 pid_tgid = bpf_get_current_pid_tgid();
@@ -98,6 +98,7 @@ static __inline struct apm_span_context *build_sc(struct ebpf_proc_info *proc_in
 //			bpf_map_lookup_elem(&proc_info_map, &tgid);
 	if (proc_info) {
 		copy_byte_arrays(proc_info->instance_id, cw_sc->instance_id, APM_APP_ID_SIZE);
+		copy_byte_arrays(proc_info->app_id, cw_sc->app_id, APM_APP_ID_SIZE);
 	}
 
 	// set assumed_app_id

+ 2 - 2
ebpftracer/jvm.go

@@ -2,8 +2,8 @@ package ebpftracer
 
 import (
 	"errors"
-	"github.com/coroot/coroot-node-agent/common"
 	"github.com/coroot/coroot-node-agent/ebpftracer/tracer/inject"
+	. "github.com/coroot/coroot-node-agent/utils/modelse"
 	klog "github.com/sirupsen/logrus"
 	"io/ioutil"
 	"runtime"
@@ -25,7 +25,7 @@ const (
 	symbolsocketRead0 = "Java_sun_nio_ch_FileDispatcherImpl_read0"
 )
 
-func (t *Tracer) AttachJavaNioReadUprobes(pid uint32, codeType common.CodeType) ([]link.Link, error) {
+func (t *Tracer) AttachJavaNioReadUprobes(pid uint32, codeType CodeType) ([]link.Link, error) {
 	if t.DisableL7Tracing() {
 		return nil, nil
 	}

+ 2 - 4
ebpftracer/netcore.go

@@ -13,8 +13,6 @@ import (
 	"debug/elf"
 	"fmt"
 
-	"github.com/coroot/coroot-node-agent/utils"
-
 	"github.com/cilium/ebpf/link"
 )
 
@@ -164,7 +162,7 @@ func (t *Tracer) getFunctionOffsetDBG(libPath, functionName string) (elf.Symbol,
 	return elf.Symbol{}, fmt.Errorf("function %s not found", functionName)
 }
 
-func (t *Tracer) AttachNetCoreNetReadUprobes(pid uint32, insID utils.ID) ([]link.Link, error) {
+func (t *Tracer) AttachNetCoreNetReadUprobes(pid uint32) ([]link.Link, error) {
 	if t.DisableL7Tracing() {
 		return nil, nil
 	}
@@ -190,7 +188,7 @@ func (t *Tracer) AttachNetCoreNetReadUprobes(pid uint32, insID utils.ID) ([]link
 	return links, nil
 }
 
-func (t *Tracer) AttachNetCoreNetWriteUprobes(pid uint32, insID utils.ID) ([]link.Link, error) {
+func (t *Tracer) AttachNetCoreNetWriteUprobes(pid uint32) ([]link.Link, error) {
 	if t.DisableL7Tracing() {
 		return nil, nil
 	}

+ 14 - 12
ebpftracer/tls.go

@@ -7,19 +7,18 @@ import (
 	"debug/elf"
 	"errors"
 	"fmt"
-	"github.com/coroot/coroot-node-agent/ebpftracer/tracer"
-	"github.com/coroot/coroot-node-agent/utils"
-	"os"
-	"regexp"
-	"strconv"
-	"strings"
-
 	"github.com/cilium/ebpf/link"
+	"github.com/coroot/coroot-node-agent/ebpftracer/tracer"
 	"github.com/coroot/coroot-node-agent/proc"
+	. "github.com/coroot/coroot-node-agent/utils/modelse"
 	klog "github.com/sirupsen/logrus"
 	"golang.org/x/arch/arm64/arm64asm"
 	"golang.org/x/arch/x86/x86asm"
 	"golang.org/x/mod/semver"
+	"os"
+	"regexp"
+	"strconv"
+	"strings"
 )
 
 const (
@@ -115,13 +114,14 @@ func (t *Tracer) AttachOpenSslUprobes(pid uint32) ([]link.Link, error) {
 	return links, nil
 }
 
-func (t *Tracer) AttachGoTlsUprobes(pid uint32, insID utils.ID, codeType uint16) ([]link.Link, error) {
+func (t *Tracer) AttachGoTlsUprobes(pid uint32, appInfo *AppInfo, codeType uint16) ([]link.Link, error) {
 	if t.DisableL7Tracing() {
 		return nil, nil
 	}
 
 	path := proc.Path(pid, "exe")
-
+	instanceID := appInfo.InstanceIdHash.HashtVal
+	appID := appInfo.AppIdHash.HashtVal
 	var err error
 	var name, version string
 	log := func(msg string, err error) {
@@ -213,13 +213,14 @@ func (t *Tracer) AttachGoTlsUprobes(pid uint32, insID utils.ID, codeType uint16)
 			}
 			goVersion := ((major & 0xFF) << 16) + ((minor & 0xFF) << 8) + min(revision, 255)
 
-			info := tracer.EbpfProcInfo{}
+			info := EbpfProcInfo{}
 			info.Version = uint32(goVersion)
-			info.Offsets[tracer.OFFSET_IDX_GOID_RUNTIME_G] = uint16(offset)
+			info.Offsets[OFFSET_IDX_GOID_RUNTIME_G] = uint16(offset)
 			info.NetTCPConnItab = uint64(0)
 			info.CryptoTLSConnItab = uint64(0)
 			info.CredentialsSyscallConnItab = uint64(0)
-			info.InstanceId = insID.HashtVal
+			info.InstanceId = instanceID
+			info.AppId = appID
 			// go
 			info.MethodPtrPos = uint64(0)
 			info.UrlPtrPos = uint64(16)
@@ -248,6 +249,7 @@ func (t *Tracer) AttachGoTlsUprobes(pid uint32, insID utils.ID, codeType uint16)
 				klog.Error("failed to update program info", err)
 				return nil, err
 			}
+			appInfo.EBPFProcInfo = &info
 		}
 	}
 

+ 23 - 26
ebpftracer/tracer.go

@@ -19,7 +19,7 @@ import (
 	"github.com/coroot/coroot-node-agent/ebpftracer/l7"
 	"github.com/coroot/coroot-node-agent/ebpftracer/tracer"
 	"github.com/coroot/coroot-node-agent/proc"
-	"github.com/coroot/coroot-node-agent/utils"
+	. "github.com/coroot/coroot-node-agent/utils/modelse"
 	klog "github.com/sirupsen/logrus"
 	"golang.org/x/sys/unix"
 	"inet.af/netaddr"
@@ -280,7 +280,7 @@ func (t *Tracer) ebpf(ch chan<- Event) error {
 	if !t.DisableL7Tracing() {
 		perfMaps = append(perfMaps, perfMap{name: "l7_events", typ: perfMapTypeL7Events, perCPUBufferSizePages: 32})
 	}
-	perfMaps = append(perfMaps, perfMap{name: tracer.MAP_PERF_SOCKET_DATA_NAME, typ: perfMapTypeSocketEvents, perCPUBufferSizePages: 64})
+	perfMaps = append(perfMaps, perfMap{name: MAP_PERF_SOCKET_DATA_NAME, typ: perfMapTypeSocketEvents, perCPUBufferSizePages: 64})
 	klog.Infof("[start] Look eBPF perf_maps")
 	for _, pm := range perfMaps {
 		klog.Infoln(pm.name)
@@ -415,13 +415,13 @@ type l7Event struct {
 	TraceStart          uint32
 	TraceEnd            uint32
 	EventCount          uint32
-	AssumedAppId        utils.HashByte
-	SpanId              utils.HashByte
-	TraceIdFrom         utils.HashByte16
-	CalledId            utils.HashByte
-	InstanceIdFrom      utils.HashByte
-	AppIdFrom           utils.HashByte
-	SpanIdFrom          utils.HashByte
+	AssumedAppId        HashByte
+	SpanId              HashByte
+	TraceIdFrom         HashByte16
+	CalledId            HashByte
+	InstanceIdFrom      HashByte
+	AppIdFrom           HashByte
+	SpanIdFrom          HashByte
 }
 
 type SocketDataBufferddd struct {
@@ -710,28 +710,25 @@ func ipPort(ip [16]byte, port uint16) netaddr.IPPort {
 	return netaddr.IPPortFrom(i, port)
 }
 
-func (t *Tracer) InitKProcInfo(pid uint32, insID utils.ID, codeType uint16) error {
+func (t *Tracer) InitKProcInfo(pid uint32, appInfo *AppInfo) error {
 	var err error
-	info := tracer.EbpfProcInfo{}
-	info.InstanceId = insID.HashtVal
-	// 获取内存地址
-	//allocDetails, err := tracer.Allocate(int(pid))
-	//if err == nil && allocDetails != nil {
-	//	info.StartAddr = allocDetails.StartAddr
-	//	info.EndAddr = allocDetails.EndAddr
-	//}
-
-	info.CodeType = codeType
-	//klog.Infoln("Major:", major)
-	//klog.Infoln("Minor:", minor)
-	//klog.Infoln("Revision:", revision)
-	//klog.Infoln("goVersion", goVersion)
-	//klog.Infoln("info.StartAddr", info.StartAddr)
-	//klog.Infoln("info.EndAddr", info.EndAddr)
+	var info EbpfProcInfo
+	if appInfo.EBPFProcInfo == nil {
+		info = EbpfProcInfo{
+			InstanceId: appInfo.InstanceIdHash.HashtVal,
+			AppId:      appInfo.AppIdHash.HashtVal,
+			CodeType:   uint16(appInfo.CodeType),
+		}
+	} else {
+		info = *appInfo.EBPFProcInfo
+		info.AppId = appInfo.AppIdHash.HashtVal
+	}
+
 	_, err = tracer.UpdateProcInfoToMap(t.collection, pid, info)
 	if err != nil {
 		klog.Error("failed to update program info", err)
 	}
+	appInfo.EBPFProcInfo = &info
 	return err
 }
 

+ 4 - 3
ebpftracer/tracer/btf_vmlinux.go

@@ -6,6 +6,7 @@ import (
 	"fmt"
 	"github.com/cilium/ebpf"
 	"github.com/cilium/ebpf/btf"
+	. "github.com/coroot/coroot-node-agent/utils/modelse"
 	"runtime"
 )
 
@@ -115,12 +116,12 @@ func test(collectionSpec *ebpf.CollectionSpec, opts *ebpf.CollectionOptions) {
 		if err != nil {
 			fmt.Println("Failed to create map:", err)
 		}
-		data := &testStruct{
-			test_id: 123123123,
+		data := &TestStruct{
+			Test_id: 123123123,
 		}
 		// Convert test_t to slice
 		numCPU := runtime.NumCPU()
-		value := make([]testStruct, numCPU)
+		value := make([]TestStruct, numCPU)
 		for i := range value {
 			value[i] = *data
 		}

+ 2 - 1
ebpftracer/tracer/offset.go

@@ -6,8 +6,9 @@ import (
 	"errors"
 	"fmt"
 	"github.com/cilium/ebpf"
+	. "github.com/coroot/coroot-node-agent/utils/modelse"
+	klog "github.com/sirupsen/logrus"
 	"io"
-	"k8s.io/klog/v2"
 	"net"
 	"os"
 	"strings"

+ 5 - 4
ebpftracer/tracer/socket.go

@@ -5,6 +5,7 @@ import (
 	"github.com/cilium/ebpf"
 	"github.com/cilium/ebpf/btf"
 	"github.com/coroot/coroot-node-agent/utils"
+	. "github.com/coroot/coroot-node-agent/utils/modelse"
 	klog "github.com/sirupsen/logrus"
 	"net"
 	"os"
@@ -160,7 +161,7 @@ func set_conf_map_default(collectionSpec *ebpf.CollectionSpec, opts *ebpf.Collec
 	tConf := make([]any, numCPU)
 	for i := range tConf {
 		socketID := uint64(i)<<56 | uint64(uidBase)
-		tracerConf := traceConf{
+		tracerConf := EbpfTraceConf{
 			SocketID:               socketID,
 			CoroutineTraceID:       socketID,
 			ThreadTraceID:          socketID,
@@ -265,7 +266,7 @@ func update_offset_map_from_btf_vmlinux(collectionSpec *ebpf.CollectionSpec, opt
 		return ETR_NOTSUPP
 	}
 
-	offset := bpfOffsetParam{}
+	offset := BpfOffsetParam{}
 	offset.Ready = 1
 	offset.TaskFilesOffset = uint32(files_offs)
 	offset.SockFlagsOffset = uint32(sk_flags_offs)
@@ -294,7 +295,7 @@ func update_offset_map_from_btf_vmlinux(collectionSpec *ebpf.CollectionSpec, opt
 }
 
 func update_offset_map_default(collectionSpec *ebpf.CollectionSpec, opts *ebpf.CollectionOptions) int {
-	offset := bpfOffsetParam{}
+	offset := BpfOffsetParam{}
 
 	offset.StructFilesStructFdtOffset = 0x20
 	offset.StructFilesPrivateDataOffset = 0xc8
@@ -318,7 +319,7 @@ func update_offset_map_default(collectionSpec *ebpf.CollectionSpec, opts *ebpf.C
 	return ETR_OK
 }
 
-func update_offsets_table(collectionSpec *ebpf.CollectionSpec, opts *ebpf.CollectionOptions, offset bpfOffsetParam) int {
+func update_offsets_table(collectionSpec *ebpf.CollectionSpec, opts *ebpf.CollectionOptions, offset BpfOffsetParam) int {
 	numCPU := runtime.NumCPU()
 	offsetData := make([]any, numCPU)
 	for i := range offsetData {

+ 55 - 3
flags/flags.go

@@ -1,10 +1,15 @@
 package flags
 
 import (
+	"encoding/json"
+	"fmt"
+	"github.com/coroot/coroot-node-agent/utils"
+	"github.com/coroot/coroot-node-agent/utils/modelse"
+	"github.com/jedib0t/go-pretty/v6/table"
+	"gopkg.in/alecthomas/kingpin.v2"
 	"os"
+	"path"
 	"strings"
-
-	"gopkg.in/alecthomas/kingpin.v2"
 )
 
 var (
@@ -36,6 +41,7 @@ var (
 
 	ScrapeInterval = kingpin.Flag("scrape-interval", "How often to gather metrics from the agent").Default("15s").Envar("SCRAPE_INTERVAL").Duration()
 	WalDir         = kingpin.Flag("wal-dir", "Path to where the agent stores data (e.g. the metrics Write-Ahead Log)").Default("/tmp/coroot-node-agent").Envar("WAL_DIR").String()
+	DumpApps       = kingpin.Flag("dump", "Dump app snap").Default("false").Bool()
 )
 
 func GetString(fl *string) string {
@@ -52,7 +58,9 @@ func init() {
 
 	kingpin.HelpFlag.Short('h').Hidden()
 	kingpin.Parse()
-
+	if *DumpApps {
+		DumpTableFeatures()
+	}
 	if *CollectorEndpoint != nil {
 		u := *CollectorEndpoint
 		if *MetricsEndpoint == nil {
@@ -73,3 +81,47 @@ func init() {
 		*ListenAddress = "127.0.0.1:10300"
 	}
 }
+
+func DumpTableFeatures() {
+	dumpPath := path.Join(utils.GetDefaultLogPath(), "memdump")
+	fileName := path.Join(dumpPath, "app.snap")
+	content, err := os.ReadFile(fileName)
+	if err != nil {
+		fmt.Println(err.Error())
+	}
+
+	s := make(map[uint32]modelse.AppStatusInfo)
+	err = json.Unmarshal(content, &s)
+	if err != nil {
+		fmt.Println(err.Error())
+	}
+	t := table.NewWriter()
+	for pid, info := range s {
+		service := fmt.Sprintf("%s:%d", info.Sn, info.Sport)
+		t.AppendRow(table.Row{
+			pid,
+			info.ProcName,
+			info.AppName,
+			info.Language,
+			service,
+			info.AppID,
+			//info.AgentID,
+			info.RegisterAt,
+			info.UpdateAt,
+		})
+	}
+	t.SetAutoIndex(true)
+	t.AppendHeader(table.Row{
+		"pid",
+		"process",
+		"app name",
+		"code",
+		"service",
+		"app id",
+		//"agent id",
+		"register at",
+		"update at",
+	})
+	fmt.Println(t.Render())
+	os.Exit(0)
+}

+ 5 - 2
go.mod

@@ -19,9 +19,10 @@ require (
 	github.com/gomodule/redigo v1.9.2
 	github.com/grafana/pyroscope/ebpf v0.4.1
 	github.com/hashicorp/go-version v1.6.0
+	github.com/jedib0t/go-pretty/v6 v6.6.0
 	github.com/jpillora/backoff v1.0.0
 	github.com/mdlayher/taskstats v0.0.0-20230712191918-387b3d561d14
-	github.com/natefinch/lumberjack v0.0.0-00010101000000-000000000000
+	github.com/natefinch/lumberjack v0.0.0
 	github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417
 	github.com/pkg/errors v0.9.1
 	github.com/prometheus/client_golang v1.18.0
@@ -48,7 +49,6 @@ require (
 	gopkg.in/alecthomas/kingpin.v2 v2.2.6
 	gopkg.in/yaml.v2 v2.4.0
 	inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a
-	k8s.io/klog/v2 v2.120.1
 )
 
 require (
@@ -122,6 +122,7 @@ require (
 	github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
 	github.com/magiconair/properties v1.8.6 // indirect
 	github.com/mailru/easyjson v0.7.7 // indirect
+	github.com/mattn/go-runewidth v0.0.15 // indirect
 	github.com/mdlayher/genetlink v1.3.2 // indirect
 	github.com/mdlayher/netlink v1.7.2 // indirect
 	github.com/mdlayher/socket v0.4.1 // indirect
@@ -148,6 +149,7 @@ require (
 	github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
 	github.com/prometheus/common/sigv4 v0.1.0 // indirect
 	github.com/prometheus/procfs v0.12.0 // indirect
+	github.com/rivo/uniseg v0.2.0 // indirect
 	github.com/samber/lo v1.38.1 // indirect
 	github.com/sasha-s/go-deadlock v0.3.1 // indirect
 	github.com/shirou/gopsutil/v3 v3.22.10 // indirect
@@ -186,6 +188,7 @@ require (
 	gopkg.in/yaml.v3 v3.0.1 // indirect
 	k8s.io/apimachinery v0.28.6 // indirect
 	k8s.io/client-go v0.28.6 // indirect
+	k8s.io/klog/v2 v2.120.1 // indirect
 	k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
 )
 

+ 6 - 0
go.sum

@@ -686,6 +686,8 @@ github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLf
 github.com/ionos-cloud/sdk-go/v6 v6.1.11 h1:J/uRN4UWO3wCyGOeDdMKv8LWRzKu6UIkLEaes38Kzh8=
 github.com/ionos-cloud/sdk-go/v6 v6.1.11/go.mod h1:EzEgRIDxBELvfoa/uBN0kOQaqovLjUWEB7iW4/Q+t4k=
 github.com/j-keck/arping v0.0.0-20160618110441-2cf9dc699c56/go.mod h1:ymszkNOg6tORTn+6F6j+Jc8TOr5osrynvN6ivFWZ2GA=
+github.com/jedib0t/go-pretty/v6 v6.6.0 h1:wmZVuAcEkZRT+Aq1xXpE8IGat4vE5WXOMmBpbQqERXw=
+github.com/jedib0t/go-pretty/v6 v6.6.0/go.mod h1:zbn98qrYlh95FIhwwsbIip0LYpwSG8SUOScs+v9/t0E=
 github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
 github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
 github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
@@ -776,6 +778,8 @@ github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx
 github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
 github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
 github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
+github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
+github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
 github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o=
 github.com/mattn/go-shellwords v1.0.6/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o=
 github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
@@ -969,6 +973,8 @@ github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3c
 github.com/prometheus/prometheus v0.50.1 h1:N2L+DYrxqPh4WZStU+o1p/gQlBaqFbcLBTjlp3vpdXw=
 github.com/prometheus/prometheus v0.50.1/go.mod h1:FvE8dtQ1Ww63IlyKBn1V4s+zMwF9kHkVNkQBR1pM4CU=
 github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
+github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
+github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
 github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
 github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
 github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=

+ 4 - 0
main.go

@@ -35,6 +35,10 @@ var (
 
 const minSupportedKernelVersion = "4.16"
 
+func init() {
+	logs.FormatterInit()
+}
+
 func uname() (string, string, error) {
 	runtime.LockOSThread()
 	defer runtime.UnlockOSThread()

+ 1 - 0
pkg/go.opentelemetry.io/otel/exporters/otlp/otlptrace/apm_exporter.go

@@ -389,6 +389,7 @@ func buildLevelFromEvent(sdl *RootDataT) {
 func initRootDataFromEvent() RootDataT {
 	hostID, _ := utils.GetHostID()
 	data := RootDataT{
+		// todo AccountId
 		AccountId:      110,
 		AgentId:        0, // 基于 ip:port + process_name + exe路径生成
 		AgentVersion:   "2.1.0",

+ 2 - 3
pkg/go.opentelemetry.io/otel/exporters/otlp/otlptrace/go.mod

@@ -5,7 +5,7 @@ go 1.21
 toolchain go1.21.3
 
 require (
-	github.com/coroot/coroot-node-agent v0.0.0-00010101000000-000000000000
+	github.com/coroot/coroot-node-agent v0.0.0
 	github.com/google/go-cmp v0.6.0
 	github.com/stretchr/testify v1.8.4
 	go.opentelemetry.io/otel v1.22.0
@@ -30,7 +30,7 @@ require (
 	github.com/golang/protobuf v1.5.3 // indirect
 	github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
 	github.com/hashicorp/go-version v1.6.0 // indirect
-	github.com/natefinch/lumberjack v0.0.0-00010101000000-000000000000 // indirect
+	github.com/natefinch/lumberjack v0.0.0 // indirect
 	github.com/pkg/errors v0.9.1 // indirect
 	github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
 	github.com/sirupsen/logrus v1.9.3 // indirect
@@ -53,7 +53,6 @@ require (
 	gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
 	gopkg.in/yaml.v3 v3.0.1 // indirect
 	inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a // indirect
-	k8s.io/klog/v2 v2.120.1 // indirect
 )
 
 replace go.opentelemetry.io/otel => ../../..

+ 0 - 2
pkg/go.opentelemetry.io/otel/exporters/otlp/otlptrace/go.sum

@@ -176,5 +176,3 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
 gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a h1:1XCVEdxrvL6c0TGOhecLuB7U9zYNdxZEjvOqJreKZiM=
 inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a/go.mod h1:e83i32mAQOW1LAqEIweALsuK2Uw4mhQadA5r7b0Wobo=
-k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw=
-k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=

+ 3 - 3
pkg/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/client_apm.go

@@ -5,7 +5,7 @@ import (
 	"context"
 	"encoding/json"
 	"fmt"
-	"github.com/coroot/coroot-node-agent/common"
+	. "github.com/coroot/coroot-node-agent/utils/modelse"
 	"go.opentelemetry.io/otel"
 	"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
 	"io"
@@ -26,7 +26,7 @@ func (d *client) UploadApmTraces(ctx context.Context, rootData []otlptrace.RootD
 	ctx, cancel := d.contextWithStop(ctx)
 	defer cancel()
 	mapLen := len(rootData)
-	request, err := d.newApmRequest(rawRequest, mapLen, common.CodeType(codeType))
+	request, err := d.newApmRequest(rawRequest, mapLen, CodeType(codeType))
 	if err != nil {
 		return err
 	}
@@ -91,7 +91,7 @@ type RespDataT struct {
 	Msg  string `json:"message"`
 }
 
-func (d *client) newApmRequest(body []byte, mapLen int, codeType common.CodeType) (request, error) {
+func (d *client) newApmRequest(body []byte, mapLen int, codeType CodeType) (request, error) {
 	u := url.URL{Scheme: d.getScheme(), Host: d.cfg.Endpoint, Path: d.cfg.URLPath}
 	r, err := http.NewRequest(http.MethodPost, u.String(), nil)
 	if err != nil {

+ 23 - 2
pkg/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/go.mod

@@ -6,7 +6,7 @@ toolchain go1.21.3
 
 require (
 	github.com/cenkalti/backoff/v4 v4.2.1
-	github.com/coroot/coroot-node-agent v0.0.0-00010101000000-000000000000
+	github.com/coroot/coroot-node-agent v0.0.0
 	github.com/stretchr/testify v1.8.4
 	go.opentelemetry.io/otel v1.22.0
 	go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.22.0
@@ -18,20 +18,39 @@ require (
 )
 
 require (
+	github.com/agoda-com/opentelemetry-logs-go v0.4.1 // indirect
+	github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
+	github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9 // indirect
+	github.com/cilium/ebpf v0.11.0 // indirect
+	github.com/coreos/go-systemd/v22 v22.5.0 // indirect
+	github.com/coroot/logparser v1.1.2 // indirect
 	github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
 	github.com/go-logr/logr v1.4.1 // indirect
 	github.com/go-logr/stdr v1.2.2 // indirect
 	github.com/golang/protobuf v1.5.3 // indirect
 	github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
-	github.com/kr/text v0.2.0 // indirect
+	github.com/hashicorp/go-version v1.6.0 // indirect
+	github.com/natefinch/lumberjack v0.0.0 // indirect
+	github.com/pkg/errors v0.9.1 // indirect
 	github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
+	github.com/sirupsen/logrus v1.9.3 // indirect
+	github.com/vishvananda/netlink v1.2.1-beta.2.0.20220608195807-1a118fe229fc // indirect
+	github.com/vishvananda/netns v0.0.4 // indirect
+	go.mongodb.org/mongo-driver v1.13.1 // indirect
 	go.opentelemetry.io/otel/metric v1.22.0 // indirect
+	go4.org/intern v0.0.0-20211027215823-ae77deb06f29 // indirect
+	go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 // indirect
+	golang.org/x/arch v0.4.0 // indirect
+	golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect
+	golang.org/x/mod v0.16.0 // indirect
 	golang.org/x/net v0.22.0 // indirect
 	golang.org/x/sys v0.18.0 // indirect
 	golang.org/x/text v0.14.0 // indirect
 	google.golang.org/genproto/googleapis/api v0.0.0-20240116215550-a9fa1716bcac // indirect
 	google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac // indirect
+	gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect
 	gopkg.in/yaml.v3 v3.0.1 // indirect
+	inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a // indirect
 )
 
 replace go.opentelemetry.io/otel/exporters/otlp/otlptrace => ../
@@ -45,3 +64,5 @@ replace go.opentelemetry.io/otel/trace => ../../../../trace
 replace go.opentelemetry.io/otel/metric => ../../../../metric
 
 replace github.com/coroot/coroot-node-agent => ../../../../../../../
+
+replace github.com/natefinch/lumberjack => ../../../../../../lumberjack

+ 141 - 23
pkg/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/go.sum

@@ -1,60 +1,178 @@
+github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
+github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
+github.com/agoda-com/opentelemetry-logs-go v0.4.1 h1:PWGqIxkEEg4HIjnHsHmNa+yGu0lhxHz4XPGKeT4o6T0=
+github.com/agoda-com/opentelemetry-logs-go v0.4.1/go.mod h1:CeDuVaK9yCWN+8UjOW8AciYJE0rl7K/mw4ejBntGYkc=
+github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=
+github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
+github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9 h1:ez/4by2iGztzR4L0zgAOR8lTQK9VlyBVVd7G4omaOQs=
+github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE=
 github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM=
 github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
-github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
-github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/cilium/ebpf v0.11.0 h1:V8gS/bTCCjX9uUnkUFUpPsksM8n1lXBAvHcpiFk1X2Y=
+github.com/cilium/ebpf v0.11.0/go.mod h1:WE7CZAnqOL2RouJ4f1uyNhqr2P4CCvXFIqdRDUgWsVs=
+github.com/containerd/cgroups v1.0.4 h1:jN/mbWBEaz+T1pi5OFtnkQ+8qnmEbAr1Oo1FRm5B0dA=
+github.com/containerd/cgroups v1.0.4/go.mod h1:nLNQtsF7Sl2HxNebu77i1R0oDlhiTG+kO4JTrUzo6IA=
+github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
+github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
+github.com/coroot/logparser v1.1.2 h1:9aH4zIBle14xMHq07YHqVFE2t68k3LE10X2yKHXtJG8=
+github.com/coroot/logparser v1.1.2/go.mod h1:YfYxn9FYBm5GYHHUB4zI22irFAWVDe2bcbOWDHKSmEo=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
+github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
+github.com/dvyukov/go-fuzz v0.0.0-20210103155950-6a8e9d1f2415/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw=
+github.com/frankban/quicktest v1.14.5 h1:dfYrrRyLtiqT9GyKXgdh+k4inNeTvmGbuSgZ3lx3GhA=
+github.com/frankban/quicktest v1.14.5/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
 github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
-github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
-github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
+github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
 github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
 github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
 github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
-github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE=
+github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
+github.com/godbus/dbus/v5 v5.0.6 h1:mkgN1ofwASrYnJ5W6U/BxG15eXXXjirgZc7CLqkcaro=
+github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
+github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
+github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
+github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo=
+github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ=
 github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
 github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
 github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
+github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
+github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
+github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
+github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
 github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms=
 github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg=
+github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
+github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
+github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
 github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
+github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
 github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
 github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
-github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
+github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 h1:3snG66yBm59tKhhSPQrQ/0bCrv1LQbKt40LnUPiUxdc=
+github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
+github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
+github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
 github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
+github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
+github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
+github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
+github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
 github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
+github.com/vishvananda/netlink v1.2.1-beta.2.0.20220608195807-1a118fe229fc h1:2wzJ1cBcM23GetRJs2y6ETXrFMvp6HefTbFWtqviHZQ=
+github.com/vishvananda/netlink v1.2.1-beta.2.0.20220608195807-1a118fe229fc/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho=
+github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
+github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8=
+github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
+github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
+github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
+github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
+github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
+github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
+go.mongodb.org/mongo-driver v1.13.1 h1:YIc7HTYsKndGK4RFzJ3covLz1byri52x0IoMB0Pt/vk=
+go.mongodb.org/mongo-driver v1.13.1/go.mod h1:wcDf1JBCXy2mOW0bWHwO/IOYqdca1MPCwDtFu/Z9+eo=
 go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I=
 go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM=
-golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
-golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
+go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
+go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
+go4.org/intern v0.0.0-20211027215823-ae77deb06f29 h1:UXLjNohABv4S58tHmeuIZDO6e3mHpW2Dx33gaNt03LE=
+go4.org/intern v0.0.0-20211027215823-ae77deb06f29/go.mod h1:cS2ma+47FKrLPdXFpr7CuxiTW3eyJbWew4qx0qtQWDA=
+go4.org/unsafe/assume-no-moving-gc v0.0.0-20211027215541-db492cf91b37/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E=
+go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 h1:WJhcL4p+YeDxmZWg141nRm7XC8IDmhz7lk5GpadO1Sg=
+go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E=
+golang.org/x/arch v0.4.0 h1:A8WCeEWhLwPBKNbFi5Wv5UTCBx5zzubnXDlMOFAzFMc=
+golang.org/x/arch v0.4.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
+golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
+golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA=
+golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
+golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
+golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic=
+golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
+golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
+golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
+golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
 golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
-golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
-golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
 golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
-golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
+golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
+golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
+golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
 golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
+golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 h1:Z0hjGZePRE0ZBWotvtrwxFNrNE9CUAGtplaDK5NNI/g=
-google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 h1:FmF5cCW94Ij59cfpoLiwTgodWmm60eEV0CjlsVg2fuw=
-google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917 h1:nz5NESFLZbJGPFxDT/HCn+V1mZ8JGNoY4nUpmW/Y2eg=
+google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917/go.mod h1:pZqR+glSb11aJ+JQcczCvgf47+duRuzNSKqE8YAQnV0=
+google.golang.org/genproto/googleapis/api v0.0.0-20240116215550-a9fa1716bcac h1:OZkkudMUu9LVQMCoRUbI/1p5VCo9BOrlvkqMvWtqa6s=
 google.golang.org/genproto/googleapis/api v0.0.0-20240116215550-a9fa1716bcac/go.mod h1:B5xPO//w8qmBDjGReYLpR6UJPnkldGkCSMoH/2vxJeg=
-google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U=
-google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM=
+google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac h1:nUQEQmH/csSvFECKYRv6HWEyypysidKl2I6Qpsglq/0=
 google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac/go.mod h1:daQN87bsDqDoe316QbbvX60nMoJQa4r6Ds0ZuoAe5yA=
-google.golang.org/grpc v1.58.2 h1:SXUpjxeVF3FKrTYQI4f4KvbGD5u2xccdYdurwowix5I=
-google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
+google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0=
 google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs=
 google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
-google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
-google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
+google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
 google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
+gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
+gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
+gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
+gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
+gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
 gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a h1:1XCVEdxrvL6c0TGOhecLuB7U9zYNdxZEjvOqJreKZiM=
+inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a/go.mod h1:e83i32mAQOW1LAqEIweALsuK2Uw4mhQadA5r7b0Wobo=

+ 1 - 3
pkg/lumberjack/go.mod

@@ -3,7 +3,5 @@ module github.com/natefinch/lumberjack
 go 1.12
 
 require (
-	github.com/BurntSushi/toml v1.4.0
-	gopkg.in/natefinch/lumberjack.v2 v2.2.1
-	gopkg.in/yaml.v2 v2.4.0
+
 )

+ 5 - 5
tracing/apm_tracing.go

@@ -3,16 +3,16 @@ package tracing
 import (
 	"context"
 	"fmt"
-	"github.com/coroot/coroot-node-agent/common"
 	"github.com/coroot/coroot-node-agent/ebpftracer"
 	"github.com/coroot/coroot-node-agent/ebpftracer/l7"
 	"github.com/coroot/coroot-node-agent/utils"
+	. "github.com/coroot/coroot-node-agent/utils/modelse"
+	klog "github.com/sirupsen/logrus"
 	"go.opentelemetry.io/otel/attribute"
 	"go.opentelemetry.io/otel/codes"
 	semconv "go.opentelemetry.io/otel/semconv/v1.18.0"
 	"go.opentelemetry.io/otel/trace"
 	"inet.af/netaddr"
-	"k8s.io/klog/v2"
 	"strconv"
 	"sync/atomic"
 	"time"
@@ -125,7 +125,7 @@ func (t *Trace) AllEventReady(traceID uint64) bool {
 	return t.startEventReady && t.endEventReady && *t.currenEventCount >= t.needEventCount
 }
 
-func (t *Trace) TraceStartEvent(method, path string, status l7.Status, addr netaddr.IPPort, pid uint32, appInfo common.AppInfo) {
+func (t *Trace) TraceStartEvent(method, path string, status l7.Status, addr netaddr.IPPort, pid uint32, appInfo AppInfo) {
 	t.span.SetAttributes(semconv.HTTPURL(fmt.Sprintf("http://%s%s", addr.String(), path)),
 		semconv.HTTPMethod(method),
 		attribute.String("http.uri", path))
@@ -140,9 +140,9 @@ func (t *Trace) TraceStartEvent(method, path string, status l7.Status, addr neta
 		attribute.Int("server.code_type", appInfo.CodeType.Int()),
 		attribute.String("server.app_name", appInfo.AppName),
 		attribute.String("server.service_name", appInfo.ServiceName),
-		attribute.Int64("server.app_id", appInfo.AppId),
+		attribute.Int64("server.app_id", appInfo.AppIdHash.IntVal),
 		attribute.Int64("server.agent_id", appInfo.AgentId),
-		attribute.Int64("server.instance_id", appInfo.InstanceId),
+		attribute.Int64("server.instance_id", appInfo.InstanceIdHash.IntVal),
 	}
 	t.span.SetAttributes(t.commonAttrs...)
 	t.startReady()

+ 1 - 0
utils/enums/enums.go

@@ -10,6 +10,7 @@ const (
 	DaemonServiceFile = "omniagent"
 	CpuLimit          = "omniagent-cpulimit"
 
+	TestApp = "eBPF-APP"
 	// windows
 	DaemonCtlProcEXE   = "omniagent-ctl.exe"
 	ServerAgentProcEXE = "omniagent-os.exe"

+ 21 - 189
utils/id.go

@@ -3,6 +3,7 @@ package utils
 import (
 	"crypto/md5"
 	"fmt"
+	. "github.com/coroot/coroot-node-agent/utils/modelse"
 	"math"
 	"os"
 	"path"
@@ -10,58 +11,6 @@ import (
 	"strings"
 )
 
-const (
-	HASH_SIZE_8  = 8
-	HASH_SIZE_16 = 16
-)
-
-// apm_span_context
-type ApmSpanContextT struct {
-	type_from      [1]byte
-	sample         [1]byte
-	host_id        [8]byte
-	app_id         [8]byte
-	instance_id    [8]byte
-	trace_id       [16]byte
-	assumed_app_id [8]byte
-	span_id        [8]byte
-}
-
-type HashByte [HASH_SIZE_8]byte
-
-type HashByte16 [HASH_SIZE_16]byte
-
-type Id_T struct {
-	AppID      ID
-	HostID     ID
-	InstanceID ID
-}
-
-type ID struct {
-	IntVal   int64
-	HashtVal HashByte
-}
-
-type ID_STRING string
-
-func (id ID_STRING) ToString() string {
-	return string(id)
-}
-
-func (id ID_STRING) ToInt64() (int64, error) {
-	intID, err := strconv.ParseInt(id.ToString(), 10, 64)
-	if err != nil {
-		return 0, err
-	}
-	return intID, nil
-}
-
-func (id ID_STRING) ToHashByte() HashByte {
-	var charArray HashByte
-	hexStringToBPFBytes(id.ToString(), &charArray)
-	return charArray
-}
-
 func init() {
 
 }
@@ -69,6 +18,7 @@ func init() {
 var (
 	APP_ID_INT64      int64
 	HOST_ID_INT64     int64
+	ACCOUNT_ID_INT    int
 	INSTANCE_ID_INT64 int64
 
 	APP_ID_BYTE      HashByte
@@ -82,40 +32,35 @@ func BuildInt64ID(str string) ID_STRING {
 
 	id_string := md5ToDec(code)
 	return ID_STRING(id_string)
-	//
-	//id, err := strconv.ParseInt(id_string, 10, 64)
-	//if err != nil {
-	//	return 0, HashByte{}, ""
-	//}
-	////INSTANCE_ID_INT64 = id
-	//var charArray HashByte
-	//hexStringToBPFBytes(id_string, &charArray)
-	////INSTANCE_ID_BYTE = charArray
-	//return id, charArray, id_string
 }
 
-func BuildInt64ID2(str string) (int64, HashByte, string) {
-	srcCode := md5.Sum([]byte(str))
-	code := fmt.Sprintf("%x", srcCode)
-	id_string := md5ToDec(code)
-	fmt.Println(id_string)
-	id, err := strconv.ParseInt(id_string, 10, 64)
-	if err != nil {
-		return 0, HashByte{}, ""
+func hexStringToBPFBytes(str string, out *HashByte) {
+	for i := 0; i < len(str)/2; i++ {
+		ch0 := str[2*i]
+		ch1 := str[2*i+1]
+		nib0 := (ch0 & 0x0F) + (ch0 >> 6) | ((ch0 >> 3) & 0x08)
+		nib1 := (ch1 & 0x0F) + (ch1 >> 6) | ((ch1 >> 3) & 0x08)
+		(*out)[i] = (nib0 << 4) | nib1
 	}
-	//INSTANCE_ID_INT64 = id
-	var charArray HashByte
-	hexStringToBPFBytes(id_string, &charArray)
-	//INSTANCE_ID_BYTE = charArray
-	return id, charArray, id_string
 }
 
+// todo account id
+func GetAccountID() int {
+	if ACCOUNT_ID_INT != 0 {
+		return ACCOUNT_ID_INT
+	}
+	ACCOUNT_ID_INT = 110
+	return ACCOUNT_ID_INT
+}
+
+// todo HostId
 func GetHostID() (int64, HashByte) {
 	if HOST_ID_INT64 != 0 {
 		return HOST_ID_INT64, HOST_ID_BYTE
 	}
 	uuid := MachineID()
-	str := fmt.Sprintf("%s:%s", "110", uuid)
+	// todo AccountId
+	str := fmt.Sprintf("%d:%s", GetAccountID(), uuid)
 	srcCode := md5.Sum([]byte(str))
 	code := fmt.Sprintf("%x", srcCode)
 	host_id_string := md5ToDec(code)
@@ -136,56 +81,6 @@ func GetHostID() (int64, HashByte) {
 	return id, charArray
 }
 
-func GetAppID() (int64, HashByte) {
-	if APP_ID_INT64 != 0 {
-		return APP_ID_INT64, APP_ID_BYTE
-	}
-	//str := fmt.Sprintf("%s:%s", "110", uuid)
-	//srcCode := md5.Sum([]byte(str))
-	//code := fmt.Sprintf("%x", srcCode)
-	//id_string := md5ToDec(code)
-	// todo 应用注册逻辑 && 写入proc_conf层维护
-	var id_string string
-	fmt.Println(os.Getenv("JAVA"))
-	if os.Getenv("JAVA") == "1" {
-		id_string = "3365853273187618"
-	} else {
-		id_string = "5410049101545798"
-	}
-	id, err := strconv.ParseInt(id_string, 10, 64)
-	if err != nil {
-		return 0, HashByte{}
-	}
-	APP_ID_INT64 = id
-	var charArray HashByte
-	hexStringToBPFBytes(id_string, &charArray)
-	APP_ID_BYTE = charArray
-	return id, charArray
-}
-
-//func GetHostID2() uint64 {
-//	if HOST_ID_UINT64 != 0 {
-//		return HOST_ID_UINT64
-//	}
-//	uuid := MachineID()
-//	hash := make([]byte, HASH_SIZE)
-//	customHash(uuid, hash, HASH_SIZE)
-//
-//	fmt.Print("Hashed string: ")
-//	for i := 0; i < HASH_SIZE; i++ {
-//		fmt.Printf("%d", hash[i])
-//	}
-//	hashInt := byteArrayToInt(hash)
-//	fmt.Println("HashByte as integer:", hashInt)
-//	str := strconv.FormatInt(int64(hashInt), 10)
-//
-//	// 将 hash 转换为字符串(可以使用 Base64 或其他编码)
-//	fmt.Println("HashByte as string:", str)
-//	HOST_ID_UINT64 = hashInt
-//	os.Exit(1)
-//	return hashInt
-//}
-
 func MachineID() string {
 	for _, p := range []string{"sys/devices/virtual/dmi/id/product_uuid", "etc/machine-id", "var/lib/dbus/machine-id"} {
 		payload, err := os.ReadFile(path.Join("/proc/1/root", p))
@@ -198,30 +93,6 @@ func MachineID() string {
 	return ""
 }
 
-func customHash(str string, hash []byte, size int) {
-	var intHash uint64 = 0
-	for i := 0; i < len(str); i++ {
-		intHash = (intHash * 31) + uint64(str[i])
-	}
-
-	// Convert intHash to 16 bytes
-	for i := 0; i < size; i++ {
-		hash[i] = byte(intHash % 10)
-		intHash /= 10
-	}
-	if hash[0] == 0 {
-		hash[0] = 1
-	}
-}
-
-func byteArrayToInt(hash []byte) uint64 {
-	var result uint64
-	for _, b := range hash {
-		result = result*10 + uint64(b)
-	}
-	return result
-}
-
 func hexdec(hexStr string) int {
 	dec, _ := strconv.ParseInt(hexStr, 16, 64)
 	return int(dec)
@@ -237,42 +108,3 @@ func md5ToDec(str string) string {
 	}
 	return strCode
 }
-
-//func hexStringToBPFBytes(str string, size int) []byte {
-//	out := make([]byte, size/2)
-//	for i := 0; i < size/2; i++ {
-//		ch0 := str[2*i]
-//		ch1 := str[2*i+1]
-//		nib0 := (ch0 & 0x0F) + (ch0 >> 6) | ((ch0 >> 3) & 0x08)
-//		nib1 := (ch1 & 0x0F) + (ch1 >> 6) | ((ch1 >> 3) & 0x08)
-//		out[i] = (nib0 << 4) | nib1
-//	}
-//	return out
-//}
-
-func hexStringToBPFBytes(str string, out *HashByte) {
-	for i := 0; i < len(str)/2; i++ {
-		ch0 := str[2*i]
-		ch1 := str[2*i+1]
-		nib0 := (ch0 & 0x0F) + (ch0 >> 6) | ((ch0 >> 3) & 0x08)
-		nib1 := (ch1 & 0x0F) + (ch1 >> 6) | ((ch1 >> 3) & 0x08)
-		(*out)[i] = (nib0 << 4) | nib1
-	}
-}
-
-// hex 表示十六进制字符
-var hex = []byte{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}
-
-// bytesToHexString 将字节数组转换为十六进制字符串
-func BytesToHexString(pin HashByte) string {
-	size := len(pin)
-	out := make([]byte, size*2)
-	pout := 0
-	for i := 0; i < size; i++ {
-		out[pout] = hex[(pin[i]>>4)&0xF]
-		pout++
-		out[pout] = hex[pin[i]&0xF]
-		pout++
-	}
-	return string(out)
-}

+ 22 - 0
utils/modelse/app_info.go

@@ -0,0 +1,22 @@
+package modelse
+
+const (
+	APP_NAME    = "app_name"
+	APP_ID      = "app_id"
+	AGENT_ID    = "agent_id"
+	INSTANCE_ID = "instance_id"
+)
+
+type AppInfo struct {
+	AppName        string        `json:"app_name"`
+	AppIdHash      INT_HASH_ID   `json:"app_id_hash"`
+	InstanceIdHash INT_HASH_ID   `json:"instance_id_hash"`
+	AgentId        int64         `json:"agent_id"`
+	Sn             string        `json:"sn"`
+	Sport          int           `json:"sport"`
+	ServiceName    string        `json:"service_name"`
+	CodeType       CodeType      `json:"code_type"`
+	EBPFProcInfo   *EbpfProcInfo `json:"ebpf_proc_info"`
+	RegisterAt     int64         `json:"register_at"`
+	UpdateAt       int64         `json:"update_at"`
+}

+ 9 - 10
ebpftracer/tracer/common.go → utils/modelse/bpf_struct.go

@@ -1,6 +1,4 @@
-package tracer
-
-import "github.com/coroot/coroot-node-agent/utils"
+package modelse
 
 const (
 	ETR_OK               = 0
@@ -86,11 +84,11 @@ const (
 
 var EbpfConfigProtocolFilter [PROTO_NUM]uint32
 
-type testStruct struct {
-	test_id uint32
+type TestStruct struct {
+	Test_id uint32
 }
 
-type bpfOffsetParam struct {
+type BpfOffsetParam struct {
 	Ready                          uint32 `json:"ready"`
 	TaskFilesOffset                uint32 `json:"task__files_offset"`
 	SockFlagsOffset                uint32 `json:"sock__flags_offset"`
@@ -132,7 +130,7 @@ const (
 	OFFSET_IDX_MAX
 )
 
-type traceConf struct {
+type EbpfTraceConf struct {
 	SocketID               uint64 // 会话标识
 	CoroutineTraceID       uint64 // 同一协程的数据转发关联
 	ThreadTraceID          uint64 // 同一进程/线程的数据转发关联,用于多事务流转场景
@@ -141,8 +139,8 @@ type traceConf struct {
 	IOEventCollectMode     uint64
 	IOEventMinimalDuartion uint64
 	TotalCpus              uint64
-	HostID                 utils.HashByte
-	APPID                  utils.HashByte
+	HostID                 HashByte
+	APPID                  HashByte
 }
 
 /*
@@ -181,7 +179,8 @@ type EbpfProcInfo struct {
 	CredentialsSyscallConnItab uint64 // gRPC
 	StartAddr                  uint64
 	EndAddr                    uint64
-	InstanceId                 utils.HashByte
+	InstanceId                 HashByte
+	AppId                      HashByte
 	CodeType                   uint16
 	// go http
 	MethodPtrPos   uint64

+ 1 - 1
common/code_type.go → utils/modelse/code_type.go

@@ -1,4 +1,4 @@
-package common
+package modelse
 
 type CodeType int16
 

+ 59 - 0
utils/modelse/id.go

@@ -0,0 +1,59 @@
+package modelse
+
+import "strconv"
+
+const (
+	HASH_SIZE_8  = 8
+	HASH_SIZE_16 = 16
+)
+
+// apm_span_context
+type ApmSpanContextT struct {
+	type_from      [1]byte
+	sample         [1]byte
+	host_id        [8]byte
+	app_id         [8]byte
+	instance_id    [8]byte
+	trace_id       [16]byte
+	assumed_app_id [8]byte
+	span_id        [8]byte
+}
+
+type HashByte [HASH_SIZE_8]byte
+
+type HashByte16 [HASH_SIZE_16]byte
+
+type INT_HASH_ID struct {
+	IntVal   int64
+	HashtVal HashByte
+}
+
+type ID_STRING string
+
+func (id ID_STRING) ToString() string {
+	return string(id)
+}
+
+func (id ID_STRING) ToInt64() (int64, error) {
+	intID, err := strconv.ParseInt(id.ToString(), 10, 64)
+	if err != nil {
+		return 0, err
+	}
+	return intID, nil
+}
+
+func (id ID_STRING) ToHashByte() HashByte {
+	var charArray HashByte
+	hexStringToBPFBytes(id.ToString(), &charArray)
+	return charArray
+}
+
+func hexStringToBPFBytes(str string, out *HashByte) {
+	for i := 0; i < len(str)/2; i++ {
+		ch0 := str[2*i]
+		ch1 := str[2*i+1]
+		nib0 := (ch0 & 0x0F) + (ch0 >> 6) | ((ch0 >> 3) & 0x08)
+		nib1 := (ch1 & 0x0F) + (ch1 >> 6) | ((ch1 >> 3) & 0x08)
+		(*out)[i] = (nib0 << 4) | nib1
+	}
+}

+ 15 - 0
utils/modelse/status.go

@@ -0,0 +1,15 @@
+package modelse
+
+type AppStatusInfo struct {
+	Pid        uint32 `json:"pid"`
+	ProcName   string `json:"proc_name"`
+	AppName    string `json:"app_name"`
+	Language   string `json:"language"`
+	AppID      int64  `json:"app_id"`
+	AgentID    int64  `json:"agent_id,omitempty"`
+	InstanceID int64  `json:"instance_id,omitempty"`
+	Sn         string `json:"sn"`
+	Sport      int    `json:"sport"`
+	RegisterAt string `json:"register_at"`
+	UpdateAt   string `json:"update_at"`
+}

+ 110 - 0
utils/try/try.go

@@ -0,0 +1,110 @@
+package try
+
+import (
+	"fmt"
+	"reflect"
+	"runtime/debug"
+)
+
+type TryCatch struct {
+	TryFn       interface{}
+	TryParams   []interface{}
+	CatchFn     interface{}
+	CatchParams []interface{}
+}
+
+type TryInterface interface {
+	Run()
+	SetFn(interface{})
+	SetCatchFn(fn interface{})
+	SetTryParams(params []interface{})
+	SetCatchParams(params []interface{})
+}
+
+func (t *TryCatch) SetFn(fn interface{}) {
+	t.TryFn = fn
+}
+
+func (t *TryCatch) SetCatchFn(fn interface{}) {
+	t.CatchFn = fn
+}
+
+func (t *TryCatch) SetTryParams(params []interface{}) {
+	t.TryParams = params
+}
+
+func (t *TryCatch) SetCatchParams(params []interface{}) {
+	t.CatchParams = params
+}
+
+func catchFunc(err interface{}) {
+	fmt.Println(fmt.Sprintf("panic : %s\n", err))
+	fmt.Println(fmt.Sprint(string(debug.Stack())))
+}
+
+func (t *TryCatch) getParams(params []interface{}) []reflect.Value {
+	realParams := make([]reflect.Value, len(params))
+	for i, param := range params {
+		realParams[i] = reflect.ValueOf(param)
+	}
+	return realParams
+}
+
+func (t *TryCatch) Run() {
+	go func() {
+		defer func() {
+			if err := recover(); err != nil {
+				defer func() {
+					if err = recover(); err != nil {
+						catchFunc(err)
+					}
+				}()
+				if t.CatchFn != nil {
+					realCatchFunc := reflect.ValueOf(t.CatchFn)
+					errParams := []reflect.Value{}
+					errParams = append(errParams, reflect.ValueOf(err))
+					for _, param := range t.CatchParams {
+						errParams = append(errParams, reflect.ValueOf(param))
+					}
+					realCatchFunc.Call(errParams)
+				} else {
+					catchFunc(err)
+				}
+			}
+		}()
+		realFunc := reflect.ValueOf(t.TryFn)
+		realFunc.Call(t.getParams(t.TryParams))
+	}()
+}
+
+func Go(tryFunc func(), catchFunc func(interface{})) {
+	go func(tryFunc func(), catchFunc func(interface{})) {
+		defer func() {
+			if err := recover(); err != nil {
+				catchFunc(err)
+			}
+		}()
+		tryFunc()
+	}(tryFunc, catchFunc)
+}
+
+/**
+ * tryFunc go func
+ * catchFunc catch func
+ * tryFunc params
+ */
+func GoParams(tryFunc interface{}, catchFunc func(interface{}), fnParams ...interface{}) {
+	realFunc := reflect.ValueOf(tryFunc)
+	realParams := make([]reflect.Value, len(fnParams))
+	for i, param := range fnParams {
+		realParams[i] = reflect.ValueOf(param)
+	}
+	go func(realFunc reflect.Value, catchFunc func(interface{}), realParams []reflect.Value) {
+		defer func() {
+			if err := recover(); err != nil {
+				catchFunc(err)
+			}
+		}()
+		realFunc.Call(realParams)
+	}(realFunc, catchFunc, realParams)
+}

+ 2 - 7
utils/util.go

@@ -11,7 +11,6 @@ import (
 	"encoding/json"
 	"errors"
 	"fmt"
-	"github.com/coroot/coroot-node-agent/logs"
 	"github.com/coroot/coroot-node-agent/utils/enums"
 	"io"
 	"io/ioutil"
@@ -45,10 +44,6 @@ var (
 	MetaPath         = "meta"
 )
 
-func init() {
-	logs.FormatterInit()
-}
-
 func init() {
 	// TODO: 后面校验所有的路径,都要以agentdaemon_home开头.... @jay
 	// 初始化时获取omniagent的工作目录
@@ -67,14 +62,14 @@ func init() {
 		}
 	}
 	agentdaemon_home = filepath.Dir(filepath.Dir(agentdaemon_home))
-	log.Infof("omniagent work path %s", agentdaemon_home)
+	//log.Infof("omniagent work path %s", agentdaemon_home)
 
 	_, filename := filepath.Split(agentdaemon_home)
 	if !strings.EqualFold(filename, "omniagent") && !strings.EqualFold(filename, "doccagent") && !strings.EqualFold(filename, "cloudwise") {
 		// 考虑后续支持自定义目录安装的情况 卸载逻辑在uninstall.sh中判断
 		//panic(errors.New(fmt.Sprintf("get exec path[%s] is not doccagent work path panic error", agentdaemon_home)))
 	}
-	log.Infof("omniagent exec path %s", agentdaemon_home)
+	//log.Infof("omniagent exec path %s", agentdaemon_home)
 	//initCntrPidConvert()
 }
 

+ 2 - 2
utils/worker/serverWorker.go

@@ -45,10 +45,10 @@ type ServerWorker interface {
 }
 
 func (w *ServerHTTPWorker) RegisterApp(request RegisterAppReq) error {
-	log.Infof("Register App request:%v.", request.String())
+	log.Infof("[register] Register App request:%v.", request.String())
 	_, err := w.requestServer("/v2/app/create", request)
 	if err != nil {
-		log.WithError(err).Errorf("Failed RegisterApp request:%v.", request.String())
+		log.WithError(err).Errorf("[register] Failed RegisterApp request:%v.", request.String())
 		return err
 	}
 	return nil