Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/core/pprof.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (c *PprofTaskCommandImpl) getWriter() (io.Writer, error) {
}

// sample data to file
pprofFileName := filepath.Join(c.taskID, ".pprof")
pprofFileName := c.taskID + ".pprof"
pprofFilePath := filepath.Join(c.pprofFilePath, pprofFileName)
if err := os.MkdirAll(filepath.Dir(pprofFilePath), os.ModePerm); err != nil {
return nil, err
Expand Down
33 changes: 31 additions & 2 deletions plugins/core/reporter/pprof_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,19 @@ func (r *PprofTaskManager) HandleCommand(rawCommand *commonv3.Command) {
// direct sampling of Heap, Allocs, Goroutine, Thread
writer, err := command.StartTask()
if err != nil {
r.logger.Errorf("start %s pprof task error %v \n", command.GetTaskID(), err)
err = fmt.Errorf("start %s pprof task error %v", command.GetTaskID(), err)
r.ReportPprofError(command.GetTaskID(), err)
r.logger.Errorf(err.Error())
return
}
command.StopTask(writer)
} else {
// The CPU, Block and Mutex sampling lasts for a duration and then stops
writer, err := command.StartTask()
if err != nil {
r.logger.Errorf("start %s pprof task error %v \n", command.GetTaskID(), err)
err = fmt.Errorf("start %s pprof task error %v", command.GetTaskID(), err)
r.ReportPprofError(command.GetTaskID(), err)
r.logger.Errorf(err.Error())
return
}
time.AfterFunc(command.GetDuration(), func() {
Expand Down Expand Up @@ -238,6 +242,29 @@ func (r *PprofTaskManager) ReportPprof(taskID string, content []byte) {
}
}

func (r *PprofTaskManager) ReportPprofError(taskID string, err error) {
metaData := &pprofv10.PprofMetaData{
Service: r.entity.ServiceName,
ServiceInstance: r.entity.ServiceInstanceName,
TaskId: taskID,
Type: pprofv10.PprofProfilingStatus_PPROF_EXECUTION_TASK_ERROR,
ContentSize: 0,
}

pprofData := &pprofv10.PprofData{
Metadata: metaData,
Result: &pprofv10.PprofData_ErrorMessage{
ErrorMessage: err.Error(),
},
}

select {
case r.pprofSendCh <- pprofData:
default:
r.logger.Errorf("reach max pprof send buffer")
}
}

func (r *PprofTaskManager) initPprofSendPipeline() {
go func() {
defer func() {
Expand Down Expand Up @@ -291,9 +318,11 @@ func (r *PprofTaskManager) uploadPprofData(pprofData *pprofv10.PprofData) {
switch resp.Status {
case pprofv10.PprofProfilingStatus_PPROF_TERMINATED_BY_OVERSIZE:
r.logger.Errorf("pprof is too large to be received by the oap server")
r.closePprofStream(stream)
return
case pprofv10.PprofProfilingStatus_PPROF_EXECUTION_TASK_ERROR:
r.logger.Errorf("server rejected pprof upload due to execution task error")
r.closePprofStream(stream)
return
}

Expand Down
Loading