Skip to content

Commit

Permalink
Merge pull request #1075 from remind101/rollbar
Browse files Browse the repository at this point in the history
add support for reporting to rollbar
  • Loading branch information
ejholmes authored Jun 7, 2017
2 parents ccce74d + cf8a7a0 commit 217559f
Show file tree
Hide file tree
Showing 113 changed files with 10,085 additions and 706 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

* Processes can now be scaled down to a negative value to prevent AWS resources from being created. [#1064](https://github.com/remind101/empire/pull/1064)
* AWS resources for scheduled processes are now always created, unless scaled down to a negative value. [#1064](https://github.com/remind101/empire/pull/1064)
* Empire now supports reporting its own errors to [Rollbar](https://rollbar.com) in addition to Honeybadger. [#1075](https://github.com/remind101/empire/pull/1075)

## 0.12.0 (2017-03-10)

Expand Down
30 changes: 4 additions & 26 deletions cmd/empire/factories.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/remind101/empire/scheduler/docker"
"github.com/remind101/empire/stats"
"github.com/remind101/pkg/reporter"
"github.com/remind101/pkg/reporter/hb"
"github.com/remind101/pkg/reporter/config"
)

// DB ===================================
Expand Down Expand Up @@ -347,33 +347,11 @@ func newLogger(c *Context) (log15.Logger, error) {
// Reporter ============================

func newReporter(c *Context) (reporter.Reporter, error) {
u := c.String(FlagReporter)
if u == "" {
return reporter.NewLogReporter(), nil
}

uri, err := url.Parse(u)
rep, err := config.NewReporterFromUrls(c.StringSlice(FlagReporter))
if err != nil {
return nil, err
}

switch uri.Scheme {
case "hb":
log.Println("Using Honeybadger to report errors")
q := uri.Query()
return newHBReporter(q.Get("key"), q.Get("environment"))
default:
panic(fmt.Errorf("unknown reporter: %s", u))
panic(fmt.Errorf("couldn't create reporter: %#v", err))
}
}

func newHBReporter(key, env string) (reporter.Reporter, error) {
r := hb.NewReporter(key)
r.Environment = env

// Append here because `go vet` will complain about unkeyed fields,
// since it thinks MultiReporter is a struct literal.
return append(reporter.MultiReporter{}, reporter.NewLogReporter(), r), nil
return rep, nil
}

// Stats =======================
Expand Down
13 changes: 9 additions & 4 deletions cmd/empire/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"os"
"path"

Expand All @@ -9,6 +10,9 @@ import (
"github.com/remind101/empire/server/github"
)

const hbExampleURL = "hb://api.honeybadger.io?key=<key>&environment=<environment>"
const rollbarExampleURL = "rollbar://api.rollbar.com?key=<key>&environment=<environment>"

const (
FlagURL = "url"
FlagPort = "port"
Expand Down Expand Up @@ -232,10 +236,11 @@ var CommonFlags = []cli.Flag{
Usage: "The stats backend to use. (e.g. statsd://localhost:8125)",
EnvVar: "EMPIRE_STATS",
},
cli.StringFlag{
Name: FlagReporter,
Value: "",
Usage: "The error reporter to use. (e.g. hb://api.honeybadger.io?key=<apikey>&environment=production)",
cli.StringSliceFlag{
Name: FlagReporter,
Value: &cli.StringSlice{},
Usage: fmt.Sprintf("The reporter to use to report errors. Available options are `%s` or `%s`",
hbExampleURL, rollbarExampleURL),
EnvVar: "EMPIRE_REPORTER",
},
}
Expand Down
16 changes: 0 additions & 16 deletions server/github/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/remind101/empire"
"github.com/remind101/empire/pkg/dockerutil"
streamhttp "github.com/remind101/empire/pkg/stream/http"
"github.com/remind101/pkg/trace"
"github.com/remind101/tugboat"
"golang.org/x/net/context"
)
Expand Down Expand Up @@ -132,18 +131,3 @@ func DeployAsync(d Deployer) Deployer {
return nil
})
}

// TraceDeploy wraps a Deployer to perform tracing with package trace.
func TraceDeploy(d Deployer) Deployer {
return DeployerFunc(func(ctx context.Context, event events.Deployment, w io.Writer) (err error) {
ctx, done := trace.Trace(ctx)
err = d.Deploy(ctx, event, w)
done(err, "Deploy",
"repository", event.Repository.FullName,
"creator", event.Deployment.Creator.Login,
"ref", event.Deployment.Ref,
"sha", event.Deployment.Sha,
)
return err
})
}
3 changes: 0 additions & 3 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@ func newDeployer(e *empire.Empire, options Options) github.Deployer {
d = github.NotifyTugboat(d, url)
}

// Add tracing information so we know about errors.
d = github.TraceDeploy(d)

// Perform the deployment within a go routine so we don't timeout
// githubs webhook requests.
d = github.DeployAsync(d)
Expand Down
10 changes: 10 additions & 0 deletions vendor/github.com/pborman/uuid/CONTRIBUTING.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/github.com/pborman/uuid/CONTRIBUTORS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions vendor/github.com/pborman/uuid/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions vendor/github.com/pborman/uuid/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 84 additions & 0 deletions vendor/github.com/pborman/uuid/dce.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions vendor/github.com/pborman/uuid/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions vendor/github.com/pborman/uuid/hash.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 217559f

Please sign in to comment.