This is an automated email from the ASF dual-hosted git repository.
liuhan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-go.git
The following commit(s) were added to refs/heads/main by this push:
new afa75a3 fix: upload err log (#236)
afa75a3 is described below
commit afa75a3cc8c31f142102443af6164b825d63d8fc
Author: Jingyi Qu <[email protected]>
AuthorDate: Thu Oct 23 17:02:54 2025 +0800
fix: upload err log (#236)
---
plugins/core/pprof.go | 2 +-
plugins/core/reporter/pprof_manager.go | 33 +++++++++++++++++++++++++++++++--
2 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/plugins/core/pprof.go b/plugins/core/pprof.go
index 8c83689..08f7058 100644
--- a/plugins/core/pprof.go
+++ b/plugins/core/pprof.go
@@ -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
diff --git a/plugins/core/reporter/pprof_manager.go
b/plugins/core/reporter/pprof_manager.go
index e3d5d9d..34c6a9c 100644
--- a/plugins/core/reporter/pprof_manager.go
+++ b/plugins/core/reporter/pprof_manager.go
@@ -143,7 +143,9 @@ 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)
@@ -151,7 +153,9 @@ func (r *PprofTaskManager) HandleCommand(rawCommand
*commonv3.Command) {
// 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() {
@@ -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() {
@@ -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
}