bugsnag-go icon indicating copy to clipboard operation
bugsnag-go copied to clipboard

Report inline functions in stack

Open dingyaguang117 opened this issue 2 years ago • 1 comments

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.

dingyaguang117 avatar Sep 01 '21 06:09 dingyaguang117

hey @dingyaguang117 - thanks for raising this. We'll look into whether this can be resolved in a future release!

luke-belton avatar Sep 03 '21 16:09 luke-belton

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.

clr182 avatar Mar 07 '24 08:03 clr182

Great Job! Thanks!

dingyaguang117 avatar Mar 07 '24 12:03 dingyaguang117