metricbatcher

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0 Imports: 3 Imported by: 19 modules, 38 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Jump to

Keyboard shortcuts

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