Просмотр исходного кода

Merge branch 'dev' of https://git.cloudwise.com/TSB/euspace into dev

Tom 1 год назад
Родитель
Сommit
e5f356cf61

+ 15 - 2
Makefile

@@ -1,3 +1,4 @@
+VERSION=0.0.1
 FILTER=
 PARAMS=
 # Set debug
@@ -23,12 +24,24 @@ ifdef kernel
 	PARAMS+= kernel=${kernel}
 endif
 
+ifdef version
+	VERSION=${version}
+endif
+
+GIT_COMMIT=$(shell git rev-parse --short HEAD)
+BUILD_DATE=$(shell date '+%Y-%m-%d-%H:%M:%S')
+
+# Set Version
 TARGET_FILE=dist/package_dir/bin/euspace
+GO_LD_FLAGS_VERSION=-X github.com/coroot/coroot-node-agent/flags.AgentVersion=${VERSION}
+GO_LD_FLAGS_GIT_COMMIT=-X github.com/coroot/coroot-node-agent/flags.GitCommit=${GIT_COMMIT}
+GO_LD_FLAGS_BUILD_DATE=-X github.com/coroot/coroot-node-agent/flags.BuildDate=${BUILD_DATE}
+GO_LD_FLAGS=-ldflags="${GO_LD_FLAGS_VERSION} ${GO_LD_FLAGS_GIT_COMMIT} ${GO_LD_FLAGS_BUILD_DATE}"
 
 all: c-build go-build
 
 build:
-	CGO_ENABLED=1 go build -gcflags="all=-N -l" -buildvcs=false -o dist/package_dir/bin/euspace
+	CGO_ENABLED=1 go build -gcflags="all=-N -l" ${GO_LD_FLAGS} -buildvcs=false -o ${TARGET_FILE}
 c:
 	docker exec -it 62d0676aa0b7 sh -c 'cd /opt/github/euspace/ebpftracer && make all ${PARAMS}'
 c-build: c
@@ -43,7 +56,7 @@ run:
 docker-build-c:
 	cd /opt/github/euspace/ebpftracer && make all ${PARAMS}
 docker-build-go:
-	source ~/.g/env; CGO_ENABLED=1 go build -a -gcflags="all=-N -l" -buildvcs=false -o ${TARGET_FILE}
+	source ~/.g/env; CGO_ENABLED=1 go build -a -gcflags="all=-N -l" ${GO_LD_FLAGS} -buildvcs=false -o ${TARGET_FILE}
 docker-build: docker-build-c docker-build-go
 	@echo Target file: ${TARGET_FILE}
 	@echo Euspaces build success!

+ 2 - 2
containers/apm_register_app.go

@@ -40,9 +40,9 @@ func (c *Container) RegisterAppInfo(r *Registry, pid uint32) error {
 		if nodeInfo == nil {
 			return fmt.Errorf("[%sregister app] Unknown node info.", cl)
 		}
-		if reRegFlag {
+		// if reRegFlag {
 			c.ReBuildIds(pid)
-		}
+		// }
 		registerAppReq := RegisterAppReq{
 			AppId:       c.AppInfo.AppIdHash.IntVal,
 			AppName:     c.WhiteSettingInfo.AppName,

+ 4 - 3
containers/container_apm.go

@@ -324,8 +324,8 @@ func (c *Container) buildIDs(pid uint32) bool {
 		strInstanceID := utils.BuildInt64ID(fmt.Sprintf("%s:%d", c.AppInfo.Sn, sport))
 		c.AppInfo.InstanceIdHash.IntVal, _ = strInstanceID.ToInt64()
 		c.AppInfo.InstanceIdHash.HashtVal = strInstanceID.ToHashByte()
-		strAgentID := utils.BuildInt64ID(fmt.Sprintf("%s:%s", utils.GetHostIP(), string(proc.GetExe(pid))))
-		c.AppInfo.AgentId, _ = strAgentID.ToInt64()
+		// strAgentID := utils.BuildInt64ID(fmt.Sprintf("%s:%s", utils.GetHostIP(), string(proc.GetExe(pid))))
+		// c.AppInfo.AgentId, _ = strAgentID.ToInt64()
 		c.AppInfo.CodeType = c.GetCodeTypeFromCache(pid)
 		return true
 	}
@@ -354,7 +354,8 @@ func (c *Container) ReBuildIds(pid uint32) {
 		strInstanceID := utils.BuildInt64ID(fmt.Sprintf("%s:%d", c.AppInfo.Sn, sport))
 		c.AppInfo.InstanceIdHash.IntVal, _ = strInstanceID.ToInt64()
 		c.AppInfo.InstanceIdHash.HashtVal = strInstanceID.ToHashByte()
-		strAgentID := utils.BuildInt64ID(fmt.Sprintf("%s:%s", utils.GetHostIP(), string(proc.GetExe(pid))))
+		// strAgentID := utils.BuildInt64ID(fmt.Sprintf("%s:%s", utils.GetHostIP(), string(proc.GetExe(pid))))
+		strAgentID := utils.BuildInt64ID(fmt.Sprintf("%s:%d", utils.GetHostIP(), c.AppInfo.AppIdHash.IntVal))
 		c.AppInfo.AgentId, _ = strAgentID.ToInt64()
 		c.AppInfo.CodeType = c.GetCodeTypeFromCache(pid)
 	}

BIN
dist/package_dir/agents/NativeAgent/lib/apmAgent.jar


BIN
dist/package_dir/agents/NativeAgent/lib/apmCore.jar


BIN
dist/package_dir/agents/NativeAgent/lib/apmSpy.jar


+ 0 - 2
flags/flags.go

@@ -11,7 +11,6 @@ import (
 	"net/url"
 	"os"
 	"path"
-	"runtime"
 	"strings"
 )
 
@@ -219,6 +218,5 @@ func ShowVersion() {
 	fmt.Printf("%-20s %-8s\n", "Version:", AgentVersion)
 	fmt.Printf("%-20s %-8s\n", "Commit:", GitCommit)
 	fmt.Printf("%-20s %-8s\n", "Date:", BuildDate)
-	fmt.Printf("%-20s %-8s\n", "go version:", runtime.Version())
 	os.Exit(0)
 }

+ 1 - 1
main.go

@@ -39,7 +39,7 @@ import (
 )
 
 var (
-	version             = "0.0.1"
+	version             = flags.AgentVersion
 	sendNetDataInterval = 1 * time.Minute
 )