Documentation
¶
Index ¶
- type ChannelStatsWatcher
- type HeartBeater
- type InternalEventHandler
- type InternalMetricHandler
- type InternalStatser
- func (is *InternalStatser) Count(name string, amount float64, tags gostatsd.Tags)
- 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 (fn *InternalStatser) NotifyFlush(d time.Duration)
- func (fn *InternalStatser) RegisterFlush() (ch <-chan time.Duration, unregister func())
- func (is *InternalStatser) Run(ctx context.Context)
- 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) WithTags(tags gostatsd.Tags) Statser
- type LoggingStatser
- func (ls *LoggingStatser) Count(name string, amount float64, tags gostatsd.Tags)
- 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(d time.Duration)
- func (fn *LoggingStatser) RegisterFlush() (ch <-chan time.Duration, unregister func())
- 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) WithTags(tags gostatsd.Tags) Statser
- type NullStatser
- func (ns *NullStatser) Count(name string, amount float64, tags gostatsd.Tags)
- 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(d time.Duration)
- func (fn *NullStatser) RegisterFlush() (ch <-chan time.Duration, unregister func())
- 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) WithTags(tags gostatsd.Tags) Statser
- type Statser
- type TaggedStatser
- func (ts *TaggedStatser) Count(name string, amount float64, tags gostatsd.Tags)
- 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(d time.Duration)
- func (ts *TaggedStatser) RegisterFlush() (<-chan time.Duration, func())
- 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) WithTags(tags gostatsd.Tags) Statser
- type Timer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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(statser Statser, 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 InternalEventHandler ¶
InternalEventHandler is an interface to dispatch metrics to. Exists to break circular dependencies.
type InternalMetricHandler ¶
type InternalMetricHandler interface {
DispatchMetric(ctx context.Context, m *gostatsd.Metric) error
}
InternalMetricHandler is an interface to dispatch metrics to. Exists to break circular dependencies.
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(bufferSize int, tags gostatsd.Tags, namespace, hostname string, metrics InternalMetricHandler, events InternalEventHandler) *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) 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 ¶
NotifyFlush will notify any registered channels that a flush has completed. Non-blocking, thread-safe.
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) Run ¶
func (is *InternalStatser) Run(ctx context.Context)
Run will pull internal metrics off a small buffer, and dispatch them. It stops running when the context is closed.
func (*InternalStatser) TimingDuration ¶
TimingDuration sends a timing metric from a time.Duration
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) 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) TimingDuration ¶
TimingDuration sends a timing metric from a time.Duration
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) TimingDuration ¶
TimingDuration does nothing
type Statser ¶
type Statser interface { // NotifyFlush is called when a flush occurs. It signals all known subscribers. NotifyFlush(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) 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 }
Statser is the interface for sending metrics
func NewLoggingStatser ¶
NewLoggingStatser creates a new Statser which sends metrics to the supplied log.Entry
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) 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(d time.Duration)
func (*TaggedStatser) RegisterFlush ¶
func (ts *TaggedStatser) RegisterFlush() (<-chan time.Duration, func())
func (*TaggedStatser) TimingDuration ¶
TimingDuration sends a timing metric from a time.Duration