Documentation ¶
Overview ¶
package metricbatcher provides a mechanism to batch counter updates into a single event.
Index ¶
- type BatchCounterChainer
- type MetricBatcher
- func (mb *MetricBatcher) AddConsistentlyEmittedMetrics(names ...string)
- func (mb *MetricBatcher) BatchAddCounter(name string, delta uint64)
- func (mb *MetricBatcher) BatchCounter(name string) BatchCounterChainer
- func (mb *MetricBatcher) BatchIncrementCounter(name string)
- func (mb *MetricBatcher) Close()
- func (mb *MetricBatcher) Reset()
- type MetricSender
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) AddConsistentlyEmittedMetrics ¶ added in v1.1.0
func (mb *MetricBatcher) AddConsistentlyEmittedMetrics(names ...string)
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
}