Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RecordingSender ¶
type RecordingSender struct {
// contains filtered or unexported fields
}
RecordingSender implements statsd.Sender but parses individual Stats into a buffer that can be later inspected instead of sending to some server. It should constructed with NewRecordingSender().
func NewRecordingSender ¶
func NewRecordingSender() *RecordingSender
NewRecordingSender creates a new RecordingSender for use by a statsd.Client.
func (*RecordingSender) ClearSent ¶
func (rs *RecordingSender) ClearSent()
ClearSent locks the sender and clears any Stats that have been recorded.
func (*RecordingSender) Close ¶
func (rs *RecordingSender) Close() error
Close marks this sender as closed. Subsequent attempts to Send stats will result in an error.
func (*RecordingSender) GetSent ¶
func (rs *RecordingSender) GetSent() Stats
GetSent returns the stats that have been sent. Locks and copies the current state of the sent Stats.
The entire buffer of Stat objects (including Stat.Raw is copied).
func (*RecordingSender) Send ¶
func (rs *RecordingSender) Send(data []byte) (int, error)
Send parses the provided []byte into stat objects and then appends these to the buffer of sent stats. Buffer operations are synchronized so it is safe to call this from multiple goroutines (though contenion will impact performance so don't use this during a benchmark). Send treats '\n' as a delimiter between multiple sats in the same []byte.
Calling after the Sender has been closed will return an error (and not mutate the buffer).
type Stat ¶
Stat contains the raw and extracted stat information from a stat that was sent by the RecordingSender. Raw will always have the content that was consumed for this specific stat and Parsed will be set if no errors were hit pulling information out of it.
type Stats ¶
type Stats []Stat
Stats is a slice of Stat
func ParseStats ¶
ParseStats takes a sequence of bytes destined for a Statsd server and parses it out into one or more Stat structs. Each struct includes both the raw bytes (copied, so the src []byte may be reused if desired) as well as each component it was able to parse out. If parsing was incomplete Stat.Parsed will be set to false but no error is returned / kept.
func (Stats) CollectNamed ¶
CollectNamed returns all data sent for a given stat name.