Skip to content

Commit

Permalink
Report initialization errors to Sentry from main
Browse files Browse the repository at this point in the history
  • Loading branch information
ChimeraCoder committed Jun 29, 2017
1 parent 981cf75 commit c75fcd2
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion cmd/veneur/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package main

import (
"flag"
"os"
"time"

"github.com/Sirupsen/logrus"
"github.com/getsentry/raven-go"
"github.com/stripe/veneur"
"github.com/stripe/veneur/trace"
)
Expand All @@ -27,9 +30,34 @@ func main() {
if err != nil {
logrus.WithError(err).Fatal("Error reading config file")
}

server, err := veneur.NewFromConfig(conf)
if err != nil {
logrus.WithError(err).Fatal("Could not initialize server")
e := err

logrus.WithError(e).Error("Error initializing server")
var sentry *raven.Client
if conf.SentryDsn != "" {
sentry, err = raven.New(conf.SentryDsn)
if err != nil {
logrus.WithError(err).Error("Error initializing Sentry client")
}
}

hostname, _ := os.Hostname()

p := raven.NewPacket(e.Error())
if hostname != "" {
p.ServerName = hostname
}

_, ch := sentry.Capture(p, nil)
select {
case <-ch:
case <-time.After(10 * time.Second):
}

logrus.WithError(e).Fatal("Could not initialize server")
}
defer func() {
veneur.ConsumePanic(server.Sentry, server.Statsd, server.Hostname, recover())
Expand Down

0 comments on commit c75fcd2

Please sign in to comment.