Skip to content

Commit

Permalink
fix: Don't remove file paths from full traces
Browse files Browse the repository at this point in the history
`Full()` was accidentally dropping the file names from the full traces.
  • Loading branch information
abhinav committed Oct 21, 2023
1 parent 06135bd commit a04e123
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 6 additions & 4 deletions internal/stack/stacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,6 @@ func (p *stackParser) parseStack(line string) (Stack, error) {
funcs := make(map[string]struct{})
for p.scan.Scan() {
line := p.scan.Text()
if len(line) == 0 {
continue
}

if strings.HasPrefix(line, "goroutine ") {
// If we see the goroutine header,
// it's the end of this stack.
Expand All @@ -152,6 +148,10 @@ func (p *stackParser) parseStack(line string) (Stack, error) {
fullStack.WriteString(line)
fullStack.WriteByte('\n') // scanner trims the newline

if len(line) == 0 {
continue
}

funcName, err := parseFuncName(line)
if err != nil {
return Stack{}, fmt.Errorf("parse function: %w", err)
Expand All @@ -170,6 +170,8 @@ func (p *stackParser) parseStack(line string) (Stack, error) {
if p.scan.Scan() {
bs := p.scan.Bytes()
if len(bs) > 0 && bs[0] == '\t' {
fullStack.Write(bs)
fullStack.WriteByte('\n')
continue
}

Expand Down
3 changes: 3 additions & 0 deletions internal/stack/stacks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ func TestCurrent(t *testing.T) {
assert.True(t, got.HasFunction("testing.(*T).Run"),
"missing in stack: %v\n%s", "testing.(*T).Run", all)

assert.Contains(t, all, "stack/stacks_test.go",
"file name missing in stack:\n%s", all)

// Ensure that we are not returning the buffer without slicing it
// from getStackBuffer.
if len(got.Full()) > 1024 {
Expand Down

0 comments on commit a04e123

Please sign in to comment.