Documentation ¶
Index ¶
- func NewContext(ctx context.Context, statser Statser) context.Context
- type ChangeGauge
- type ChannelStatsWatcher
- type HeartBeater
- type InternalStatser
- func (is *InternalStatser) Count(name string, amount float64, tags gostatsd.Tags)
- func (is *InternalStatser) Event(ctx context.Context, e *gostatsd.Event)
- func (is *InternalStatser) Gauge(name string, value float64, tags gostatsd.Tags)
- func (is *InternalStatser) Increment(name string, tags gostatsd.Tags)
- func (is *InternalStatser) NewTimer(name string, tags gostatsd.Tags) *Timer
- func (is *InternalStatser) NotifyFlush(ctx context.Context, d time.Duration)
- func (fn *InternalStatser) RegisterFlush() (ch <-chan time.Duration, unregister func())
- func (is *InternalStatser) Report(name string, value *uint64, tags gostatsd.Tags)
- func (is *InternalStatser) TimingDuration(name string, d time.Duration, tags gostatsd.Tags)
- func (is *InternalStatser) TimingMS(name string, ms float64, tags gostatsd.Tags)
- func (is *InternalStatser) WaitForEvents()
- func (is *InternalStatser) WithTags(tags gostatsd.Tags) Statser
- type LoggingStatser
- func (ls *LoggingStatser) Count(name string, amount float64, tags gostatsd.Tags)
- func (ls *LoggingStatser) Event(ctx context.Context, e *gostatsd.Event)
- func (ls *LoggingStatser) Gauge(name string, value float64, tags gostatsd.Tags)
- func (ls *LoggingStatser) Increment(name string, tags gostatsd.Tags)
- func (ls *LoggingStatser) NewTimer(name string, tags gostatsd.Tags) *Timer
- func (fn *LoggingStatser) NotifyFlush(ctx context.Context, d time.Duration)
- func (fn *LoggingStatser) RegisterFlush() (ch <-chan time.Duration, unregister func())
- func (ls *LoggingStatser) Report(name string, value *uint64, tags gostatsd.Tags)
- func (ls *LoggingStatser) TimingDuration(name string, d time.Duration, tags gostatsd.Tags)
- func (ls *LoggingStatser) TimingMS(name string, ms float64, tags gostatsd.Tags)
- func (ls *LoggingStatser) WaitForEvents()
- func (ls *LoggingStatser) WithTags(tags gostatsd.Tags) Statser
- type NullStatser
- func (ns *NullStatser) Count(name string, amount float64, tags gostatsd.Tags)
- func (ns *NullStatser) Event(ctx context.Context, e *gostatsd.Event)
- func (ns *NullStatser) Gauge(name string, value float64, tags gostatsd.Tags)
- func (ns *NullStatser) Increment(name string, tags gostatsd.Tags)
- func (ns *NullStatser) NewTimer(name string, tags gostatsd.Tags) *Timer
- func (fn *NullStatser) NotifyFlush(ctx context.Context, d time.Duration)
- func (fn *NullStatser) RegisterFlush() (ch <-chan time.Duration, unregister func())
- func (ns *NullStatser) Report(name string, value *uint64, tags gostatsd.Tags)
- func (ns *NullStatser) TimingDuration(name string, d time.Duration, tags gostatsd.Tags)
- func (ns *NullStatser) TimingMS(name string, ms float64, tags gostatsd.Tags)
- func (ns *NullStatser) WaitForEvents()
- func (ns *NullStatser) WithTags(tags gostatsd.Tags) Statser
- type Statser
- type TaggedStatser
- func (ts *TaggedStatser) Count(name string, amount float64, tags gostatsd.Tags)
- func (ts *TaggedStatser) Event(ctx context.Context, e *gostatsd.Event)
- func (ts *TaggedStatser) Gauge(name string, value float64, tags gostatsd.Tags)
- func (ts *TaggedStatser) Increment(name string, tags gostatsd.Tags)
- func (ts *TaggedStatser) NewTimer(name string, tags gostatsd.Tags) *Timer
- func (ts *TaggedStatser) NotifyFlush(ctx context.Context, d time.Duration)
- func (ts *TaggedStatser) RegisterFlush() (<-chan time.Duration, func())
- func (ts *TaggedStatser) Report(name string, value *uint64, tags gostatsd.Tags)
- func (ts *TaggedStatser) TimingDuration(name string, d time.Duration, tags gostatsd.Tags)
- func (ts *TaggedStatser) TimingMS(name string, ms float64, tags gostatsd.Tags)
- func (ts *TaggedStatser) WaitForEvents()
- func (ts *TaggedStatser) WithTags(tags gostatsd.Tags) Statser
- type Timer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ChangeGauge ¶
type ChangeGauge struct { // Cur is the last value expected to be sent. If this is changed, SendIfChanged will send the value for // 22 flush intervals in an attempt to retry any failures to send it. Cur is assumed to be atomic by // ChangeGauge.SendIfChanged, however if the owner has more specific knowledge, it can be written to // with non-atomic operations. Cur uint64 // atomic // contains filtered or unexported fields }
ChangeGauge is a simpler wrapper to send a gauge for a rare event, multiple times. It is primarily intended for things that won't change in the majority of cases (such as failure to parse a statsd line), and things that will be bursty (ie, transient http message failure). It isn't suitable for things which are constantly changing such as number of metrics or http requests.
func (*ChangeGauge) SendIfChanged ¶
func (cg *ChangeGauge) SendIfChanged(statser Statser, metricName string, tags gostatsd.Tags)
type ChannelStatsWatcher ¶
type ChannelStatsWatcher struct {
// contains filtered or unexported fields
}
ChannelStatsWatcher reports metrics about channel usage to a Statser
func NewChannelStatsWatcher ¶
func NewChannelStatsWatcher(statser Statser, channelName string, tags gostatsd.Tags, capacity int, lenFunc func() int, sampleInterval time.Duration) *ChannelStatsWatcher
NewChannelStatsWatcher creates a new ChannelStatsWatcher
func (*ChannelStatsWatcher) Run ¶
func (csw *ChannelStatsWatcher) Run(ctx context.Context)
Run will run a ChannelStatsWatcher in the background until the supplied context is closed. Metrics are sampled every sampleInterval, and written every flush.
type HeartBeater ¶
type HeartBeater struct {
// contains filtered or unexported fields
}
HeartBeater periodically sends a gauge for heartbeat purposes
func NewHeartBeater ¶
func NewHeartBeater(metricName string, tags gostatsd.Tags) *HeartBeater
NewHeartBeater creates a new HeartBeater
func (*HeartBeater) Run ¶
func (hb *HeartBeater) Run(ctx context.Context)
Run will run a HeartBeater in the background until the supplied context is closed.
type InternalStatser ¶
type InternalStatser struct {
// contains filtered or unexported fields
}
InternalStatser is a Statser which sends metrics to a handler on a best effort basis. If all buffers are full, metrics will be dropped. Dropped metrics will be accumulated and emitted as a gauge (not counter). Metrics sent after the context is closed will be counted as dropped, but never surfaced because it has nowhere to submit them.
There is an assumption (but not enforcement) that InternalStatser is a singleton, and therefore there is no namespacing/tags on the dropped metrics.
func NewInternalStatser ¶
func NewInternalStatser( tags gostatsd.Tags, namespace string, hostname gostatsd.Source, handler gostatsd.PipelineHandler, disableEvents bool, forwarderMode bool, ) *InternalStatser
NewInternalStatser creates a new Statser which sends metrics to the supplied InternalHandler.
func (*InternalStatser) Count ¶
func (is *InternalStatser) Count(name string, amount float64, tags gostatsd.Tags)
Count sends a counter metric
func (*InternalStatser) Event ¶
func (is *InternalStatser) Event(ctx context.Context, e *gostatsd.Event)
func (*InternalStatser) Gauge ¶
func (is *InternalStatser) Gauge(name string, value float64, tags gostatsd.Tags)
Gauge sends a gauge metric
func (*InternalStatser) Increment ¶
func (is *InternalStatser) Increment(name string, tags gostatsd.Tags)
Increment sends a counter metric with a value of 1
func (*InternalStatser) NewTimer ¶
func (is *InternalStatser) NewTimer(name string, tags gostatsd.Tags) *Timer
NewTimer returns a new timer with time set to now
func (*InternalStatser) NotifyFlush ¶
func (is *InternalStatser) NotifyFlush(ctx context.Context, d time.Duration)
func (*InternalStatser) RegisterFlush ¶
RegisterFlush returns a channel which will receive a notification after every flush, and a cleanup function which should be called to signal the channel is no longer being monitored. If the channel blocks, the notification will be silently dropped. Thread-safe.
func (*InternalStatser) Report ¶
func (is *InternalStatser) Report(name string, value *uint64, tags gostatsd.Tags)
func (*InternalStatser) TimingDuration ¶
TimingDuration sends a timing metric from a time.Duration
func (*InternalStatser) TimingMS ¶
func (is *InternalStatser) TimingMS(name string, ms float64, tags gostatsd.Tags)
TimingMS sends a timing metric from a millisecond value
func (*InternalStatser) WaitForEvents ¶
func (is *InternalStatser) WaitForEvents()
type LoggingStatser ¶
type LoggingStatser struct {
// contains filtered or unexported fields
}
LoggingStatser is a Statser which emits logs
func (*LoggingStatser) Count ¶
func (ls *LoggingStatser) Count(name string, amount float64, tags gostatsd.Tags)
Count sends a counter metric
func (*LoggingStatser) Event ¶
func (ls *LoggingStatser) Event(ctx context.Context, e *gostatsd.Event)
func (*LoggingStatser) Gauge ¶
func (ls *LoggingStatser) Gauge(name string, value float64, tags gostatsd.Tags)
Gauge sends a gauge metric
func (*LoggingStatser) Increment ¶
func (ls *LoggingStatser) Increment(name string, tags gostatsd.Tags)
Increment sends a counter metric with a value of 1
func (*LoggingStatser) NewTimer ¶
func (ls *LoggingStatser) NewTimer(name string, tags gostatsd.Tags) *Timer
NewTimer returns a new timer with time set to now
func (*LoggingStatser) NotifyFlush ¶
NotifyFlush will notify any registered channels that a flush has completed. Non-blocking, thread-safe.
func (*LoggingStatser) RegisterFlush ¶
RegisterFlush returns a channel which will receive a notification after every flush, and a cleanup function which should be called to signal the channel is no longer being monitored. If the channel blocks, the notification will be silently dropped. Thread-safe.
func (*LoggingStatser) Report ¶
func (ls *LoggingStatser) Report(name string, value *uint64, tags gostatsd.Tags)
func (*LoggingStatser) TimingDuration ¶
TimingDuration sends a timing metric from a time.Duration
func (*LoggingStatser) TimingMS ¶
func (ls *LoggingStatser) TimingMS(name string, ms float64, tags gostatsd.Tags)
TimingMS sends a timing metric from a millisecond value
func (*LoggingStatser) WaitForEvents ¶
func (ls *LoggingStatser) WaitForEvents()
type NullStatser ¶
type NullStatser struct {
// contains filtered or unexported fields
}
NullStatser is a null implementation of Statser, intended primarily for test purposes
func (*NullStatser) Count ¶
func (ns *NullStatser) Count(name string, amount float64, tags gostatsd.Tags)
Count does nothing
func (*NullStatser) Gauge ¶
func (ns *NullStatser) Gauge(name string, value float64, tags gostatsd.Tags)
Gauge does nothing
func (*NullStatser) Increment ¶
func (ns *NullStatser) Increment(name string, tags gostatsd.Tags)
Increment does nothing
func (*NullStatser) NewTimer ¶
func (ns *NullStatser) NewTimer(name string, tags gostatsd.Tags) *Timer
NewTimer returns a new timer with time set to now
func (*NullStatser) NotifyFlush ¶
NotifyFlush will notify any registered channels that a flush has completed. Non-blocking, thread-safe.
func (*NullStatser) RegisterFlush ¶
RegisterFlush returns a channel which will receive a notification after every flush, and a cleanup function which should be called to signal the channel is no longer being monitored. If the channel blocks, the notification will be silently dropped. Thread-safe.
func (*NullStatser) Report ¶
func (ns *NullStatser) Report(name string, value *uint64, tags gostatsd.Tags)
func (*NullStatser) TimingDuration ¶
TimingDuration does nothing
func (*NullStatser) TimingMS ¶
func (ns *NullStatser) TimingMS(name string, ms float64, tags gostatsd.Tags)
TimingMS does nothing
func (*NullStatser) WaitForEvents ¶
func (ns *NullStatser) WaitForEvents()
type Statser ¶
type Statser interface { // NotifyFlush is called when a flush occurs. It signals all known subscribers. NotifyFlush(ctx context.Context, d time.Duration) // RegisterFlush returns a channel which will receive a notification after every flush, and a cleanup // function which should be called to signal the channel is no longer being monitored. If the channel // blocks, the notification will be silently dropped. RegisterFlush() (ch <-chan time.Duration, unregister func()) Gauge(name string, value float64, tags gostatsd.Tags) Count(name string, amount float64, tags gostatsd.Tags) Increment(name string, tags gostatsd.Tags) Report(name string, value *uint64, tags gostatsd.Tags) TimingMS(name string, ms float64, tags gostatsd.Tags) TimingDuration(name string, d time.Duration, tags gostatsd.Tags) NewTimer(name string, tags gostatsd.Tags) *Timer WithTags(tags gostatsd.Tags) Statser Event(ctx context.Context, e *gostatsd.Event) WaitForEvents() }
Statser is the interface for sending metrics
func FromContext ¶
FromContext returns a Statser from a Context. Always succeeds, will return a NullStatser if there is no statser present.
func NewLoggingStatser ¶
func NewLoggingStatser(tags gostatsd.Tags, logger logrus.FieldLogger) Statser
NewLoggingStatser creates a new Statser which sends metrics to the supplied logger.
type TaggedStatser ¶
type TaggedStatser struct {
// contains filtered or unexported fields
}
TaggedStatser adds tags and submits metrics to another Statser
func (*TaggedStatser) Count ¶
func (ts *TaggedStatser) Count(name string, amount float64, tags gostatsd.Tags)
Count sends a counter metric
func (*TaggedStatser) Event ¶
func (ts *TaggedStatser) Event(ctx context.Context, e *gostatsd.Event)
func (*TaggedStatser) Gauge ¶
func (ts *TaggedStatser) Gauge(name string, value float64, tags gostatsd.Tags)
Gauge sends a gauge metric
func (*TaggedStatser) Increment ¶
func (ts *TaggedStatser) Increment(name string, tags gostatsd.Tags)
Increment sends a counter metric with a value of 1
func (*TaggedStatser) NewTimer ¶
func (ts *TaggedStatser) NewTimer(name string, tags gostatsd.Tags) *Timer
NewTimer returns a new timer with time set to now
func (*TaggedStatser) NotifyFlush ¶
func (ts *TaggedStatser) NotifyFlush(ctx context.Context, d time.Duration)
func (*TaggedStatser) RegisterFlush ¶
func (ts *TaggedStatser) RegisterFlush() (<-chan time.Duration, func())
func (*TaggedStatser) Report ¶
func (ts *TaggedStatser) Report(name string, value *uint64, tags gostatsd.Tags)
func (*TaggedStatser) TimingDuration ¶
TimingDuration sends a timing metric from a time.Duration
func (*TaggedStatser) TimingMS ¶
func (ts *TaggedStatser) TimingMS(name string, ms float64, tags gostatsd.Tags)
TimingMS sends a timing metric from a millisecond value
func (*TaggedStatser) WaitForEvents ¶
func (ts *TaggedStatser) WaitForEvents()