Documentation ¶
Index ¶
- func GetLogger() *log.Logger
- func NewBlocklistKeysFilter(keys ...interface{}) func(*Notice) *Notice
- func SetLogger(l *log.Logger)
- type Error
- type Metric
- type Notice
- type Notifier
- func (n *Notifier) AddFilter(fn func(*Notice) *Notice)
- func (n *Notifier) Close() error
- func (n *Notifier) CloseTimeout(timeout time.Duration) error
- func (n *Notifier) Flush()
- func (n *Notifier) Notice(err interface{}, ctx *gin.Context, depth int) *Notice
- func (n *Notifier) Notify(e interface{}, ctx *gin.Context)
- func (n *Notifier) NotifyOnPanic()
- func (n *Notifier) SendNotice(notice *Notice) (string, error)
- func (n *Notifier) SendNoticeAsync(notice *Notice)
- type NotifierOptions
- type QueryInfo
- type QueueMetric
- type RemoteConfigJSON
- type RemoteSettings
- type RouteMetric
- type Span
- type StackFrame
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBlocklistKeysFilter ¶
Example ¶
package main import ( "regexp" "github.com/Tixologi-Inc/gobrake" ) func main() { notifier := gobrake.NewNotifier(1, "key") filter := gobrake.NewBlocklistKeysFilter("password", regexp.MustCompile("(?i)(user)")) notifier.AddFilter(filter) notice := &gobrake.Notice{ Params: map[string]interface{}{ "password": "slds2&LP", "User": "username", "email": "john@example.com", }, } notifier.Notify(notice, nil) }
Output:
Types ¶
type Error ¶
type Error struct { Type string `json:"type"` Message string `json:"message"` Backtrace []StackFrame `json:"backtrace"` }
type Metric ¶
func ContextMetric ¶
type Notice ¶
type Notice struct { Id string `json:"-"` // id returned by SendNotice Error error `json:"-"` // error returned by SendNotice Errors []Error `json:"errors"` Context map[string]interface{} `json:"context"` Env map[string]interface{} `json:"environment"` Session map[string]interface{} `json:"session"` Params map[string]interface{} `json:"params"` }
func (*Notice) SetRequest ¶
type Notifier ¶
type Notifier struct { Routes *routes Queries *queryStats Queues *queueStats // contains filtered or unexported fields }
func NewNotifier ¶
func NewNotifierWithOptions ¶
func NewNotifierWithOptions(opt *NotifierOptions) *Notifier
func (*Notifier) AddFilter ¶
AddFilter adds filter that can change notice or ignore it by returning nil.
func (*Notifier) CloseTimeout ¶
CloseTimeout waits for pending requests to finish with a custom input timeout and then closes the notifier.
func (*Notifier) Flush ¶
func (n *Notifier) Flush()
Flush waits for pending requests to finish. It is recommended to be used with SendNoticeAsync().
func (*Notifier) Notice ¶
Notice returns Aibrake notice created from error and request. depth determines which call frame to use when constructing backtrace.
func (*Notifier) NotifyOnPanic ¶
func (n *Notifier) NotifyOnPanic()
NotifyOnPanic notifies Airbrake about the panic and should be used with defer statement.
func (*Notifier) SendNotice ¶
SendNotice sends notice to Airbrake.
func (*Notifier) SendNoticeAsync ¶
SendNoticeAsync is like SendNotice, but sends notice asynchronously. Pending notices can be flushed with Flush().
type NotifierOptions ¶
type NotifierOptions struct { // Airbrake project id. ProjectId int64 // Airbrake project key. ProjectKey string // Airbrake host name. Default is https://api.airbrake.io. Host string // Airbrake host name for sending APM data. APMHost string // The host name where the remote config is located. RemoteConfigHost string // Controls the remote config feature. DisableRemoteConfig bool // Environment such as production or development. Environment string // Git revision. Default is SOURCE_VERSION on Heroku. Revision string // List of keys containing sensitive information that must be filtered out. // Default is password, secret. KeysBlocklist []interface{} // Disables code hunks. DisableCodeHunks bool // Controls the error reporting feature. DisableErrorNotifications bool // Controls the error reporting feature. DisableAPM bool // http.Client that is used to interact with Airbrake API. HTTPClient *http.Client // Controls the backlog reporting feature. // Default is false DisableBacklog bool }
func (*NotifierOptions) Copy ¶
func (opt *NotifierOptions) Copy() *NotifierOptions
Makes a shallow copy (without copying slices or nested structs; because we don't need it so far).
type QueueMetric ¶
func ContextQueueMetric ¶
func ContextQueueMetric(c context.Context) *QueueMetric
func NewQueueMetric ¶
type RemoteConfigJSON ¶
type RemoteConfigJSON struct { ProjectId int64 `json:"project_id"` UpdatedAt int64 `json:"updated_at"` PollSec int64 `json:"poll_sec"` ConfigRoute string `json:"config_route"` RemoteSettings []*RemoteSettings `json:"settings"` }
type RemoteSettings ¶
type RouteMetric ¶
type RouteMetric struct { Method string Route string StatusCode int ContentType string // contains filtered or unexported fields }
func ContextRouteMetric ¶
func ContextRouteMetric(c context.Context) *RouteMetric