Documentation
¶
Index ¶
- Constants
- Variables
- func Absolute(stat string, value int64) error
- func Close() error
- func CreateSocket() error
- func Decr(stat string, count int64) error
- func Duration(start int64) int64
- func FAbsolute(stat string, value float64) error
- func FGauge(stat string, value float64) error
- func FGaugeDelta(stat string, value float64) error
- func Gauge(stat string, value int64) error
- func GaugeDelta(stat string, value int64) error
- func Handler(next http.Handler, endpoint string) http.Handler
- func HandlerFunc(next http.HandlerFunc, endpoint string) http.Handler
- func HandlerFuncCtx(h func(context.Context, http.ResponseWriter, *http.Request), endpoint string) http.Handler
- func Incr(stat string, count int64) error
- func IncrPanic()
- func InstrumentRouter(r *mux.Router) error
- func MSTime() int64
- func Middleware(next http.Handler) http.Handler
- func PrecisionTiming(stat string, delta time.Duration) error
- func Range(size int64) string
- func SanitizeRoute(method, route string) string
- func Statsd(service string) statsd.Statsd
- func Timer() func() int64
- func Timing(stat string, delta int64) error
- func Total(stat string, value int64) error
- type Config
- type LoggingClient
- func (c *LoggingClient) Absolute(stat string, value int64) error
- func (c *LoggingClient) Close() error
- func (c *LoggingClient) CreateSocket() error
- func (c *LoggingClient) CreateTCPSocket() error
- func (c *LoggingClient) Decr(stat string, count int64) error
- func (c *LoggingClient) FAbsolute(stat string, value float64) error
- func (c *LoggingClient) FGauge(stat string, value float64) error
- func (c *LoggingClient) FGaugeDelta(stat string, value float64) error
- func (c *LoggingClient) Gauge(stat string, value int64) error
- func (c *LoggingClient) GaugeDelta(stat string, value int64) error
- func (c *LoggingClient) Incr(stat string, count int64) error
- func (c *LoggingClient) PrecisionTiming(stat string, delta time.Duration) error
- func (c *LoggingClient) SendEvents(events map[string]event.Event) error
- func (c *LoggingClient) Timing(stat string, delta int64) error
- func (c *LoggingClient) Total(stat string, value int64) error
- type MultiClient
- func (c *MultiClient) Absolute(stat string, value int64) error
- func (c *MultiClient) Append(client statsd.Statsd)
- func (c *MultiClient) Close() error
- func (c *MultiClient) CreateSocket() error
- func (c *MultiClient) CreateTCPSocket() error
- func (c *MultiClient) Decr(stat string, count int64) error
- func (c *MultiClient) FAbsolute(stat string, value float64) error
- func (c *MultiClient) FGauge(stat string, value float64) error
- func (c *MultiClient) FGaugeDelta(stat string, value float64) error
- func (c *MultiClient) Gauge(stat string, value int64) error
- func (c *MultiClient) GaugeDelta(stat string, value int64) error
- func (c *MultiClient) Incr(stat string, count int64) error
- func (c *MultiClient) PrecisionTiming(stat string, delta time.Duration) error
- func (c *MultiClient) SendEvents(events map[string]event.Event) error
- func (c *MultiClient) Timing(stat string, delta int64) error
- func (c *MultiClient) Total(stat string, value int64) error
- type Recorder
- type RecorderResponseWriter
- type StopFunc
Constants ¶
const ( Byte = 1 KByte = Byte * 1000 MByte = KByte * 1000 GByte = MByte * 1000 TByte = GByte * 1000 )
Constants for computing the size buckets
Variables ¶
var DefaultStatsd statsd.Statsd
DefaultStatsd is the default statsd implementation
Functions ¶
func Duration ¶
Duration provided a start time in milliseconds, returns the difference / duration between that time and the time of Duration being called as an int64. The returned calue is the duration in time in milliseconds.
func FGaugeDelta ¶
FGaugeDelta calls FGaugeDelta on DefaultStatsd
func GaugeDelta ¶
GaugeDelta calls GaugeDelta on DefaultStatsd
func Handler ¶
Handler provides a middleware that will report how much time the wrapped handler took
func HandlerFunc ¶
func HandlerFunc(next http.HandlerFunc, endpoint string) http.Handler
HandlerFunc is a convenience method to wrap http.HandlerFunc with the middleware
func HandlerFuncCtx ¶
func HandlerFuncCtx(h func(context.Context, http.ResponseWriter, *http.Request), endpoint string) http.Handler
HandlerFuncCtx is the same implementation as Handler but accepts context.Context as the first parameter
func InstrumentRouter ¶
InstrumentRouter walks all the handlers on a mux.Router and wraps each route's handler with a metrics Handler for reporting sanitized route timing metrics
func Middleware ¶
Middleware is a metrics handler middleware. If your route contains wildcards (ie `/some/route/with/{id_of_object}/foo`) you should not use this middleware as it will create individual metrics for each value of `{id_of_object}`. Instead, you want to use Handler() and send it the same route that you gave to the router, but sanitized.
func PrecisionTiming ¶
PrecisionTiming calls PrecisionTiming on DefaultStatsd
func SanitizeRoute ¶
SanitizeRoute cleans up a route for the Gorilla Mux to be used as a metric name
func Statsd ¶
Statsd returns a ready to use Statsd interface, in case of error connecting to the statsd instance returns a no operation interface, Connection with Statsd is UDP (fire and forget) is recommended to use just one instance, to send all the stats, and call Close when the service stops to
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config contains all the logic for parsing command line flags.
type LoggingClient ¶
type LoggingClient struct {
// contains filtered or unexported fields
}
LoggingClient is a client that dumps stats to a Logger
func NewLoggingClient ¶
func NewLoggingClient(l *logger.L, level string) *LoggingClient
NewLoggingClient creates a new logging client that will log to logger
func (*LoggingClient) Absolute ¶
func (c *LoggingClient) Absolute(stat string, value int64) error
Absolute logs a Absolute operation
func (*LoggingClient) CreateSocket ¶
func (c *LoggingClient) CreateSocket() error
CreateSocket is a noop
func (*LoggingClient) CreateTCPSocket ¶
func (c *LoggingClient) CreateTCPSocket() error
CreateTCPSocket is a noop
func (*LoggingClient) Decr ¶
func (c *LoggingClient) Decr(stat string, count int64) error
Decr logs a Decr operation
func (*LoggingClient) FAbsolute ¶
func (c *LoggingClient) FAbsolute(stat string, value float64) error
FAbsolute logs a FAbsolute operation
func (*LoggingClient) FGauge ¶
func (c *LoggingClient) FGauge(stat string, value float64) error
FGauge logs a FGauge operation
func (*LoggingClient) FGaugeDelta ¶
func (c *LoggingClient) FGaugeDelta(stat string, value float64) error
FGaugeDelta logs a FGaugeDelta operation
func (*LoggingClient) Gauge ¶
func (c *LoggingClient) Gauge(stat string, value int64) error
Gauge logs a Gauge operation
func (*LoggingClient) GaugeDelta ¶
func (c *LoggingClient) GaugeDelta(stat string, value int64) error
GaugeDelta logs a GaugeDelta operation
func (*LoggingClient) Incr ¶
func (c *LoggingClient) Incr(stat string, count int64) error
Incr logs an Incr operation
func (*LoggingClient) PrecisionTiming ¶
func (c *LoggingClient) PrecisionTiming(stat string, delta time.Duration) error
PrecisionTiming logs a PrecisionTiming operation
func (*LoggingClient) SendEvents ¶
func (c *LoggingClient) SendEvents(events map[string]event.Event) error
SendEvents does nothing.
type MultiClient ¶
type MultiClient struct {
// contains filtered or unexported fields
}
MultiClient passes metrics to multiple statsd backends
func (*MultiClient) Absolute ¶
func (c *MultiClient) Absolute(stat string, value int64) error
Absolute calls Absolute for each backend
func (*MultiClient) Append ¶
func (c *MultiClient) Append(client statsd.Statsd)
Append adds a new statsd client to the MultiClient
func (*MultiClient) CreateSocket ¶
func (c *MultiClient) CreateSocket() error
CreateSocket calls CreateSocket for each backend
func (*MultiClient) CreateTCPSocket ¶
func (c *MultiClient) CreateTCPSocket() error
CreateTCPSocket calls CreateTCPSocket for each backend
func (*MultiClient) Decr ¶
func (c *MultiClient) Decr(stat string, count int64) error
Decr calls Decr for each backend
func (*MultiClient) FAbsolute ¶
func (c *MultiClient) FAbsolute(stat string, value float64) error
FAbsolute calls FAbsolute for each backend
func (*MultiClient) FGauge ¶
func (c *MultiClient) FGauge(stat string, value float64) error
FGauge calls FGauge for each backend
func (*MultiClient) FGaugeDelta ¶
func (c *MultiClient) FGaugeDelta(stat string, value float64) error
FGaugeDelta calls FGaugeDelta for each backend
func (*MultiClient) Gauge ¶
func (c *MultiClient) Gauge(stat string, value int64) error
Gauge calls Gauge for each backend
func (*MultiClient) GaugeDelta ¶
func (c *MultiClient) GaugeDelta(stat string, value int64) error
GaugeDelta calls GaugeDelta for each backend
func (*MultiClient) Incr ¶
func (c *MultiClient) Incr(stat string, count int64) error
Incr calls Incr for each backend
func (*MultiClient) PrecisionTiming ¶
func (c *MultiClient) PrecisionTiming(stat string, delta time.Duration) error
PrecisionTiming calls PrecisionTiming for each backend
func (*MultiClient) SendEvents ¶
func (c *MultiClient) SendEvents(events map[string]event.Event) error
SendEvents does nothing.
type Recorder ¶
type Recorder interface {
http.ResponseWriter
Status() int
}
Recorder is a convenience interface to record the response codes
type RecorderResponseWriter ¶
type RecorderResponseWriter struct {
http.ResponseWriter
// contains filtered or unexported fields
}
RecorderResponseWriter is an http.ResponseWriter that keeps track of the http status code
func (*RecorderResponseWriter) Flush ¶
func (r *RecorderResponseWriter) Flush()
Flush flushes the writer
func (*RecorderResponseWriter) Hijack ¶
func (r *RecorderResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
Hijack fulfills the Hijacker interface and allows the handler to take over the connection
func (*RecorderResponseWriter) Status ¶
func (r *RecorderResponseWriter) Status() int
Status returns the status code
func (*RecorderResponseWriter) WriteHeader ¶
func (r *RecorderResponseWriter) WriteHeader(code int)
WriteHeader keeps track of the status code
func (*RecorderResponseWriter) Written ¶
func (r *RecorderResponseWriter) Written() bool
Written returns true if a status code has been seen
type StopFunc ¶
type StopFunc func()
StopFunc stops the timer started with NewTimer and publishes the result
func NewTimer ¶
NewTimer convenience function start and publish Timing stat, typical use is:
stop := metrics.NewTimer("my_metric")
defer stop()
func NewTimerBySize ¶
NewTimerBySize convenience function start and publish Timing stat bucketed by byte size, typical use is:
stop := metrics.NewTimerBySize("my_metric", size)
defer stop()