2016-01-27 21:21:36 +00:00
|
|
|
package telegraf
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2016-08-30 17:09:48 +00:00
|
|
|
// ValueType is an enumeration of metric types that represent a simple value.
|
|
|
|
type ValueType int
|
|
|
|
|
|
|
|
// Possible values for the ValueType enum.
|
|
|
|
const (
|
|
|
|
_ ValueType = iota
|
|
|
|
Counter
|
|
|
|
Gauge
|
|
|
|
Untyped
|
2017-10-24 23:28:52 +00:00
|
|
|
Summary
|
|
|
|
Histogram
|
2016-08-30 17:09:48 +00:00
|
|
|
)
|
|
|
|
|
2016-01-27 21:21:36 +00:00
|
|
|
type Metric interface {
|
2016-12-04 20:18:13 +00:00
|
|
|
// Serialize serializes the metric into a line-protocol byte buffer,
|
|
|
|
// including a newline at the end.
|
2016-11-22 12:51:57 +00:00
|
|
|
Serialize() []byte
|
2016-12-04 20:18:13 +00:00
|
|
|
// same as Serialize, but avoids an allocation.
|
|
|
|
// returns number of bytes copied into dst.
|
|
|
|
SerializeTo(dst []byte) int
|
|
|
|
// String is the same as Serialize, but returns a string.
|
|
|
|
String() string
|
|
|
|
// Copy deep-copies the metric.
|
2016-11-22 12:51:57 +00:00
|
|
|
Copy() Metric
|
2016-12-05 13:00:37 +00:00
|
|
|
// Split will attempt to return multiple metrics with the same timestamp
|
|
|
|
// whose string representations are no longer than maxSize.
|
|
|
|
// Metrics with a single field may exceed the requested size.
|
|
|
|
Split(maxSize int) []Metric
|
2016-01-27 21:21:36 +00:00
|
|
|
|
2016-11-22 12:51:57 +00:00
|
|
|
// Tag functions
|
|
|
|
HasTag(key string) bool
|
|
|
|
AddTag(key, value string)
|
2016-12-01 15:18:46 +00:00
|
|
|
RemoveTag(key string)
|
2016-01-27 21:21:36 +00:00
|
|
|
|
2016-11-22 12:51:57 +00:00
|
|
|
// Field functions
|
|
|
|
HasField(key string) bool
|
|
|
|
AddField(key string, value interface{})
|
2016-12-01 15:18:46 +00:00
|
|
|
RemoveField(key string) error
|
2016-01-27 21:21:36 +00:00
|
|
|
|
2016-11-22 12:51:57 +00:00
|
|
|
// Name functions
|
|
|
|
SetName(name string)
|
|
|
|
SetPrefix(prefix string)
|
|
|
|
SetSuffix(suffix string)
|
2016-08-30 17:09:48 +00:00
|
|
|
|
2016-11-22 12:51:57 +00:00
|
|
|
// Getting data structure functions
|
|
|
|
Name() string
|
|
|
|
Tags() map[string]string
|
|
|
|
Fields() map[string]interface{}
|
|
|
|
Time() time.Time
|
2016-01-27 21:21:36 +00:00
|
|
|
UnixNano() int64
|
2016-11-22 12:51:57 +00:00
|
|
|
Type() ValueType
|
|
|
|
Len() int // returns the length of the serialized metric, including newline
|
2016-09-08 14:22:10 +00:00
|
|
|
HashID() uint64
|
|
|
|
|
2016-11-22 12:51:57 +00:00
|
|
|
// aggregator things:
|
2016-09-08 14:22:10 +00:00
|
|
|
SetAggregate(bool)
|
|
|
|
IsAggregate() bool
|
2016-11-23 12:30:31 +00:00
|
|
|
}
|