statser

package
v0.0.0-...-170def7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

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

type InternalEventHandler interface {
	DispatchEvent(context.Context, *gostatsd.Event) error
}

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

func (fn *InternalStatser) NotifyFlush(d time.Duration)

NotifyFlush will notify any registered channels that a flush has completed. Non-blocking, thread-safe.

func (*InternalStatser) RegisterFlush

func (fn *InternalStatser) RegisterFlush() (ch <-chan time.Duration, unregister func())

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

func (is *InternalStatser) TimingDuration(name string, d time.Duration, tags gostatsd.Tags)

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) WithTags

func (is *InternalStatser) WithTags(tags gostatsd.Tags) Statser

WithTags creates a new Statser with additional tags

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

func (fn *LoggingStatser) NotifyFlush(d time.Duration)

NotifyFlush will notify any registered channels that a flush has completed. Non-blocking, thread-safe.

func (*LoggingStatser) RegisterFlush

func (fn *LoggingStatser) RegisterFlush() (ch <-chan time.Duration, unregister func())

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

func (ls *LoggingStatser) TimingDuration(name string, d time.Duration, tags gostatsd.Tags)

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) WithTags

func (ls *LoggingStatser) WithTags(tags gostatsd.Tags) Statser

WithTags creates a new Statser with additional tags

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

func (fn *NullStatser) NotifyFlush(d time.Duration)

NotifyFlush will notify any registered channels that a flush has completed. Non-blocking, thread-safe.

func (*NullStatser) RegisterFlush

func (fn *NullStatser) RegisterFlush() (ch <-chan time.Duration, unregister func())

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

func (ns *NullStatser) TimingDuration(name string, d time.Duration, tags gostatsd.Tags)

TimingDuration does nothing

func (*NullStatser) TimingMS

func (ns *NullStatser) TimingMS(name string, ms float64, tags gostatsd.Tags)

TimingMS does nothing

func (*NullStatser) WithTags

func (ns *NullStatser) WithTags(tags gostatsd.Tags) Statser

WithTags returns a NullStatser

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

func NewLoggingStatser(tags gostatsd.Tags, logger *log.Entry) Statser

NewLoggingStatser creates a new Statser which sends metrics to the supplied log.Entry

func NewNullStatser

func NewNullStatser() Statser

NewNullStatser creates a new NullStatser

func NewTaggedStatser

func NewTaggedStatser(statser Statser, tags gostatsd.Tags) Statser

NewTaggedStatser creates a new Statser which adds additional tags all metrics submitted.

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

func (ts *TaggedStatser) TimingDuration(name string, d time.Duration, tags gostatsd.Tags)

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) WithTags

func (ts *TaggedStatser) WithTags(tags gostatsd.Tags) Statser

WithTags creates a new Statser with additional tags

type Timer

type Timer struct {
	// contains filtered or unexported fields
}

Timer times an operation and submits a timing or gauge metric

func (*Timer) Send

func (t *Timer) Send()

Send sends a timing style metric

func (*Timer) SendGauge

func (t *Timer) SendGauge()

SendGauge sends a gauge metric in milliseconds

func (*Timer) Stop

func (t *Timer) Stop()

Stop stops the time being recorded

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL