From 49529367b9efce580852294603f1f7dac28622a3 Mon Sep 17 00:00:00 2001 From: mrproliu <741550557@qq.com> Date: Wed, 1 Jun 2022 17:00:16 +0800 Subject: [PATCH] Fix profiling issue and add logs (#38) --- CHANGES.md | 2 ++ README.md | 2 ++ pkg/process/finders/kubernetes/container.go | 1 + pkg/profiling/task/manager.go | 9 ++++++++- pkg/profiling/task/oncpu/runner.go | 2 ++ 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 858b912f..f9f418b3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,8 +8,10 @@ Release Notes. * Support `OFF_CPU` Profiling. * Introduce the `BTFHub` module. * Update to using frequency mode to `ON_CPU` Profiling. +* Add logs in the profiling module logical. #### Bug Fixes +* Fix `docker` based process could not be detected. #### Issues and PR - All issues are [here](https://github.com/apache/skywalking/milestone/134?closed=1) diff --git a/README.md b/README.md index 34566577..9a15dcd2 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ Apache SkyWalking Rover # Download +Follow the [releases page](https://skywalking.apache.org/downloads/#SkyWalkingRover) or [docker image](https://hub.docker.com/r/apache/skywalking-rover) to download a release of Apache SkyWalking Rover. + # Contact Us * Mail list: **dev@skywalking.apache.org**. Mail to `dev-subscribe@skywalking.apache.org`, follow the reply to subscribe the mail list. * Join `skywalking` channel at [Apache Slack](http://s.apache.org/slack-invite). If the link is not working, find the latest one at [Apache INFRA WIKI](https://cwiki.apache.org/confluence/display/INFRA/Slack+Guest+Invites). diff --git a/pkg/process/finders/kubernetes/container.go b/pkg/process/finders/kubernetes/container.go index c2a3a626..94dabb3a 100644 --- a/pkg/process/finders/kubernetes/container.go +++ b/pkg/process/finders/kubernetes/container.go @@ -69,6 +69,7 @@ func (c *PodContainer) CGroupID() string { // delete the container runtime prefix is the cgroupid cgroupID = strings.TrimPrefix(cgroupID, "containerd://") cgroupID = strings.TrimPrefix(cgroupID, "dockerd://") + cgroupID = strings.TrimPrefix(cgroupID, "docker://") return cgroupID } diff --git a/pkg/profiling/task/manager.go b/pkg/profiling/task/manager.go index 80578709..5af4b305 100644 --- a/pkg/profiling/task/manager.go +++ b/pkg/profiling/task/manager.go @@ -98,6 +98,8 @@ func (m *Manager) StartTask(c *Context) { // shutdown task if exists taskIdentity := c.BuildTaskIdentity() if m.tasks[taskIdentity] != nil { + id := m.tasks[taskIdentity].TaskID() + log.Infof("existing profiling task: %s, so need to stop it", id) if err := m.shutdownAndRemoveTask(m.tasks[taskIdentity]); err != nil { log.Warnf("shutdown existing profiling task failure, so cannot to start new profiling task: %v. reason: %v", c.task.TaskID, err) return @@ -118,6 +120,7 @@ func (m *Manager) StartTask(c *Context) { go func() { select { case <-time.After(afterRun): + log.Infof("the profiling task need to wait %fmin to run: %s", afterRun.Minutes(), c.TaskID()) m.runTask(c) case <-c.ctx.Done(): return @@ -126,6 +129,7 @@ func (m *Manager) StartTask(c *Context) { } func (m *Manager) runTask(c *Context) { + log.Infof("ready to starting profiling task: %s", c.TaskID()) var wg sync.WaitGroup wg.Add(1) c.runningWg = &wg @@ -148,7 +152,7 @@ func (m *Manager) runTask(c *Context) { } func (m *Manager) afterProfilingStartSuccess(c *Context) { - log.Infof("starting the profiling task. taskId: %s, pid: %d", c.task.TaskID, c.process.Pid()) + log.Infof("profiling task has been started. taskId: %s, pid: %d", c.task.TaskID, c.process.Pid()) go func() { select { // shutdown task when arrived task running task @@ -223,6 +227,7 @@ func (m *Manager) flushProfilingData() error { return err } currentMilli := time.Now().UnixMilli() + totalSendCount := make(map[string]int) for _, t := range m.tasks { data, err1 := t.runner.FlushData() if err1 != nil { @@ -234,6 +239,7 @@ func (m *Manager) flushProfilingData() error { continue } + totalSendCount[t.TaskID()] += len(data) // only the first data have task metadata data[0].Task = &profiling_v3.EBPFProfilingTaskMetadata{ TaskId: t.task.TaskID, @@ -250,6 +256,7 @@ func (m *Manager) flushProfilingData() error { } } + log.Infof("send profiling data summary: %v", totalSendCount) _, err = stream.CloseAndRecv() return err } diff --git a/pkg/profiling/task/oncpu/runner.go b/pkg/profiling/task/oncpu/runner.go index 8051ce6f..4f490bcf 100644 --- a/pkg/profiling/task/oncpu/runner.go +++ b/pkg/profiling/task/oncpu/runner.go @@ -197,6 +197,8 @@ func (r *Runner) Stop() error { result = multierror.Append(result, err) } } + + close(r.stopChan) }) return result }