Skip to content

Commit

Permalink
Support app.type in error events (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaschaephraim authored and kattrali committed Jul 3, 2017
1 parent 70e1420 commit 5f933ea
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions bugsnag.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func init() {
APIKey: "",
Endpoint: "https://notify.bugsnag.com/",
Hostname: "",
AppType: "",
AppVersion: "",
ReleaseStage: "",
ParamsFilters: []string{"password", "secret"},
Expand Down
2 changes: 2 additions & 0 deletions bugsnag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func TestNotify(t *testing.T) {
APIKey: testAPIKey,
Endpoint: testEndpoint,
ReleaseStage: "test",
AppType: "foo",
AppVersion: "1.2.3",
Hostname: "web1",
ProjectPackages: []string{"github.com/bugsnag/bugsnag-go"},
Expand Down Expand Up @@ -112,6 +113,7 @@ func TestNotify(t *testing.T) {
"context": "testing",
"groupingHash": "lol",
"app.releaseStage": "test",
"app.type": "foo",
"app.version": "1.2.3",
"device.hostname": "web1",
"user.id": "123",
Expand Down
6 changes: 6 additions & 0 deletions configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ type Configuration struct {
// The current release stage. This defaults to "production" and is used to
// filter errors in the Bugsnag dashboard.
ReleaseStage string
// A specialized type of the application, such as the worker queue or web
// framework used, like "rails", "mailman", or "celery"
AppType string
// The currently running version of the app. This is used to filter errors
// in the Bugsnag dasboard. If you set this then Bugsnag will only re-open
// resolved errors if they happen in different app versions.
Expand Down Expand Up @@ -76,6 +79,9 @@ func (config *Configuration) update(other *Configuration) *Configuration {
if other.Hostname != "" {
config.Hostname = other.Hostname
}
if other.AppType != "" {
config.AppType = other.AppType
}
if other.AppVersion != "" {
config.AppVersion = other.AppVersion
}
Expand Down
4 changes: 2 additions & 2 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ For detailed integration instructions see https://bugsnag.com/docs/notifiers/go.
Configuration
The only required configuration is the Bugsnag API key which can be obtained by clicking "Settings"
on the top of https://bugsnag.com/ after signing up. We also recommend you set the ReleaseStage
and AppVersion if these make sense for your deployment workflow.
on the top of https://bugsnag.com/ after signing up. We also recommend you set the ReleaseStage,
AppType, and AppVersion if these make sense for your deployment workflow.
RawData
Expand Down
3 changes: 3 additions & 0 deletions payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ func (p *payload) MarshalJSON() ([]byte, error) {
"hostname": p.Hostname,
}
}
if p.AppType != "" {
event["app"].(hash)["type"] = p.AppType
}
if p.AppVersion != "" {
event["app"].(hash)["version"] = p.AppVersion
}
Expand Down
3 changes: 2 additions & 1 deletion revel/bugsnagrevel.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var once sync.Once
// Filter should be added to the filter chain just after the PanicFilter.
// It sends errors to Bugsnag automatically. Configuration is read out of
// conf/app.conf, you should set bugsnag.apikey, and can also set
// bugsnag.endpoint, bugsnag.releasestage, bugsnag.appversion,
// bugsnag.endpoint, bugsnag.releasestage, bugsnag.apptype, bugsnag.appversion,
// bugsnag.projectroot, bugsnag.projectpackages if needed.
func Filter(c *revel.Controller, fc []revel.Filter) {
defer bugsnag.AutoNotify(c)
Expand Down Expand Up @@ -51,6 +51,7 @@ func init() {
bugsnag.Configure(bugsnag.Configuration{
APIKey: revel.Config.StringDefault("bugsnag.apikey", ""),
Endpoint: revel.Config.StringDefault("bugsnag.endpoint", ""),
AppType: revel.Config.StringDefault("bugsnag.apptype", ""),
AppVersion: revel.Config.StringDefault("bugsnag.appversion", ""),
ReleaseStage: revel.Config.StringDefault("bugsnag.releasestage", revel.RunMode),
ProjectPackages: projectPackages,
Expand Down

0 comments on commit 5f933ea

Please sign in to comment.