From ec3e9b0a35e0fe99006d5b91ef77f234b521670a Mon Sep 17 00:00:00 2001 From: Sydonian <794346190@qq.com> Date: Mon, 25 Mar 2024 11:31:03 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99scanner=E7=9A=84=E9=83=A8=E5=88=86even?= =?UTF-8?q?t=E5=A2=9E=E5=8A=A0=E6=89=A7=E8=A1=8C=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scanner/internal/event/agent_cache_gc.go | 5 ++++- scanner/internal/event/agent_check_cache.go | 6 ++++-- scanner/internal/event/agent_storage_gc.go | 5 ++++- scanner/internal/event/check_package_redundancy.go | 5 ++++- scanner/internal/event/clean_pinned.go | 6 +++++- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/scanner/internal/event/agent_cache_gc.go b/scanner/internal/event/agent_cache_gc.go index 22e5521..f37bff8 100644 --- a/scanner/internal/event/agent_cache_gc.go +++ b/scanner/internal/event/agent_cache_gc.go @@ -40,8 +40,11 @@ func (t *AgentCacheGC) TryMerge(other Event) bool { func (t *AgentCacheGC) Execute(execCtx ExecuteContext) { log := logger.WithType[AgentCacheGC]("Event") + startTime := time.Now() log.Debugf("begin with %v", logger.FormatStruct(t.AgentCacheGC)) - defer log.Debugf("end") + defer func() { + log.Debugf("end, time: %v", time.Since(startTime)) + }() // TODO unavailable的节点需不需要发送任务? diff --git a/scanner/internal/event/agent_check_cache.go b/scanner/internal/event/agent_check_cache.go index 7f4cd45..17bc18f 100644 --- a/scanner/internal/event/agent_check_cache.go +++ b/scanner/internal/event/agent_check_cache.go @@ -40,9 +40,11 @@ func (t *AgentCheckCache) TryMerge(other Event) bool { func (t *AgentCheckCache) Execute(execCtx ExecuteContext) { log := logger.WithType[AgentCheckCache]("Event") + startTime := time.Now() log.Debugf("begin with %v", logger.FormatStruct(t.AgentCheckCache)) - defer log.Debugf("end") - + defer func() { + log.Debugf("end, time: %v", time.Since(startTime)) + }() // TODO unavailable的节点需不需要发送任务? agtCli, err := stgglb.AgentMQPool.Acquire(t.NodeID) diff --git a/scanner/internal/event/agent_storage_gc.go b/scanner/internal/event/agent_storage_gc.go index c89e9b8..c3c22ad 100644 --- a/scanner/internal/event/agent_storage_gc.go +++ b/scanner/internal/event/agent_storage_gc.go @@ -37,8 +37,11 @@ func (t *AgentStorageGC) TryMerge(other Event) bool { func (t *AgentStorageGC) Execute(execCtx ExecuteContext) { log := logger.WithType[AgentStorageGC]("Event") + startTime := time.Now() log.Debugf("begin with %v", logger.FormatStruct(t.AgentStorageGC)) - defer log.Debugf("end") + defer func() { + log.Debugf("end, time: %v", time.Since(startTime)) + }() // TODO unavailable的节点需不需要发送任务? diff --git a/scanner/internal/event/check_package_redundancy.go b/scanner/internal/event/check_package_redundancy.go index 9d82041..0a6eee0 100644 --- a/scanner/internal/event/check_package_redundancy.go +++ b/scanner/internal/event/check_package_redundancy.go @@ -51,8 +51,11 @@ func (t *CheckPackageRedundancy) TryMerge(other Event) bool { func (t *CheckPackageRedundancy) Execute(execCtx ExecuteContext) { log := logger.WithType[CheckPackageRedundancy]("Event") + startTime := time.Now() log.Debugf("begin with %v", logger.FormatStruct(t.CheckPackageRedundancy)) - defer log.Debugf("end") + defer func() { + log.Debugf("end, time: %v", time.Since(startTime)) + }() coorCli, err := stgglb.CoordinatorMQPool.Acquire() if err != nil { diff --git a/scanner/internal/event/clean_pinned.go b/scanner/internal/event/clean_pinned.go index 4957770..67e4599 100644 --- a/scanner/internal/event/clean_pinned.go +++ b/scanner/internal/event/clean_pinned.go @@ -5,6 +5,7 @@ import ( "math" "math/rand" "sync" + "time" "github.com/samber/lo" "gitlink.org.cn/cloudream/common/pkgs/bitmap" @@ -44,8 +45,11 @@ func (t *CleanPinned) TryMerge(other Event) bool { func (t *CleanPinned) Execute(execCtx ExecuteContext) { log := logger.WithType[CleanPinned]("Event") + startTime := time.Now() log.Debugf("begin with %v", logger.FormatStruct(t.CleanPinned)) - defer log.Debugf("end") + defer func() { + log.Debugf("end, time: %v", time.Since(startTime)) + }() coorCli, err := stgglb.CoordinatorMQPool.Acquire() if err != nil {