Documentation
¶
Overview ¶
package hb is a Go package from sending errors to Honeybadger.
Example ¶
package main import ( "errors" "net/http" "github.com/remind101/pkg/reporter" "github.com/remind101/pkg/reporter/hb" "golang.org/x/net/context" ) var errBoom = errors.New("boom") func main() { ctx := reporter.WithReporter(context.Background(), hb.NewReporter("dcb8affa")) req, _ := http.NewRequest("GET", "/api/foo", nil) req.Header.Set("Content-Type", "application/json") reporter.AddContext(ctx, "request_id", "1234") reporter.AddRequest(ctx, req) reporter.Report(ctx, errBoom) }
Output:
Index ¶
Examples ¶
Constants ¶
View Source
const ( DefaultURL = "https://api.honeybadger.io" DefaultVersion = "v1" )
Variables ¶
View Source
var IgnoredHeaders = map[string]struct{}{
"Authorization": struct{}{},
}
Headers that won't be sent to honeybadger.
Functions ¶
This section is empty.
Types ¶
type BacktraceLine ¶
type Client ¶
type Client struct { // URL is the location for the honeybadger api. The zero value is DefaultURL. URL string // Version is the API version to use. The zero value is DefaultVersion. Version string // contains filtered or unexported fields }
func NewClientFromKey ¶
NewClientFromKey returns a new Client with an http.Client configured to add the key as the api token.
func (*Client) NewRequest ¶
type Error ¶
type Error struct { Class string `json:"class"` Message string `json:"message"` Backtrace []*BacktraceLine `json:"backtrace"` Source map[string]interface{} `json:"source"` Tags []string `json:"tags"` }
type Report ¶
type Reporter ¶
type Reporter struct { Environment string // contains filtered or unexported fields }
Reporter is used to report errors to honeybadger.
func NewReporter ¶
NewReporter returns a new Reporter instance.
type Request ¶
type Request struct { Url string `json:"url"` Component string `json:"component"` Action string `json:"action"` Params map[string]interface{} `json:"params"` Session map[string]interface{} `json:"session"` CgiData map[string]interface{} `json:"cgi_data"` Context map[string]interface{} `json:"context"` }
type Transport ¶
type Transport struct { Key string Transport http.RoundTripper }
Transport is an http.RoundTripper that adds the api key to the request headers.
Click to show internal directories.
Click to hide internal directories.