Documentation ¶
Overview ¶
errors implements an errors/crashes reporter.
Index ¶
- type Config
- type Reporter
- func (r *Reporter) LogHandler() log15.Handler
- func (r *Reporter) PanicHandler(fn func(interface{}))
- func (r *Reporter) SendError(err error, tags map[string]string)
- func (r *Reporter) SetSentryTransport(t sentry.Transport)
- func (r *Reporter) Start(_ context.Context) error
- func (r *Reporter) Stop(_ context.Context) error
- type SentryTestTransport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // DSN represents the Sentry DSN. DSN string `yaml:"dsn"` // Wait represents a flag indicating if the calls to Sentry should be done synchronously // (effectively blocking the caller). Wait bool `yaml:"wait"` // Debug represents a flags indicating whether to enable internal reporter activity logging. // This is mainly for debug purposes. Debug bool `yaml:"debug"` }
Config represents an errors reporter configuration.
type Reporter ¶
Reporter represents an errors reporter instance.
func (*Reporter) LogHandler ¶
func (r *Reporter) LogHandler() log15.Handler
LogHandler is a log15.Handler that sends an event to Sentry if an error-level record message is logged.
func (*Reporter) PanicHandler ¶
func (r *Reporter) PanicHandler(fn func(interface{}))
PanicHandler is a function that recovers from a panic and sends an event to Sentry. If a fn function is provided it will be executed with the recovered panic value as parameter before returning – typically to exit the program with a non-nil return code. This handler should be used with a defer statement at the beginning of the program to watch for.
func (*Reporter) SendError ¶
SendError sends the specified error to Sentry. If tags is not nil, they will be added to the event.
func (*Reporter) SetSentryTransport ¶
func (r *Reporter) SetSentryTransport(t sentry.Transport)
SetSentryTransport sets the errors reporter's Sentry client transport. This is mainly for testing purposes.
type SentryTestTransport ¶
type SentryTestTransport struct {
// contains filtered or unexported fields
}
SentryTestTransport is an implementation of the sentry.Transport interface for testing purposes.
func (*SentryTestTransport) Configure ¶
func (t *SentryTestTransport) Configure(_ sentry.ClientOptions)
Configure is a no-op for SentryTestTransport.
func (*SentryTestTransport) Events ¶
func (t *SentryTestTransport) Events() []*sentry.Event
Events returns a list of events received by the Transport.
func (*SentryTestTransport) Flush ¶
func (t *SentryTestTransport) Flush(_ time.Duration) bool
Flush is a no-op for SentryTestTransport. It always returns true immediately.
func (*SentryTestTransport) SendEvent ¶
func (t *SentryTestTransport) SendEvent(event *sentry.Event)
SendEvent assembles a new packet out of `Event` and sends it to remote server.