Documentation ¶
Overview ¶
The airbrake package provides a handler which sends events to the Airbrake error reporting service.
For a stack trace to be included, sawmill needs to be configured to gather them. E.G.:
logger.SetStackMinLevel(sawmill.ErrorLevel)
The handler sends all received events to the airbrake service. Thus it should most likely be used in combination with the filter handler (http://godoc.org/github.com/phemmer/sawmill/handler/filter).
Example ¶
package main import ( "os" "strings" "github.com/phemmer/sawmill" "github.com/phemmer/sawmill/handler/airbrake" ) func main() { sawmill.SetStackMinLevel(sawmill.ErrorLevel) a := airbrake.New(12345, "0123456789abcdef0123456789abcdef", "development") a.Context.URL = "http://myproject.example.com" // Add all environment variables. for _, envVar := range os.Environ() { envKP := strings.SplitN(envVar, "=", 2) a.Env[envKP[0]] = envKP[1] } filter := sawmill.FilterHandler(a).LevelMin(sawmill.ErrorLevel) sawmill.AddHandler("airbrake", filter) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AirbrakeContext ¶
type AirbrakeContext struct { OS string `json:"os"` Language string `json:"language"` Environment string `json:"environment"` Version string `json:"version"` URL string `json:"url"` // RootDirectory should be the project directory. This is normally // automatically deteremined. // If airbrake is integrated with your version control system (github), it // will generate links for you by stripping the RootDirectory from the // backtrace path, and adding it to the VCS repo URL. RootDirectory string `json:"rootDirectory"` UserId string `json:"userId"` UserName string `json:"userName"` UserEmail string `json:"userEmail"` }
type AirbrakeHandler ¶
type AirbrakeHandler struct { sync.Mutex // AirbrakeURL is the base URL for the airbrake service // (e.g. https://airbrake.io). AirbrakeURL *url.URL // Context contains the fields which show up under the "context" section of // airbrake. // Some fields are automatically populated: // * OS - Obtained from GOOS & GOARCH. // * Language - "go" & the go compiler version. // * Environment - The 'environment' parameter passed to New(). // * RootDirectory - The VCS repo root of the caller of New(). // * Version - The tag or commit of the caller's repo (git only). Context *AirbrakeContext // Env is an arbitrary mapping of environmental variables. // For security reasons, the OS environment variables are not copied. // Instead a few common variables are provided instead. // * _ - The name of the process // * GOVERSION - The go compiler version // * GOMAXPROCS - The value of GOMAXPROCS at the time of New() // * GOROOT - The value of GOROOT // * HOSTNAME - The system's host name // Values may be added or removed. Env map[string]string // contains filtered or unexported fields }
AirbrakeHandler implements the sawmill.Handler interface.
Modifying attributes after adding to a logger should be performed only after calling AirbrakeHandler.Lock() (and Unlock() after complete). However before being added to a sawmill logger, attributes may be modified without locking.