Skip to content

Commit

Permalink
chore: report stacktrace with panics
Browse files Browse the repository at this point in the history
  • Loading branch information
vmihailenco committed May 28, 2024
1 parent 5298766 commit 91a09ce
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions uptrace/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package uptrace
import (
"context"
"fmt"
"runtime"

"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
Expand Down Expand Up @@ -101,11 +102,15 @@ func (c *client) reportPanic(ctx context.Context, val interface{}) {
defer span.End()
}

stackTrace := make([]byte, 2048)
n := runtime.Stack(stackTrace, false)

span.AddEvent(
"log",
trace.WithAttributes(
attribute.String("log.severity", "panic"),
attribute.String("log.message", fmt.Sprint(val)),
attribute.String("exception.stackstrace", string(stackTrace[:n])),
),
)
}

0 comments on commit 91a09ce

Please sign in to comment.