metric

package module
v0.0.0-...-7861f02 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TimeWithPrecision

func TimeWithPrecision(t time.Time, precision time.Duration) time.Time

TimeWithPrecision returns the given time rounded to the given precision

Types

type Accumulator

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

func NewAccumulator

func NewAccumulator(
	pluginname string,
	metrics chan<- Metric,
) *Accumulator

NewAccumulator returns a new Accumulator instance

func (*Accumulator) AddError

func (ac *Accumulator) AddError(err error)

AddError passes a runtime error to the Accumulator. The error will be tagged with the plugin name and written to the log.

func (*Accumulator) AddFields

func (ac *Accumulator) AddFields(
	measurement string,
	fields map[string]interface{},
	tags map[string]string,
	t time.Time,
)

func (*Accumulator) AddMetric

func (ac *Accumulator) AddMetric(m Metric)

func (*Accumulator) SetPrecision

func (ac *Accumulator) SetPrecision(precision time.Duration)

func (*Accumulator) WithErrorWriter

func (ac *Accumulator) WithErrorWriter(errfile io.Writer) *Accumulator

type BytesFormat

type BytesFormat uint8

BytesFormat represents supported decode formats

const (
	Go BytesFormat = iota
	InfluxLp
)

type Field

type Field struct {
	Key   string
	Value interface{}
}

Field represents a single field key and value.

type Metric

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

func FromMetric

func FromMetric(other Metric) Metric

FromMetric returns a deep copy of the metric with any tracking information removed.

func New

func New(
	name string,
	tags map[string]string,
	fields map[string]interface{},
	tm time.Time,
) Metric

func (*Metric) AddField

func (m *Metric) AddField(key string, value interface{})

func (*Metric) AddPrefix

func (m *Metric) AddPrefix(prefix string)

func (*Metric) AddSuffix

func (m *Metric) AddSuffix(suffix string)

func (*Metric) AddTag

func (m *Metric) AddTag(key, value string)

func (*Metric) Bytes

func (m *Metric) Bytes(format BytesFormat) []byte

String returns a []byte representation of the metric in the given format

(https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md)

Currently it only supports influx line protocol

func (*Metric) Copy

func (m *Metric) Copy() Metric

func (*Metric) Field

func (m *Metric) Field(key string) interface{}

func (*Metric) FieldList

func (m *Metric) FieldList() []*Field

func (*Metric) Fields

func (m *Metric) Fields() map[string]interface{}

func (*Metric) GetField

func (m *Metric) GetField(key string) (interface{}, bool)

func (*Metric) GetTag

func (m *Metric) GetTag(key string) (string, bool)

func (*Metric) HasField

func (m *Metric) HasField(key string) bool

func (*Metric) HasTag

func (m *Metric) HasTag(key string) bool

func (*Metric) HashID

func (m *Metric) HashID() uint64

func (*Metric) Name

func (m *Metric) Name() string

func (*Metric) RemoveField

func (m *Metric) RemoveField(key string)

func (*Metric) RemoveTag

func (m *Metric) RemoveTag(key string)

func (*Metric) SetName

func (m *Metric) SetName(name string)

func (*Metric) SetTime

func (m *Metric) SetTime(t time.Time)

func (*Metric) String

func (m *Metric) String(format BytesFormat) string

String returns a string representation of the metric in the given format

func (*Metric) Tag

func (m *Metric) Tag(key string) string

func (*Metric) TagList

func (m *Metric) TagList() []*Tag

func (*Metric) Tags

func (m *Metric) Tags() map[string]string

func (*Metric) Time

func (m *Metric) Time() time.Time

type Tag

type Tag struct {
	Key   string
	Value string
}

Tag represents a single tag key and value.

Jump to

Keyboard shortcuts

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