Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report initialization errors to Sentry from main #173

Merged
merged 1 commit into from
Aug 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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