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

This commit is contained in:
Ben Schumacher 2023-09-25 20:22:25 +02:00 committed by GitHub
parent 7cd9780399
commit 35c1639ee3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -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
}

View File

@ -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 {