Documentation ¶
Overview ¶
Package reporter is a façade for reporting duties.
Such a façade includes logging, error handling and metrics.
Index ¶
- Variables
- type Configuration
- type Healthcheck
- type Reporter
- func (r *Reporter) Config() *Configuration
- func (r *Reporter) Counter(name string) metrics.Counter
- func (r *Reporter) Debug(msg string, ctx ...interface{})
- func (r *Reporter) Error(err error, msg string, ctx ...interface{}) error
- func (r *Reporter) Gauge(name string) metrics.Gauge
- func (r *Reporter) GaugeFloat64(name string) metrics.GaugeFloat64
- func (r *Reporter) Healthcheck(name string, f func(h Healthcheck)) Healthcheck
- func (r *Reporter) Histogram(name string) metrics.Histogram
- func (r *Reporter) Info(msg string, ctx ...interface{})
- func (r *Reporter) Logger() log.Logger
- func (r *Reporter) Meter(name string) metrics.Meter
- func (r *Reporter) Push() error
- func (r *Reporter) Start() error
- func (r *Reporter) Stop() error
- func (r *Reporter) Timer(name string) metrics.Timer
- func (r *Reporter) Warn(msg string, ctx ...interface{})
- func (r *Reporter) Write(p []byte) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
var DefaultConfiguration = Configuration{ Logging: logger.DefaultConfiguration, }
DefaultConfiguration is the default reporter configuration.
Functions ¶
This section is empty.
Types ¶
type Configuration ¶
type Configuration struct { Logging logger.Configuration Sentry sentry.Configuration Metrics metrics.Configuration Prefix string }
Configuration contains the reporter configuration.
func (*Configuration) UnmarshalYAML ¶
func (configuration *Configuration) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML parses a reporter configuration from YAML.
type Healthcheck ¶
type Healthcheck struct {
metrics.Healthcheck
}
Healthcheck holds healthcheck state.
type Reporter ¶
type Reporter struct {
// contains filtered or unexported fields
}
Reporter contains the state for a reporter.
func New ¶
func New(config Configuration) (*Reporter, error)
New creates a new reporter from a configuration.
func NewMock ¶
func NewMock() *Reporter
NewMock creates a new reporter that does almost nothing. It can be used with tests. There is no need to call Close with the returned reporter.
func NewSilentMock ¶
func NewSilentMock() *Reporter
NewSilentMock creates a new reporter that does nothing.
func (*Reporter) Config ¶
func (r *Reporter) Config() *Configuration
Config returns the original configuration provided during reporter initialization.
func (*Reporter) Error ¶
Error logs an error message with additional context. It takes the error as a first argument, a descriptive message (or "") as a second. It will add "err" with the error as a context. It will return a wrapped error with the message, except if message was empty. In this case, it returns the original error.
func (*Reporter) GaugeFloat64 ¶
GaugeFloat64 returns a 64-bit float gauge with the given name.
func (*Reporter) Healthcheck ¶
func (r *Reporter) Healthcheck(name string, f func(h Healthcheck)) Healthcheck
Healthcheck returns an healthcheck with the given name.
func (*Reporter) Histogram ¶
Histogram returns an histogram with the given name. This uses an exponentially-decating sample with a forward-decaying priority reservoir. It uses fixed values for the reservoir size and alpha. Those values were scientifically obtained through random Google searches.