[MM-54291] Add goroutines profile to support package (#24478)

Этот коммит содержится в:
Ben Schumacher
2023-09-25 20:22:25 +02:00
коммит произвёл GitHub
родитель 7cd9780399
Коммит 35c1639ee3
2 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@@ -42,6 +42,7 @@ func (a *App) GenerateSupportPacket(c *request.Context) []model.FileData {
"notification log": a.getNotificationsLog,
"cpu profile": a.createCPUProfile,
"heap profile": a.createHeapProfile,
"goroutines": a.createGoroutineProfile,
}
for name, fn := range functions {
@@ -333,3 +334,18 @@ func (a *App) createHeapProfile(*request.Context) (*model.FileData, error) {
}
return fileData, nil
}
func (a *App) createGoroutineProfile(_ *request.Context) (*model.FileData, error) {
var b bytes.Buffer
err := pprof.Lookup("goroutine").WriteTo(&b, 2)
if err != nil {
return nil, errors.Wrap(err, "failed to lookup goroutine profile")
}
fileData := &model.FileData{
Filename: "goroutines",
Body: b.Bytes(),
}
return fileData, nil
}

Просмотреть файл

@@ -110,6 +110,7 @@ func TestGenerateSupportPacket(t *testing.T) {
"notifications.log",
"cpu.prof",
"heap.prof",
"goroutines",
}
for _, fileData := range fileDatas {
require.NotNil(t, fileData)
@@ -132,6 +133,7 @@ func TestGenerateSupportPacket(t *testing.T) {
"cpu.prof",
"heap.prof",
"warning.txt",
"goroutines",
}
rFileNames = nil
for _, fileData := range fileDatas {