models

package
v0.0.0-...-2a2e17e Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Default size of metrics batch size.
	DEFAULT_METRIC_BATCH_SIZE = 1000

	// Default number of metrics kept. It should be a multiple of batch size.
	DEFAULT_METRIC_BUFFER_LIMIT = 10000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Buffer stores metrics in a circular buffer.

func NewBuffer

func NewBuffer(name string, alias string, capacity int) *Buffer

NewBuffer returns a new empty Buffer with the given capacity.

func (*Buffer) Accept

func (b *Buffer) Accept(batch []internal.Metric)

Accept marks the batch, acquired from Batch(), as successfully written.

func (*Buffer) Add

func (b *Buffer) Add(metrics ...internal.Metric) int

Add adds metrics to the buffer and returns number of dropped metrics.

func (*Buffer) Batch

func (b *Buffer) Batch(batchSize int) []internal.Metric

Batch returns a slice containing up to batchSize of the most recently added metrics. Metrics are ordered from newest to oldest in the batch. The batch must not be modified by the client.

func (*Buffer) Len

func (b *Buffer) Len() int

Len returns the number of metrics currently in the buffer.

func (*Buffer) Reject

func (b *Buffer) Reject(batch []internal.Metric)

Reject returns the batch, acquired from Batch(), to the buffer and marks it as unsent.

type InputConfig

type InputConfig struct {
	Name     string
	Alias    string
	Interval time.Duration

	NameOverride      string
	MeasurementPrefix string
	MeasurementSuffix string
	Tags              map[string]string
}

InputConfig is the common config for all inputs.

type OutputConfig

type OutputConfig struct {
	Name  string
	Alias string

	FlushInterval     time.Duration
	FlushJitter       *time.Duration
	MetricBufferLimit int
	MetricBatchSize   int
}

OutputConfig containing name

type RunningInput

type RunningInput struct {
	Input  plugins.Input
	Config *InputConfig
	// contains filtered or unexported fields
}

func NewRunningInput

func NewRunningInput(input plugins.Input, config *InputConfig) *RunningInput

func (*RunningInput) Gather

func (r *RunningInput) Gather(acc plugins.Accumulator) error

func (*RunningInput) Init

func (r *RunningInput) Init() error

func (*RunningInput) LogName

func (r *RunningInput) LogName() string

func (*RunningInput) MakeMetric

func (r *RunningInput) MakeMetric(metric internal.Metric) internal.Metric

func (*RunningInput) SetDefaultTags

func (r *RunningInput) SetDefaultTags(tags map[string]string)

type RunningOutput

type RunningOutput struct {
	Output            plugins.Output
	Config            *OutputConfig
	MetricBufferLimit int
	MetricBatchSize   int

	BatchReady chan time.Time
	// contains filtered or unexported fields
}

RunningOutput contains the output configuration

func NewRunningOutput

func NewRunningOutput(
	name string,
	output plugins.Output,
	config *OutputConfig,
	batchSize int,
	bufferLimit int,
) *RunningOutput

func (*RunningOutput) AddMetric

func (r *RunningOutput) AddMetric(metric internal.Metric)

AddMetric adds a metric to the output.

func (*RunningOutput) Close

func (r *RunningOutput) Close()

func (*RunningOutput) Init

func (r *RunningOutput) Init() error

func (*RunningOutput) LogBufferStatus

func (r *RunningOutput) LogBufferStatus()

func (*RunningOutput) LogName

func (r *RunningOutput) LogName() string

func (*RunningOutput) Write

func (r *RunningOutput) Write() error

Write writes all metrics to the output, stopping when all have been sent on or error.

func (*RunningOutput) WriteBatch

func (r *RunningOutput) WriteBatch() error

WriteBatch writes a single batch of metrics to the output.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳