metricbatcher

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2016 License: Apache-2.0 Imports: 3 Imported by: 33

Documentation

Overview

package metricbatcher provides a mechanism to batch counter updates into a single event.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchCounterChainer

type BatchCounterChainer interface {
	SetTag(key, value string) BatchCounterChainer
	Increment()
	Add(value uint64)
}

type MetricBatcher

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

MetricBatcher batches counter increment/add calls into periodic, aggregate events.

func New

func New(metricSender MetricSender, batchDuration time.Duration) *MetricBatcher

New instantiates a running MetricBatcher. Eventswill be emitted once per batchDuration. All updates to a given counter name will be combined into a single event and sent to metricSender.

func (*MetricBatcher) BatchAddCounter

func (mb *MetricBatcher) BatchAddCounter(name string, delta uint64)

BatchAddCounter increments the named counter by the provided delta, but does not immediately send a CounterEvent.

func (*MetricBatcher) BatchCounter

func (mb *MetricBatcher) BatchCounter(name string) BatchCounterChainer

BatchCounter returns a BatchCounterChainer which can be used to prepare a counter event before batching it up.

func (*MetricBatcher) BatchIncrementCounter

func (mb *MetricBatcher) BatchIncrementCounter(name string)

BatchIncrementCounter increments the named counter by 1, but does not immediately send a CounterEvent.

func (*MetricBatcher) Close

func (mb *MetricBatcher) Close()

Closes the metrics batcher. Using the batcher after closing, will cause a panic.

func (*MetricBatcher) Reset

func (mb *MetricBatcher) Reset()

Reset clears the MetricBatcher's internal state, so that no counters are tracked.

type MetricSender

type MetricSender interface {
	Counter(name string) metric_sender.CounterChainer
}

Jump to

Keyboard shortcuts

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