Skip to content

Commit

Permalink
Merge pull request #103 from getAlby/task-add-sentry
Browse files Browse the repository at this point in the history
chore: add capture exceptions in sentry
  • Loading branch information
im-adithya committed Aug 1, 2024
2 parents ab7d91f + 213051c commit 2a8faae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
13 changes: 9 additions & 4 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

echologrus "github.com/davrux/echo-logrus/v4"
"github.com/getsentry/sentry-go"
sentryecho "github.com/getsentry/sentry-go/echo"
"github.com/labstack/echo/v4"
"github.com/sirupsen/logrus"
ddEcho "gopkg.in/DataDog/dd-trace-go.v1/contrib/labstack/echo.v4"
Expand All @@ -24,16 +25,21 @@ func main() {
logrus.Fatalf("Failed to initialize service: %v", err)
}

e := echo.New()
e.HideBanner = true
echologrus.Logger = svc.Logger
e.Use(echologrus.Middleware())

if svc.Cfg.SentryDSN != "" {
if err = sentry.Init(sentry.ClientOptions{
Dsn: svc.Cfg.SentryDSN,
}); err != nil {
logrus.Error(err)
svc.Logger.WithError(err).Error("Failed to init Sentry")
}
defer sentry.Flush(2 * time.Second)
e.Use(sentryecho.New(sentryecho.Options{}))
}

echologrus.Logger = svc.Logger
e := echo.New()
if svc.Cfg.DatadogAgentUrl != "" {
tracer.Start(tracer.WithService("http-nostr"))
defer tracer.Stop()
Expand All @@ -47,7 +53,6 @@ func main() {
e.POST("/publish", svc.PublishHandler)
e.POST("/subscriptions", svc.SubscriptionHandler)
e.DELETE("/subscriptions/:id", svc.StopSubscriptionHandler)
e.Use(echologrus.Middleware())

//start Echo server
go func() {
Expand Down
8 changes: 4 additions & 4 deletions internal/nostr/nostr.go
Original file line number Diff line number Diff line change
Expand Up @@ -803,10 +803,10 @@ func (svc *Service) handleResponseEvent(event *nostr.Event, subscription *Subscr
"client_pubkey": clientPubkey,
"relay_url": subscription.RelayUrl,
}).Info("Received response event")
if (subscription.RequestEvent != nil) {
subscription.RequestEvent.ResponseReceivedAt = time.Now()
svc.db.Save(&subscription.RequestEvent)
}

subscription.RequestEvent.ResponseReceivedAt = time.Now()
svc.db.Save(&subscription.RequestEvent)

responseEvent := ResponseEvent{
NostrId: event.ID,
Content: event.Content,
Expand Down

0 comments on commit 2a8faae

Please sign in to comment.