Documentation ¶
Index ¶
- Variables
- type ConfigurationFunc
- type Logger
- type NoopClient
- func (s NoopClient) Absolute(stat string, value int64) error
- func (s NoopClient) Close() error
- func (s NoopClient) CreateSocket() error
- func (s NoopClient) CreateTCPSocket() error
- func (s NoopClient) Decr(stat string, count int64) error
- func (s NoopClient) FAbsolute(stat string, value float64) error
- func (s NoopClient) FGauge(stat string, value float64) error
- func (s NoopClient) FGaugeDelta(stat string, value float64) error
- func (s NoopClient) Gauge(stat string, value int64) error
- func (s NoopClient) GaugeDelta(stat string, value int64) error
- func (s NoopClient) Incr(stat string, count int64) error
- func (s NoopClient) PrecisionTiming(stat string, delta time.Duration) error
- func (s NoopClient) Timing(stat string, count int64) error
- func (s NoopClient) Total(stat string, value int64) error
- type Statsd
- type StatsdBuffer
- func (sb *StatsdBuffer) Absolute(stat string, value int64) error
- func (sb *StatsdBuffer) Close() (err error)
- func (sb *StatsdBuffer) CreateSocket() error
- func (sb *StatsdBuffer) CreateTCPSocket() error
- func (sb *StatsdBuffer) Decr(stat string, count int64) error
- func (sb *StatsdBuffer) FAbsolute(stat string, value float64) error
- func (sb *StatsdBuffer) FGauge(stat string, value float64) error
- func (sb *StatsdBuffer) FGaugeDelta(stat string, value float64) error
- func (sb *StatsdBuffer) Gauge(stat string, value int64) error
- func (sb *StatsdBuffer) GaugeDelta(stat string, value int64) error
- func (sb *StatsdBuffer) Incr(stat string, count int64) error
- func (sb *StatsdBuffer) PrecisionTiming(stat string, delta time.Duration) error
- func (sb *StatsdBuffer) Timing(stat string, delta int64) error
- func (sb *StatsdBuffer) Total(stat string, value int64) error
- type StatsdClient
- func (c *StatsdClient) Absolute(stat string, value int64) error
- func (c *StatsdClient) Close() error
- func (c *StatsdClient) CreateSocket() error
- func (c *StatsdClient) CreateTCPSocket() error
- func (c *StatsdClient) Decr(stat string, count int64) error
- func (c *StatsdClient) FAbsolute(stat string, value float64) error
- func (c *StatsdClient) FGauge(stat string, value float64) error
- func (c *StatsdClient) FGaugeDelta(stat string, value float64) error
- func (c *StatsdClient) Gauge(stat string, value int64) error
- func (c *StatsdClient) GaugeDelta(stat string, value int64) error
- func (c *StatsdClient) Incr(stat string, count int64) error
- func (c *StatsdClient) PrecisionTiming(stat string, delta time.Duration) error
- func (c *StatsdClient) Reconnect() error
- func (c *StatsdClient) SendEvent(e event.Event) error
- func (c *StatsdClient) SendEvents(events map[string]event.Event) error
- func (c *StatsdClient) String() string
- func (c *StatsdClient) Timing(stat string, delta int64) error
- func (c *StatsdClient) Total(stat string, value int64) error
Constants ¶
This section is empty.
Variables ¶
var Hostname string
Hostname is exported so clients can set it to something different than the default
var UDPPayloadSize = 512
UDPPayloadSize is the number of bytes to send at one go through the udp socket. SendEvents will try to pack as many events into one udp packet. Change this value as per network capabilities For example to change to 16KB
import "github.com/quipo/statsd" func init() { statsd.UDPPayloadSize = 16 * 1024 }
Functions ¶
This section is empty.
Types ¶
type ConfigurationFunc ¶
type ConfigurationFunc func(*StatsdClient)
ConfigurationFunc is a typedef for a function that configures some aspect of a StatsdClient instance
func WithLogger ¶
func WithLogger(logger Logger) ConfigurationFunc
WithLogger returns a ConfigurationFunc that makes the StatsdClient use the specified Logger implementation, rather than the default implementation.
func WithReconnectInterval ¶
func WithReconnectInterval(interval time.Duration) ConfigurationFunc
WithReconnectInterval returns a ConfigurationFunc that causes the StatsdClient to automatically recreate its underlying connection on the specified interval. If no reconnection interval is supplied via this configuration func, or the supplied interval is invalid, the default of 30 seconds will be used.
type Logger ¶
type Logger interface {
Println(v ...interface{})
}
Logger interface compatible with log.Logger
type NoopClient ¶
type NoopClient struct{}
NoopClient implements a "no-op" statsd in case there is no statsd server
func (NoopClient) Absolute ¶
func (s NoopClient) Absolute(stat string, value int64) error
Absolute does nothing
func (NoopClient) CreateTCPSocket ¶
func (s NoopClient) CreateTCPSocket() error
CreateTCPSocket does nothing
func (NoopClient) FAbsolute ¶
func (s NoopClient) FAbsolute(stat string, value float64) error
FAbsolute does nothing
func (NoopClient) FGauge ¶
func (s NoopClient) FGauge(stat string, value float64) error
FGauge does nothing
func (NoopClient) FGaugeDelta ¶
func (s NoopClient) FGaugeDelta(stat string, value float64) error
FGaugeDelta does nothing
func (NoopClient) Gauge ¶
func (s NoopClient) Gauge(stat string, value int64) error
Gauge does nothing
func (NoopClient) GaugeDelta ¶
func (s NoopClient) GaugeDelta(stat string, value int64) error
GaugeDelta does nothing
func (NoopClient) PrecisionTiming ¶
func (s NoopClient) PrecisionTiming(stat string, delta time.Duration) error
PrecisionTiming does nothing
type Statsd ¶
type Statsd interface { CreateSocket() error CreateTCPSocket() error Close() error Incr(stat string, count int64) error Decr(stat string, count int64) error Timing(stat string, delta int64) error PrecisionTiming(stat string, delta time.Duration) error Gauge(stat string, value int64) error GaugeDelta(stat string, value int64) error Absolute(stat string, value int64) error Total(stat string, value int64) error FGauge(stat string, value float64) error FGaugeDelta(stat string, value float64) error FAbsolute(stat string, value float64) error }
Statsd is an interface to a StatsD client (buffered/unbuffered)
type StatsdBuffer ¶
StatsdBuffer is a client library to aggregate events in memory before flushing aggregates to StatsD, useful if the frequency of events is extremely high and sampling is not desirable
func NewStatsdBuffer ¶
func NewStatsdBuffer(interval time.Duration, client *StatsdClient) *StatsdBuffer
NewStatsdBuffer Factory
func (*StatsdBuffer) Absolute ¶
func (sb *StatsdBuffer) Absolute(stat string, value int64) error
Absolute - Send absolute-valued metric (not averaged/aggregated)
func (*StatsdBuffer) Close ¶
func (sb *StatsdBuffer) Close() (err error)
Close sends a close event to the collector asking to stop & flush pending stats and closes the statsd client
func (*StatsdBuffer) CreateSocket ¶
func (sb *StatsdBuffer) CreateSocket() error
CreateSocket creates a UDP connection to a StatsD server
func (*StatsdBuffer) CreateTCPSocket ¶
func (sb *StatsdBuffer) CreateTCPSocket() error
CreateTCPSocket creates a TCP connection to a StatsD server
func (*StatsdBuffer) Decr ¶
func (sb *StatsdBuffer) Decr(stat string, count int64) error
Decr - Decrement a counter metric. Often used to note a particular event
func (*StatsdBuffer) FAbsolute ¶
func (sb *StatsdBuffer) FAbsolute(stat string, value float64) error
FAbsolute - Send absolute-valued metric (not averaged/aggregated)
func (*StatsdBuffer) FGauge ¶
func (sb *StatsdBuffer) FGauge(stat string, value float64) error
FGauge is a Gauge working with float64 values
func (*StatsdBuffer) FGaugeDelta ¶
func (sb *StatsdBuffer) FGaugeDelta(stat string, value float64) error
FGaugeDelta records a delta from the previous value (as float64)
func (*StatsdBuffer) Gauge ¶
func (sb *StatsdBuffer) Gauge(stat string, value int64) error
Gauge - Gauges are a constant data type. They are not subject to averaging, and they don’t change unless you change them. That is, once you set a gauge value, it will be a flat line on the graph until you change it again
func (*StatsdBuffer) GaugeDelta ¶
func (sb *StatsdBuffer) GaugeDelta(stat string, value int64) error
GaugeDelta records a delta from the previous value (as int64)
func (*StatsdBuffer) Incr ¶
func (sb *StatsdBuffer) Incr(stat string, count int64) error
Incr - Increment a counter metric. Often used to note a particular event
func (*StatsdBuffer) PrecisionTiming ¶
func (sb *StatsdBuffer) PrecisionTiming(stat string, delta time.Duration) error
PrecisionTiming - Track a duration event the time delta has to be a duration
type StatsdClient ¶
type StatsdClient struct { Logger Logger // contains filtered or unexported fields }
StatsdClient is a client library to send events to StatsD
func NewStatsdClient ¶
func NewStatsdClient(addr string, prefix string, options ...ConfigurationFunc) *StatsdClient
NewStatsdClient is a factory func that creates a StatsdClient that sends to the configured address and prefixes all stats with the given prefix name.
func (*StatsdClient) Absolute ¶
func (c *StatsdClient) Absolute(stat string, value int64) error
Absolute - Send absolute-valued metric (not averaged/aggregated)
func (*StatsdClient) CreateSocket ¶
func (c *StatsdClient) CreateSocket() error
CreateSocket creates a UDP connection to a StatsD server
func (*StatsdClient) CreateTCPSocket ¶
func (c *StatsdClient) CreateTCPSocket() error
CreateTCPSocket creates a TCP connection to a StatsD server
func (*StatsdClient) Decr ¶
func (c *StatsdClient) Decr(stat string, count int64) error
Decr - Decrement a counter metric. Often used to note a particular event
func (*StatsdClient) FAbsolute ¶
func (c *StatsdClient) FAbsolute(stat string, value float64) error
FAbsolute - Send absolute-valued floating point metric (not averaged/aggregated)
func (*StatsdClient) FGauge ¶
func (c *StatsdClient) FGauge(stat string, value float64) error
FGauge -- Send a floating point value for a gauge
func (*StatsdClient) FGaugeDelta ¶
func (c *StatsdClient) FGaugeDelta(stat string, value float64) error
FGaugeDelta -- Send a floating point change for a gauge
func (*StatsdClient) Gauge ¶
func (c *StatsdClient) Gauge(stat string, value int64) error
Gauge - Gauges are a constant data type. They are not subject to averaging, and they don’t change unless you change them. That is, once you set a gauge value, it will be a flat line on the graph until you change it again. If you specify delta to be true, that specifies that the gauge should be updated, not set. Due to the underlying protocol, you can't explicitly set a gauge to a negative number without first setting it to zero.
func (*StatsdClient) GaugeDelta ¶
func (c *StatsdClient) GaugeDelta(stat string, value int64) error
GaugeDelta -- Send a change for a gauge
func (*StatsdClient) Incr ¶
func (c *StatsdClient) Incr(stat string, count int64) error
Incr - Increment a counter metric. Often used to note a particular event
func (*StatsdClient) PrecisionTiming ¶
func (c *StatsdClient) PrecisionTiming(stat string, delta time.Duration) error
PrecisionTiming - Track a duration event the time delta has to be a duration
func (*StatsdClient) Reconnect ¶
func (c *StatsdClient) Reconnect() error
Reconnect causes the client to re-create its underlying socket used to send stats. Any existing socket is closed after opening a new socket. Any error encountered while closing an existing socket is logged, but not returned.
func (*StatsdClient) SendEvent ¶
func (c *StatsdClient) SendEvent(e event.Event) error
SendEvent - Sends stats from an event object
func (*StatsdClient) SendEvents ¶
func (c *StatsdClient) SendEvents(events map[string]event.Event) error
SendEvents - Sends stats from all the event objects. Tries to bundle many together into one fmt.Fprintf based on UDPPayloadSize.
func (*StatsdClient) String ¶
func (c *StatsdClient) String() string
String returns the StatsD server address