Skip to content

Commit

Permalink
capture sentry errors in scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
samgozman committed Dec 12, 2023
1 parent 31bb727 commit 51b5e1a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"github.com/getsentry/sentry-go"
"github.com/go-co-op/gocron"
. "github.com/samgozman/fin-thread/archivist"
. "github.com/samgozman/fin-thread/composer"
Expand All @@ -18,6 +19,7 @@ type App struct {
}

func (a *App) start() {
defer sentry.Flush(2 * time.Second)
// TODO: move to config, this is just a test
suspiciousKeywords := []string{
"sign up",
Expand Down Expand Up @@ -110,16 +112,34 @@ func (a *App) start() {
s := gocron.NewScheduler(time.UTC)
_, err := s.Every(60 * time.Second).Do(marketJob.Run())
if err != nil {
sentry.AddBreadcrumb(&sentry.Breadcrumb{
Category: "scheduler",
Message: "Error scheduling job for Market news",
Level: sentry.LevelError,
})
sentry.CaptureException(err)
panic(err)
}

_, err = s.Every(4 * time.Minute).Do(broadJob.Run())
if err != nil {
sentry.AddBreadcrumb(&sentry.Breadcrumb{
Category: "scheduler",
Message: "Error scheduling job for Broad news",
Level: sentry.LevelError,
})
sentry.CaptureException(err)
panic(err)
}

_, err = s.Every(5 * time.Minute).WaitForSchedule().Do(teJob.Run())
if err != nil {
sentry.AddBreadcrumb(&sentry.Breadcrumb{
Category: "scheduler",
Message: "Error scheduling job for TradingEconomics",
Level: sentry.LevelError,
})
sentry.CaptureException(err)
panic(err)
}

Expand Down

0 comments on commit 51b5e1a

Please sign in to comment.