pulseemitter

package
v7.4.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 7, 2019 License: Apache-2.0 Imports: 7 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CounterMetric

type CounterMetric interface {
	// Increment increases the counter's delta by the given value
	Increment(c uint64)

	// Emit sends the counter values to the LogClient.
	Emit(c LogClient)
}

CounterMetric is used by the pulse emitter to emit counter metrics to the LogClient.

func NewCounterMetric

func NewCounterMetric(name, sourceID string, opts ...MetricOption) CounterMetric

NewCounterMetric returns a new counterMetric that can be incremented and emitted via a LogClient.

type GaugeMetric

type GaugeMetric interface {
	// Set sets the current value of the gauge metric.
	Set(n float64)

	// Emit sends the counter values to the LogClient.
	Emit(c LogClient)
}

GaugeMetric is used by the pulse emitter to emit gauge metrics to the LogClient.

func NewGaugeMetric

func NewGaugeMetric(name, unit, sourceID string, opts ...MetricOption) GaugeMetric

NewGaugeMetric returns a new gaugeMetric that has a value that can be set and emitted via a LogClient.

type LogClient

type LogClient interface {
	EmitCounter(name string, opts ...loggregator.EmitCounterOption)
	EmitGauge(opts ...loggregator.EmitGaugeOption)
}

LogClient is the client used by PulseEmitter to emit metrics. This would usually be the go-loggregator v2 client.

type MetricOption

type MetricOption func(map[string]string)

MetricOption defines a function type that can be used to configure tags for many types of metrics.

func WithTags

func WithTags(tags map[string]string) MetricOption

WithTags will set the tags to apply to every envelopes sent about the metric..

func WithVersion

func WithVersion(major, minor uint) MetricOption

WithVersion will apply a `metric_version` tag to all envelopes sent about the metric.

type PulseEmitter

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

PulseEmitter will emit metrics on a given interval.

func New

func New(c LogClient, opts ...PulseEmitterOption) *PulseEmitter

New returns a PulseEmitter configured with the given LogClient and PulseEmitterOptions. The default pulse interval is 60 seconds.

func (*PulseEmitter) NewCounterMetric

func (c *PulseEmitter) NewCounterMetric(name string, opts ...MetricOption) CounterMetric

NewCounterMetric returns a CounterMetric that can be incremented. After calling NewCounterMetric the counter metric will begin to be emitted on the interval configured on the PulseEmitter. If the counter metrics value has not changed since last emitted a 0 value will be emitted. Every time the counter metric is emitted, its delta is reset to 0.

func (*PulseEmitter) NewGaugeMetric

func (c *PulseEmitter) NewGaugeMetric(name, unit string, opts ...MetricOption) GaugeMetric

NewGaugeMetric returns a GaugeMetric that has a value that can be set. After calling NewGaugeMetric the gauge metric will begin to be emitted on the interval configured on the PulseEmitter. When emitting the gauge metric, it will use the last value given when calling set on the gauge metric.

type PulseEmitterOption

type PulseEmitterOption func(*PulseEmitter)

PulseEmitterOption is a function type that is used to configure optional settings for a PulseEmitter.

func WithPulseInterval

func WithPulseInterval(d time.Duration) PulseEmitterOption

WithPulseInterval is a PulseEmitterOption for setting the pulsing interval.

func WithSourceID

func WithSourceID(id string) PulseEmitterOption

WithSourceID is a PulseEmitterOption for setting the source ID that will be set on all outgoing metrics.

Jump to

Keyboard shortcuts

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