Skip to content

Commit

Permalink
Fix profiling issue and add logs (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrproliu authored Jun 1, 2022
1 parent 271e2cd commit 4952936
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: **[email protected]**. Mail to `[email protected]`, 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).
Expand Down
1 change: 1 addition & 0 deletions pkg/process/finders/kubernetes/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
9 changes: 8 additions & 1 deletion pkg/profiling/task/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
Expand All @@ -250,6 +256,7 @@ func (m *Manager) flushProfilingData() error {
}
}

log.Infof("send profiling data summary: %v", totalSendCount)
_, err = stream.CloseAndRecv()
return err
}
2 changes: 2 additions & 0 deletions pkg/profiling/task/oncpu/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ func (r *Runner) Stop() error {
result = multierror.Append(result, err)
}
}

close(r.stopChan)
})
return result
}
Expand Down

0 comments on commit 4952936

Please sign in to comment.