snitch

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2018 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomPoint

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

CustomPoint is the base structure used by Point, CustomPoint should be used if you need more control over your stats.

func (*CustomPoint) GetCount

func (p *CustomPoint) GetCount() int64

GetCount return the current count.

func (*CustomPoint) GetTimestamp

func (p *CustomPoint) GetTimestamp() int64

GetTimestamp returns the current timestamp.

func (*CustomPoint) GetValue

func (p *CustomPoint) GetValue() float64

GetValue return the current value.

func (*CustomPoint) IsValueNull

func (p *CustomPoint) IsValueNull() bool

IsValueNull informs if the value is null or not.

func (*CustomPoint) Run

func (p *CustomPoint) Run()

Run takes care of the logic for sending points

func (*CustomPoint) SetCount

func (p *CustomPoint) SetCount(i int64)

SetCount sets count to i.

func (*CustomPoint) SetTimestamp

func (p *CustomPoint) SetTimestamp(t int64)

SetTimestamp sets timestamp to t.

func (*CustomPoint) SetValue

func (p *CustomPoint) SetValue(v float64)

SetValue sets value to v.

func (*CustomPoint) SetValueNull

func (p *CustomPoint) SetValueNull()

SetValueNull sets the value to zero and the valNull boolean to true.

func (*CustomPoint) ValueAdd

func (p *CustomPoint) ValueAdd(v float64)

ValueAdd adds v to value and increment the counter.

type Point

type Point struct {
	Name         string
	Metric       string
	Tags         map[string]string
	Aggregation  string
	SendInterval string
	KeepValue    bool
	SendOnNull   bool
	Disabled     bool
}

Point holds information required by timeseries and also control variables for the stats package.

type PostTransform

type PostTransform func(p *CustomPoint)

PostTransform is called just after the point is send.

type PreTransform

type PreTransform func(p *CustomPoint) bool

PreTransform is called just before the point is send.

type Settings

type Settings struct {
	Address          string
	Port             string
	Protocol         string
	HTTPTimeout      string
	HTTPPostInterval string
	Tags             map[string]string
	KSID             string
	Interval         string
	Runtime          bool
}

Settings represents default package-wide settings.

type Stats

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

Stats holds several informations. The timeseries backend address and port. The POST interval. The default tags to be added to all points and a map of all points.

func New

func New(logger *zap.Logger, settings Settings) (*Stats, error)

New creates a new stats

func (*Stats) Increment

func (st *Stats) Increment(
	metricName string,
	tags map[string]string,
	interval string,
	keep, nullable bool,
) error

Increment is a shorthand to ValueAdd with a value of one

func (*Stats) SetValue

func (st *Stats) SetValue(
	metricName string,
	tags map[string]string,
	interval string,
	keep, nullable bool, v float64,
) error

SetValue looks on the stats map for the point with the given name and set its value to v

func (*Stats) ValueAdd

func (st *Stats) ValueAdd(
	metricName string,
	tags map[string]string,
	aggregation, interval string,
	keep, nullable bool, v float64,
) error

ValueAdd looks on the stats map for the point with the given name and adds v to its value.

Jump to

Keyboard shortcuts

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