Skip to content

Commit

Permalink
add: treat faults as panic to write the trace to logs
Browse files Browse the repository at this point in the history
  • Loading branch information
CorentinB committed Aug 28, 2024
1 parent 672cd53 commit be1a5ec
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/pkg/crawl/crawl.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ type PrometheusMetrics struct {
func (c *Crawl) Start() (err error) {
defer func() {
if r := recover(); r != nil {
// Treat faults as panics
debug.SetPanicOnFault(true)

// Write the stacktrace to a file in the job's directory
stacktrace := fmt.Sprintf("%s\n%s", r, debug.Stack())
stacktracePath := path.Join(c.JobPath, "logs", fmt.Sprintf("%s.%s.log", "panic", time.Now().Format("2006.01.02T15-04")))
Expand Down

0 comments on commit be1a5ec

Please sign in to comment.