Documentation ¶
Overview ¶
Package deferlog implements deferpanic error logging.
Package deferstats implements deferpanic stats
Index ¶
- Variables
- func BackTrace() (body string)
- func GetSpanId(r http.ResponseWriter) int64
- func GetSpanIdString(r http.ResponseWriter) string
- func ResetHTTPStats()
- func WrapHTTPError(spanId int64, err error)
- type Client
- func (c *Client) AfterRequest(startTime time.Time, tracer *ResponseTracer, r *http.Request, ...)
- func (c *Client) BeforeRequest(w http.ResponseWriter, r *http.Request) (startTime time.Time, tracer *ResponseTracer, headers map[string]string)
- func (c *Client) CaptureStats()
- func (c *Client) ContextAfterRequest(startTime time.Time, tracer *ContextTracer, r *http.Request, ...)
- func (c *Client) ContextBeforeRequest(w http.ResponseWriter, r *http.Request) (startTime time.Time, ext *ResponseWriterExt, tracer *ContextTracer, ...)
- func (c *Client) GetStatsURL() (statsurl string)
- func (c *Client) HTTPHandler(f http.Handler) http.Handler
- func (c *Client) HTTPHandlerFunc(f http.HandlerFunc) http.HandlerFunc
- func (c *Client) Persist()
- func (c *Client) PersistRepanic()
- func (c *Client) SetHttpProxy(urlString string) error
- func (c *Client) SetStatsURL(statsurl string)
- func (c *Client) SetappGroup(appGroup string)
- func (c *Client) Setenvironment(environment string)
- func (c *Client) SetnoPost(noPost bool)
- func (c *Client) Wrap(err error)
- type ContextTracer
- type DB
- func (db *DB) Begin() (*Tx, error)
- func (db *DB) Exec(query string, args ...interface{}) (sql.Result, error)
- func (db *DB) Prepare(query string) (*Stmt, error)
- func (db *DB) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (db *DB) QueryRow(query string, args ...interface{}) *sql.Row
- type DeferDB
- type DeferHTTP
- type DeferHTTPs
- type DeferStats
- type HTTPPercentile
- type ResponseTracer
- type ResponseWriterExt
- type Rpm
- type Stmt
- type Tx
- func (tx *Tx) Commit() error
- func (tx *Tx) Exec(query string, args ...interface{}) (sql.Result, error)
- func (tx *Tx) Prepare(query string) (*Stmt, error)
- func (tx *Tx) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (tx *Tx) QueryRow(query string, args ...interface{}) *sql.Row
- func (tx *Tx) Rollback() error
Constants ¶
This section is empty.
Variables ¶
var ( // Querylist is the list of db_queries that will be sent to // deferpanic Querylist deferDBList )
FIXME
var ( // Token is your deferpanic token available in settings Token string )
being DEPRECATED please use deferstats.NewClient(token)
var WritePanicResponse = func(w http.ResponseWriter, r *http.Request, errMsg string) { w.WriteHeader(http.StatusInternalServerError) w.Write([]byte(errMsg)) }
WritePanicResponse is an overridable function that, by default, writes the contents of the panic error message with a 500 Internal Server Error.
Functions ¶
func GetSpanId ¶
func GetSpanId(r http.ResponseWriter) int64
GetSpanId returns the span id for this http request
func GetSpanIdString ¶
func GetSpanIdString(r http.ResponseWriter) string
GetSpanIdString is a convenience method to get the string equivalent of a span id
func ResetHTTPStats ¶
func ResetHTTPStats()
ResetHTTPStats clears the current list of HTTP statistics
func WrapHTTPError ¶
WrapHTTPError wraps an error that occurs w/in a http request and sends the error to deferpanic w/the spanId
Types ¶
type Client ¶
type Client struct { // GrabGC determines if we should grab gc stats GrabGC bool // GrabMem determines if we should grab mem stats GrabMem bool // GrabGR determines if we should grab go routine stats GrabGR bool // GrabCgo determines if we should grab cgo count GrabCgo bool // GrabFd determines if we should grab fd count GrabFd bool // GrabHTTP determines if we should grab http requests GrabHTTP bool // GrabExpvar determines if we should grab expvar GrabExpvar bool // LastGC keeps track of the last GC run LastGC int64 // Token is your deferpanic token available in settings Token string // Verbose logs any stats output - for testing/dev Verbose bool // GetExpvar captures expvar using Do method GetExpvar func() (string, error) // BaseClient is the base deferpanic client that all http requests use BaseClient *deferclient.DeferPanicClient // contains filtered or unexported fields }
Client is the client for making metrics requests to the defer panic api
func (*Client) AfterRequest ¶
func (c *Client) AfterRequest(startTime time.Time, tracer *ResponseTracer, r *http.Request, headers map[string]string, status_code int, isproblem bool)
AfterRequest is called after request processing in handler
func (*Client) BeforeRequest ¶
func (c *Client) BeforeRequest(w http.ResponseWriter, r *http.Request) ( startTime time.Time, tracer *ResponseTracer, headers map[string]string)
BeforeRequest is called before request processing in handler
func (*Client) CaptureStats ¶
func (c *Client) CaptureStats()
CaptureStats POSTs DeferStats every statsFrequency
func (*Client) ContextAfterRequest ¶
func (c *Client) ContextAfterRequest(startTime time.Time, tracer *ContextTracer, r *http.Request, headers map[string]string, status_code int, isproblem bool)
ContextAfterRequest is called after request processing in context handler
func (*Client) ContextBeforeRequest ¶
func (c *Client) ContextBeforeRequest(w http.ResponseWriter, r *http.Request) ( startTime time.Time, ext *ResponseWriterExt, tracer *ContextTracer, headers map[string]string)
ContextBeforeRequest is called before request processing in context handler
func (*Client) GetStatsURL ¶
GetStatsURL returns statistics submitting URL
func (*Client) HTTPHandler ¶
HTTPHandler wraps a http handler and captures the latency of each request this currently happens in a global list :( - TBFS
func (*Client) HTTPHandlerFunc ¶
func (c *Client) HTTPHandlerFunc(f http.HandlerFunc) http.HandlerFunc
HTTPHandlerFunc wraps a http handler func and captures the latency of each request this currently happens in a global list :( - TBFS
func (*Client) Persist ¶
func (c *Client) Persist()
Persists ensures any panics will post to deferpanic website for tracking typically used in non http go-routines
func (*Client) PersistRepanic ¶
func (c *Client) PersistRepanic()
PersistRepanic ensures any panics will post to deferpanic website for tracking, it also reissues the panic afterwards. typically used in non http go-routines
func (*Client) SetHttpProxy ¶
SetHttpProxy overrides the default httpclient with a proxy client with user given address
func (*Client) SetStatsURL ¶
SetStatsURL sets statistics submitting URL
func (*Client) SetappGroup ¶
SetappGroup sets the app group default is 'default'
func (*Client) Setenvironment ¶
Setenvironment sets the environment default is 'production'
type ContextTracer ¶
ContextTracer passes spanId/parentSpanId parameters using context
type DB ¶
DB wraps sql.DB to provide latency timing against various db operations
type DeferHTTP ¶
type DeferHTTP struct { Path string `json:"Path"` Method string `json:"Method"` StatusCode int `json:"StatusCode"` Time int `json:"Time"` SpanId int64 `json:"SpanId"` ParentSpanId int64 `json:"ParentSpanId"` IsProblem bool `json:"IsProblem"` Headers map[string]string `json:"Headers"` }
DeferHTTP holds a single instance of a http query
func GetHTTPStats ¶
func GetHTTPStats() (deferhttps []DeferHTTP)
GetHTTPStats returns the current list of HTTP statistics
type DeferHTTPs ¶
type DeferHTTPs []DeferHTTP
func (DeferHTTPs) Len ¶
func (slice DeferHTTPs) Len() int
func (DeferHTTPs) Less ¶
func (slice DeferHTTPs) Less(i, j int) bool
func (DeferHTTPs) Swap ¶
func (slice DeferHTTPs) Swap(i, j int)
type DeferStats ¶
type DeferStats struct { Mem string `json:"Mem"` GC string `json:"GC"` LastGC string `json:"LastGC"` LastPause string `json:"LastPause"` GoRoutines string `json:"GoRoutines"` Cgos string `json:"Cgos"` Fds string `json:"Fds"` Expvars string `json:"Expvars"` HTTPs []HTTPPercentile `json:"HTTPs,omitempty"` DBs []DeferDB `json:"DBs,omitempty"` Rpms Rpm `json:"RPMs,omitempty"` }
DeferStats captures {mem, gc, goroutines and http calls}
type HTTPPercentile ¶
type HTTPPercentile struct { Sample DeferHTTP `json:"Sample"` P50 float64 `json:"P50"` P75 float64 `json:"P75"` P90 float64 `json:"P90"` P95 float64 `json:"P95"` P99 float64 `json:"P99"` Min int64 `json:"Min"` Max int64 `json:"Max"` Mean float64 `json:"Mean"` StdDev float64 `json:"StdDev"` Count int64 `json:"Count"` }
HTTPPercentile is a single instance of the set of a http query percentiles
type ResponseTracer ¶
type ResponseTracer struct { SpanId int64 ParentSpanId int64 // contains filtered or unexported fields }
ResponseTracer implements a responsewriter with SpanId/ParentSpanId
func (*ResponseTracer) Header ¶
func (l *ResponseTracer) Header() http.Header
Header is implementaion of standard http ResponseWriter Header method
func (*ResponseTracer) Status ¶
func (l *ResponseTracer) Status() int
Status returns the HTTP status code
func (*ResponseTracer) Write ¶
func (l *ResponseTracer) Write(b []byte) (int, error)
Write is implementaion of standard http ResponseWriter Header method and setting the size and status
func (*ResponseTracer) WriteHeader ¶
func (l *ResponseTracer) WriteHeader(s int)
WriteHeader sets the header
type ResponseWriterExt ¶
type ResponseWriterExt struct {
// contains filtered or unexported fields
}
ResponseWriterExt implements http.ResponseWriter with extended methods
func (*ResponseWriterExt) Header ¶
func (e *ResponseWriterExt) Header() http.Header
Header is implementaion of standard http ResponseWriter Header method
func (*ResponseWriterExt) Status ¶
func (e *ResponseWriterExt) Status() int
Status returns the HTTP status code
func (*ResponseWriterExt) Write ¶
func (e *ResponseWriterExt) Write(b []byte) (int, error)
Write is implementaion of standard http ResponseWriter Header method and setting the size and status
func (*ResponseWriterExt) WriteHeader ¶
func (e *ResponseWriterExt) WriteHeader(s int)
WriteHeader is implementaion of standard http ResponseWriter WriteHeader method and setting the status
type Rpm ¶
type Rpm struct { StatusOk int `json:"200,omitempty"` StatusMovedPermanently int `json:"301,omitempty"` StatusFound int `json:"302,omitempty"` StatusBadRequest int `json:"400,omitempty"` StatusForbidden int `json:"403,omitempty"` StatusNotFound int `json:"404,omitempty"` StatusInternalServerError int `json:"500,omitempty"` }
HTTPRpm holds the count of each HTTP status code during a stats collection interval
type Stmt ¶
Stmt wraps sql.Stmt to provide latency timing against various db operations
type Tx ¶
Tx wraps sql.Tx to provide latency timing against various db operations