Documentation
¶
Index ¶
- Constants
- func NewHandler(e ErrorExporter) http.Handler
- type ErrorCollector
- func (c *ErrorCollector) Report(report ErrorReport)
- func (c *ErrorCollector) ReportError(err error)
- func (c *ErrorCollector) ReportErrorWithContext(errWithContext ErrorWithContext, severity Severity, errKey string)
- func (c *ErrorCollector) ReportWithHTTPContext(err error, httpCtx *HTTPContext)
- func (c *ErrorCollector) ReportWithHTTPContextAndSeverity(err error, severity Severity, httpCtx *HTTPContext)
- func (c *ErrorCollector) ReportWithHTTPRequest(err error, r *http.Request)
- func (c *ErrorCollector) ReportWithHTTPRequestAndSeverity(err error, severity Severity, r *http.Request)
- func (c *ErrorCollector) ReportWithSeverity(err error, severity Severity)
- type ErrorExporter
- type ErrorInstance
- type ErrorReport
- type ErrorWithContext
- type HTTPContext
- type Severity
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func NewHandler ¶
func NewHandler(e ErrorExporter) http.Handler
NewHandler receives a Periskop Error Exporter and returns a handler with the exported errors in json format
Types ¶
type ErrorCollector ¶
type ErrorCollector struct {
// contains filtered or unexported fields
}
ErrorCollector collects all the aggregated errors
func NewErrorCollector ¶
func NewErrorCollector() ErrorCollector
NewErrorCollector creates a new ErrorCollector
func (*ErrorCollector) Report ¶
func (c *ErrorCollector) Report(report ErrorReport)
Report adds an error report to map of aggregated errors. Severity defaults to Error when missing.
func (*ErrorCollector) ReportError ¶
func (c *ErrorCollector) ReportError(err error)
ReportError adds an error with severity Error to map of aggregated errors
func (*ErrorCollector) ReportErrorWithContext ¶
func (c *ErrorCollector) ReportErrorWithContext(errWithContext ErrorWithContext, severity Severity, errKey string)
ReportErrorWithContext adds a manually generated ErrorWithContext to map of aggregated errors
func (*ErrorCollector) ReportWithHTTPContext ¶
func (c *ErrorCollector) ReportWithHTTPContext(err error, httpCtx *HTTPContext)
ReportWithHTTPContext adds an error with severity Error (with HTTPContext) to map of aggregated errors
func (*ErrorCollector) ReportWithHTTPContextAndSeverity ¶
func (c *ErrorCollector) ReportWithHTTPContextAndSeverity(err error, severity Severity, httpCtx *HTTPContext)
ReportWithHTTPContextAndSeverity adds an error with given severity (with HTTPContext) to map of aggregated errors
func (*ErrorCollector) ReportWithHTTPRequest ¶
func (c *ErrorCollector) ReportWithHTTPRequest(err error, r *http.Request)
ReportWithHTTPRequest adds and error with severity Error (with HTTPContext from http.Request) to map of aggregated errors
func (*ErrorCollector) ReportWithHTTPRequestAndSeverity ¶
func (c *ErrorCollector) ReportWithHTTPRequestAndSeverity(err error, severity Severity, r *http.Request)
ReportWithHTTPRequestAndSeverity adds and error with given severity (with HTTPContext from http.Request) to map of aggregated errors
func (*ErrorCollector) ReportWithSeverity ¶
func (c *ErrorCollector) ReportWithSeverity(err error, severity Severity)
ReportWithSeverity adds an error with given severity to map of aggregated errors
type ErrorExporter ¶
type ErrorExporter struct {
// contains filtered or unexported fields
}
ErrorExporter exposes collected errors
func NewErrorExporter ¶
func NewErrorExporter(collector *ErrorCollector) ErrorExporter
NewErrorExporter creates a new ErrorExporter
func (*ErrorExporter) Export ¶
func (e *ErrorExporter) Export() (string, error)
Export exports all collected errors in json format
func (*ErrorExporter) PushToGateway ¶
func (e *ErrorExporter) PushToGateway(addr string) error
PushToGateway pushes all collected errors to the pushgateway specified by `addr`
type ErrorInstance ¶
type ErrorInstance struct { Class string `json:"class"` Message string `json:"message"` Stacktrace []string `json:"stacktrace"` Cause *ErrorInstance `json:"cause"` }
func NewCustomErrorInstance ¶
func NewCustomErrorInstance(errMsg string, errType string, stacktrace []string) ErrorInstance
NewCustomErrorInstance allows to create a custom error instance without specifying a Go error
type ErrorReport ¶
type ErrorReport struct { Err error Severity Severity HTTPRequest *http.Request HTTPCtx *HTTPContext ErrKey string }
ErrorReport represents a report of a single error
type ErrorWithContext ¶
type ErrorWithContext struct { Error ErrorInstance `json:"error"` UUID uuid.UUID `json:"uuid"` Timestamp time.Time `json:"timestamp"` Severity Severity `json:"severity"` HTTPContext *HTTPContext `json:"http_context"` }
func NewErrorWithContext ¶
func NewErrorWithContext(errInstance ErrorInstance, severity Severity, httpCtx *HTTPContext) ErrorWithContext