Documentation
¶
Index ¶
- Variables
- 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) SendEvents(events map[string]event.Event) 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) SendEvents(events map[string]event.Event) 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) DecrWithSampling(stat string, count int64, sampleRate float32) 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) FGaugeWithSampling(stat string, value float64, sampleRate float32) error
- func (c *StatsdClient) Gauge(stat string, value int64) error
- func (c *StatsdClient) GaugeDelta(stat string, value int64) error
- func (c *StatsdClient) GaugeWithSampling(stat string, value int64, sampleRate float32) error
- func (c *StatsdClient) Incr(stat string, count int64) error
- func (c *StatsdClient) IncrWithSampling(stat string, count int64, sampleRate float32) error
- func (c *StatsdClient) PrecisionTiming(stat string, delta time.Duration) 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) TimingWithSampling(stat string, delta int64, sampleRate float32) error
- func (c *StatsdClient) Total(stat string, value int64) error
- type StdoutClient
- func (s *StdoutClient) Absolute(stat string, value int64) error
- func (s *StdoutClient) Close() error
- func (s *StdoutClient) CreateSocket() error
- func (s *StdoutClient) CreateTCPSocket() error
- func (s *StdoutClient) Decr(stat string, count int64) error
- func (s *StdoutClient) FAbsolute(stat string, value float64) error
- func (s *StdoutClient) FGauge(stat string, value float64) error
- func (s *StdoutClient) FGaugeDelta(stat string, value float64) error
- func (s *StdoutClient) Gauge(stat string, value int64) error
- func (s *StdoutClient) GaugeDelta(stat string, value int64) error
- func (s *StdoutClient) Incr(stat string, count int64) error
- func (s *StdoutClient) PrecisionTiming(stat string, delta time.Duration) error
- func (s *StdoutClient) SendEvent(e event.Event) error
- func (s *StdoutClient) SendEvents(events map[string]event.Event) error
- func (s *StdoutClient) Timing(stat string, delta int64) error
- func (s *StdoutClient) Total(stat string, value int64) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidCount = errors.New("count is less than 0") ErrInvalidSampleRate = errors.New("sample rate is larger than 1 or less then 0") )
errors
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 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
func (NoopClient) SendEvents ¶
func (s NoopClient) SendEvents(events map[string]event.Event) error
SendEvents 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 SendEvents(events map[string]event.Event) 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 Statsd) *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
func (*StatsdBuffer) SendEvents ¶
func (sb *StatsdBuffer) SendEvents(events map[string]event.Event) error
SendEvents - Sends stats from all the event objects.
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) *StatsdClient
NewStatsdClient - Factory
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) DecrWithSampling ¶
func (c *StatsdClient) DecrWithSampling(stat string, count int64, sampleRate float32) error
DecrWithSampling - Decrement a counter metric with sampling between 0 and 1
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) FGaugeWithSampling ¶
func (c *StatsdClient) FGaugeWithSampling(stat string, value float64, sampleRate float32) error
FGaugeWithSampling - Gauges are a constant data type.
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) GaugeWithSampling ¶
func (c *StatsdClient) GaugeWithSampling(stat string, value int64, sampleRate float32) error
GaugeWithSampling - Gauges are a constant data type.
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) IncrWithSampling ¶
func (c *StatsdClient) IncrWithSampling(stat string, count int64, sampleRate float32) error
IncrWithSampling - Increment a counter metric with sampling between 0 and 1
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) 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
func (*StatsdClient) Timing ¶
func (c *StatsdClient) Timing(stat string, delta int64) error
Timing - Track a duration event the time delta must be given in milliseconds
func (*StatsdClient) TimingWithSampling ¶
func (c *StatsdClient) TimingWithSampling(stat string, delta int64, sampleRate float32) error
TimingWithSampling - Track a duration event
type StdoutClient ¶
StdoutClient implements a "no-op" statsd in case there is no statsd server
func NewStdoutClient ¶
func NewStdoutClient(filename string, prefix string) *StdoutClient
NewStdoutClient - Factory
func (*StdoutClient) Absolute ¶
func (s *StdoutClient) Absolute(stat string, value int64) error
Absolute - Send absolute-valued metric (not averaged/aggregated)
func (*StdoutClient) CreateSocket ¶
func (s *StdoutClient) CreateSocket() error
CreateSocket does nothing
func (*StdoutClient) CreateTCPSocket ¶
func (s *StdoutClient) CreateTCPSocket() error
CreateTCPSocket does nothing
func (*StdoutClient) Decr ¶
func (s *StdoutClient) Decr(stat string, count int64) error
Decr - Decrement a counter metric. Often used to note a particular event
func (*StdoutClient) FAbsolute ¶
func (s *StdoutClient) FAbsolute(stat string, value float64) error
FAbsolute - Send absolute-valued floating point metric (not averaged/aggregated)
func (*StdoutClient) FGauge ¶
func (s *StdoutClient) FGauge(stat string, value float64) error
FGauge -- Send a floating point value for a gauge
func (*StdoutClient) FGaugeDelta ¶
func (s *StdoutClient) FGaugeDelta(stat string, value float64) error
FGaugeDelta -- Send a floating point change for a gauge
func (*StdoutClient) Gauge ¶
func (s *StdoutClient) 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 (*StdoutClient) GaugeDelta ¶
func (s *StdoutClient) GaugeDelta(stat string, value int64) error
GaugeDelta -- Send a change for a gauge
func (*StdoutClient) Incr ¶
func (s *StdoutClient) Incr(stat string, count int64) error
Incr - Increment a counter metric. Often used to note a particular event
func (*StdoutClient) PrecisionTiming ¶
func (s *StdoutClient) PrecisionTiming(stat string, delta time.Duration) error
PrecisionTiming - Track a duration event the time delta has to be a duration
func (*StdoutClient) SendEvent ¶
func (s *StdoutClient) SendEvent(e event.Event) error
SendEvent - Sends stats from an event object
func (*StdoutClient) SendEvents ¶
func (s *StdoutClient) 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.