Skip to content

sobek profilling see #3001 #4652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
20 changes: 19 additions & 1 deletion internal/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
"fmt"
"io"
stdlog "log"
"os"
"runtime/debug"
"strconv"
"strings"
"sync"
"time"

"github.com/grafana/sobek"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
Expand Down Expand Up @@ -91,9 +93,25 @@
c.globalState.Ctx = ctx

exitCode := -1
f, err := os.CreateTemp(".", "sobek.profile")

Check failure on line 96 in internal/cmd/root.go

View workflow job for this annotation

GitHub Actions / lint

use of `os.CreateTemp` forbidden because "Using anything except Signal and SyscallError from the os package is forbidden" (forbidigo)
defer f.Close()

Check failure on line 97 in internal/cmd/root.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `f.Close` is not checked (errcheck)
if err != nil {
fmt.Println(err)
panic(err)
}
err = sobek.StartProfile(f)
if err != nil {
fmt.Println(err)
panic(err)
}
defer func() {
cancel()
sobek.StopProfile()
time.Sleep(time.Second * 5)
fmt.Println("here")
c.stopLoggers()
fmt.Println(f.Close())

c.globalState.OSExit(exitCode)
}()

Expand All @@ -108,7 +126,7 @@
}
}()

err := c.cmd.Execute()
err = c.cmd.Execute()
if err == nil {
exitCode = 0
return
Expand Down
Loading