types

package
v0.0.0-...-5655933 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInstancesEmpty = errors.New("instances empty")

Functions

This section is empty.

Types

type Field

type Field struct {
	Key   string
	Value interface{}
}

Field represents a single field key and value.

type Metric

type Metric interface {
	// Name is the primary identifier for the Metric and corresponds to the
	// measurement in the InfluxDB data model.
	Name() string

	// Tags returns the tags as a map.  This method is deprecated, use TagList instead.
	Tags() map[string]string

	// TagList returns the tags as a slice ordered by the tag key in lexical
	// bytewise ascending order.  The returned value should not be modified,
	// use the AddTag or RemoveTag methods instead.
	TagList() []*Tag

	// Fields returns the fields as a map.  This method is deprecated, use FieldList instead.
	Fields() map[string]interface{}

	// FieldList returns the fields as a slice in an undefined order.  The
	// returned value should not be modified, use the AddField or RemoveField
	// methods instead.
	FieldList() []*Field

	// Time returns the timestamp of the metric.
	Time() time.Time

	// Type returns a general type for the entire metric that describes how you
	// might interpret, aggregate the values. Used by prometheus and statsd.
	Type() ValueType

	// SetName sets the metric name.
	SetName(name string)

	// AddPrefix adds a string to the front of the metric name.  It is
	// equivalent to m.SetName(prefix + m.Name()).
	//
	// This method is deprecated, use SetName instead.
	AddPrefix(prefix string)

	// AddSuffix appends a string to the back of the metric name.  It is
	// equivalent to m.SetName(m.Name() + suffix).
	//
	// This method is deprecated, use SetName instead.
	AddSuffix(suffix string)

	// GetTag returns the value of a tag and a boolean to indicate if it was set.
	GetTag(key string) (string, bool)

	// HasTag returns true if the tag is set on the Metric.
	HasTag(key string) bool

	// AddTag sets the tag on the Metric.  If the Metric already has the tag
	// set then the current value is replaced.
	AddTag(key, value string)

	// RemoveTag removes the tag if it is set.
	RemoveTag(key string)

	// GetField returns the value of a field and a boolean to indicate if it was set.
	GetField(key string) (interface{}, bool)

	// HasField returns true if the field is set on the Metric.
	HasField(key string) bool

	// AddField sets the field on the Metric.  If the Metric already has the field
	// set then the current value is replaced.
	AddField(key string, value interface{})

	// RemoveField removes the tag if it is set.
	RemoveField(key string)

	// SetTime sets the timestamp of the Metric.
	SetTime(t time.Time)

	// HashID returns an unique identifier for the series.
	HashID() uint64

	// Copy returns a deep copy of the Metric.
	Copy() Metric

	// Accept marks the metric as processed successfully and written to an
	// output.
	Accept()

	// Reject marks the metric as processed unsuccessfully.
	Reject()

	// Drop marks the metric as processed successfully without being written
	// to any output.
	Drop()
}

Metric is the type of data that is processed by Telegraf. Input plugins, and to a lesser degree, Processor and Aggregator plugins create new Metrics and Output plugins write them.

type SafeList

type SafeList[T any] struct {
	sync.RWMutex
	L *list.List
}

SafeList is a thread-safe list

func NewSafeList

func NewSafeList[T any]() *SafeList[T]

func (*SafeList[T]) Len

func (sl *SafeList[T]) Len() int

func (*SafeList[T]) PopBack

func (sl *SafeList[T]) PopBack() *T

func (*SafeList[T]) PopBackAll

func (sl *SafeList[T]) PopBackAll() []T

func (*SafeList[T]) PopBackN

func (sl *SafeList[T]) PopBackN(n int) []T

func (*SafeList[T]) PushFront

func (sl *SafeList[T]) PushFront(v T) *list.Element

func (*SafeList[T]) PushFrontN

func (sl *SafeList[T]) PushFrontN(vs []T)

func (*SafeList[T]) RemoveAll

func (sl *SafeList[T]) RemoveAll()

type SafeListLimited

type SafeListLimited[T any] struct {
	SL *SafeList[T]
	// contains filtered or unexported fields
}

SafeListLimited is SafeList with Limited Size

func NewSafeListLimited

func NewSafeListLimited[T any](maxSize int) *SafeListLimited[T]

func (*SafeListLimited[T]) Len

func (sll *SafeListLimited[T]) Len() int

func (*SafeListLimited[T]) PopBack

func (sll *SafeListLimited[T]) PopBack() *T

func (*SafeListLimited[T]) PopBackAll

func (sll *SafeListLimited[T]) PopBackAll() []T

func (*SafeListLimited[T]) PopBackN

func (sll *SafeListLimited[T]) PopBackN(n int) []T

func (*SafeListLimited[T]) PushFront

func (sll *SafeListLimited[T]) PushFront(v T) bool

func (*SafeListLimited[T]) PushFrontN

func (sll *SafeListLimited[T]) PushFrontN(vs []T) bool

func (*SafeListLimited[T]) RemoveAll

func (sll *SafeListLimited[T]) RemoveAll()

type Sample

type Sample struct {
	Metric    string            `json:"metric"`
	Timestamp time.Time         `json:"timestamp"`
	Value     interface{}       `json:"value"`
	Labels    map[string]string `json:"labels"`
}

func NewSample

func NewSample(prefix, metric string, value interface{}, labels ...map[string]string) *Sample

func (*Sample) ConvertTimeSeries

func (item *Sample) ConvertTimeSeries(precision string) *prompb.TimeSeries

func (*Sample) SetTime

func (s *Sample) SetTime(t time.Time) *Sample

type SampleList

type SampleList struct {
	SafeList[*Sample]
}

func NewSampleList

func NewSampleList() *SampleList

func (*SampleList) PushSample

func (l *SampleList) PushSample(prefix, metric string, value interface{}, labels ...map[string]string) *list.Element

func (*SampleList) PushSamples

func (l *SampleList) PushSamples(prefix string, fields map[string]interface{}, labels ...map[string]string)

type Tag

type Tag struct {
	Key   string
	Value string
}

Tag represents a single tag key and value.

type ValueType

type ValueType int

ValueType is an enumeration of metric types that represent a simple value.

const (
	Counter ValueType
	Gauge
	Untyped
	Summary
	Histogram
)

Possible values for the ValueType enum.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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