bugsnag-go
bugsnag-go copied to clipboard
Report inline functions in stack
Inline functions were ignored
example:
package main
import (
"fmt"
"github.com/bugsnag/bugsnag-go/v2"
"github.com/pkg/errors"
)
func A() error {
return errors.New("Bugsnag Golang Demo")
}
func B() error {
return A()
}
func C() error {
return B()
}
func main() {
bugsnag.Configure(bugsnag.Configuration{
APIKey: "xxxxxx",
})
err := C()
fmt.Printf("%+v", err)
bugsnag.Notify(err, true)
}
What I get at bugsnag web UI:
Traceback (most recent call last):
File "runtime/proc.go", line 225, in main
File "main.go", line 20, in main
File "main.go", line 21, in main
*errors.fundamental: Bugsnag Golang Demo
The stdout is:
Bugsnag Golang Demo
main.A
/Users/ding/workspace/dam-gateway/test/main.go:10
main.B
/Users/ding/workspace/dam-gateway/test/main.go:14
main.C
/Users/ding/workspace/dam-gateway/test/main.go:18
main.main
/Users/ding/workspace/dam-gateway/test/main.go:26
runtime.main
/usr/local/Cellar/go/1.16/libexec/src/runtime/proc.go:225
runtime.goexit
/usr/local/Cellar/go/1.16/libexec/src/runtime/asm_amd64.s:13712021/09/01 14:29:08 notifying bugsnag: Bugsnag Golang Demo
I found code at github.com/bugsnag/bugsnag-go/[email protected]/errors/error.go
func (err *Error) StackFrames() []StackFrame {
if err.frames == nil {
callers := runtime.CallersFrames(err.stack)
err.frames = make([]StackFrame, 0, len(err.stack))
for frame, more := callers.Next(); more; frame, more = callers.Next() {
if frame.Func == nil {
// Ignore fully inlined functions
continue
}
pkg, name := packageAndName(frame.Func)
err.frames = append(err.frames, StackFrame{
function: frame.Func,
File: frame.File,
LineNumber: frame.Line,
Name: name,
Package: pkg,
ProgramCounter: frame.PC,
})
}
}
return err.frames
}
Maybe there is a way to solve the inline function problem just like what github.com/pkg/errors
does . Thanks very much.
hey @dingyaguang117 - thanks for raising this. We'll look into whether this can be resolved in a future release!
Hi @dingyaguang117
I'm just reaching out to let you know we have a new release(v2.3.0) of the BugSnag Go notifier that should address the issue you were having with reporting inline functions in the stack trace.
After updating, if you encounter any issues then please let us know and we can investigate further.
Great Job! Thanks!