func init() {
raven.SetDSN("http://6be8669224e04b92840321344621c998:[email protected]:9999/6")
}
...
raven.CaptureMessageAndWait("msg", nil)
Entering interactive mode (type "help" for commands)
(pprof) top
2155.64MB of 2155.69MB total ( 100%)
Dropped 35 nodes (cum <= 10.78MB)
flat flat% sum% cum cum%
2122.53MB 98.46% 98.46% 2122.55MB 98.46% github.com/getsentry/raven-go.NewStacktraceFrame
33.11MB 1.54% 100% 2155.66MB 100% github.com/getsentry/raven-go.NewStacktrace
0 0% 100% 2155.66MB 100% github.com/getsentry/raven-go.(*Client).CaptureErrorAndWait
0 0% 100% 2155.66MB 100% github.com/getsentry/raven-go.CaptureErrorAndWait
0 0% 100% 2155.66MB 100% main.(*Haijia).CheckAvail
0 0% 100% 2155.66MB 100% main.main
0 0% 100% 2155.66MB 100% main.main.func2
0 0% 100% 2155.66MB 100% main.notifyError
0 0% 100% 2155.69MB 100% runtime.goexit
0 0% 100% 2155.66MB 100% runtime.main
(pprof) list NewStacktraceFrame
Total: 2.11GB
ROUTINE ======================== github.com/getsentry/raven-go.NewStacktraceFrame in /Users/holys/code/src/github.com/getsentry/raven-go/stacktrace.go
2.07GB 2.07GB (flat, cum) 98.46% of Total
. . 91:// one line with no surrounding context, and 0 returns no context.
. . 92://
. . 93:// appPackagePrefixes is a list of prefixes used to check whether a package should
. . 94:// be considered "in app".
. . 95:func NewStacktraceFrame(pc uintptr, file string, line, context int, appPackagePrefixes []string) *StacktraceFrame {
641.16MB 641.16MB 96: frame := &StacktraceFrame{AbsolutePath: file, Filename: trimPath(file), Lineno: line, InApp: false}
. . 97: frame.Module, frame.Function = functionName(pc)
. . 98:
. . 99: // `runtime.goexit` is effectively a placeholder that comes from
. . 100: // runtime/asm_amd64.s and is meaningless.
. . 101: if frame.Module == "runtime" && frame.Function == "goexit" {
. . 102: return nil
. . 103: }
. . 104:
. . 105: if frame.Module == "main" {
. . 106: frame.InApp = true
. . 107: } else {
. . 108: for _, prefix := range appPackagePrefixes {
. . 109: if strings.HasPrefix(frame.Module, prefix) && !strings.Contains(frame.Module, "vendor") && !strings.Contains(frame.Module, "third_party") {
. . 110: frame.InApp = true
. . 111: }
. . 112: }
. . 113: }
. . 114:
. . 115: if context > 0 {
. 15.28kB 116: contextLines, lineIdx := fileContext(file, line, context)
. . 117: if len(contextLines) > 0 {
. . 118: for i, line := range contextLines {
. . 119: switch {
. . 120: case i < lineIdx:
901.01MB 901.01MB 121: frame.PreContext = append(frame.PreContext, string(line))
. . 122: case i == lineIdx:
192.24MB 192.24MB 123: frame.ContextLine = string(line)
. . 124: default:
388.12MB 388.12MB 125: frame.PostContext = append(frame.PostContext, string(line))
. . 126: }
. . 127: }
. . 128: }
. . 129: } else if context == -1 {
. . 130: contextLine, _ := fileContext(file, line, 0)
func NewStacktrace(skip int, context int, appPackagePrefixes []string) *Stacktrace {
var frames []*StacktraceFrame
for i := 1 + skip; ; i++ {
pc, file, line, ok := runtime.Caller(0)
if !ok {
break
}
// it never break
frame := NewStacktraceFrame(pc, file, line, context, appPackagePrefixes)
if frame != nil {
frames = append(frames, frame)
}
}