Documentation ¶
Index ¶
- func GetLocalHost() string
- func MockMetrics() []telegraf.Metric
- func MustMetric(name string, tags map[string]string, fields map[string]interface{}, ...) telegraf.Metric
- func NewPKI(path string) *pki
- func RequireMetricEqual(t *testing.T, expected, actual telegraf.Metric)
- func RequireMetricsEqual(t *testing.T, expected, actual []telegraf.Metric)
- func TestMetric(value interface{}, name ...string) telegraf.Metric
- type Accumulator
- func (a *Accumulator) AddCounter(measurement string, fields map[string]interface{}, tags map[string]string, ...)
- func (a *Accumulator) AddError(err error)
- func (a *Accumulator) AddFields(measurement string, fields map[string]interface{}, tags map[string]string, ...)
- func (a *Accumulator) AddGauge(measurement string, fields map[string]interface{}, tags map[string]string, ...)
- func (a *Accumulator) AddHistogram(measurement string, fields map[string]interface{}, tags map[string]string, ...)
- func (a *Accumulator) AddMetrics(metrics []telegraf.Metric)
- func (a *Accumulator) AddSummary(measurement string, fields map[string]interface{}, tags map[string]string, ...)
- func (a *Accumulator) AssertContainsFields(t *testing.T, measurement string, fields map[string]interface{})
- func (a *Accumulator) AssertContainsTaggedFields(t *testing.T, measurement string, fields map[string]interface{}, ...)
- func (a *Accumulator) AssertDoesNotContainMeasurement(t *testing.T, measurement string)
- func (a *Accumulator) AssertDoesNotContainsTaggedFields(t *testing.T, measurement string, fields map[string]interface{}, ...)
- func (a *Accumulator) BoolField(measurement string, field string) (bool, bool)
- func (a *Accumulator) ClearMetrics()
- func (a *Accumulator) Debug() bool
- func (a *Accumulator) DisablePrecision()
- func (a *Accumulator) FirstError() error
- func (a *Accumulator) FloatField(measurement string, field string) (float64, bool)
- func (a *Accumulator) GatherError(gf func(telegraf.Accumulator) error) error
- func (a *Accumulator) Get(measurement string) (*Metric, bool)
- func (a *Accumulator) HasField(measurement string, field string) bool
- func (a *Accumulator) HasFloatField(measurement string, field string) bool
- func (a *Accumulator) HasInt32Field(measurement string, field string) bool
- func (a *Accumulator) HasInt64Field(measurement string, field string) bool
- func (a *Accumulator) HasIntField(measurement string, field string) bool
- func (a *Accumulator) HasMeasurement(measurement string) bool
- func (a *Accumulator) HasPoint(measurement string, tags map[string]string, fieldKey string, ...) bool
- func (a *Accumulator) HasStringField(measurement string, field string) bool
- func (a *Accumulator) HasTag(measurement string, key string) bool
- func (a *Accumulator) HasTimestamp(measurement string, timestamp time.Time) bool
- func (a *Accumulator) HasUIntField(measurement string, field string) bool
- func (a *Accumulator) Int32Field(measurement string, field string) (int32, bool)
- func (a *Accumulator) Int64Field(measurement string, field string) (int64, bool)
- func (a *Accumulator) IntField(measurement string, field string) (int, bool)
- func (a *Accumulator) NFields() int
- func (a *Accumulator) NMetrics() uint64
- func (a *Accumulator) SetDebug(debug bool)
- func (a *Accumulator) SetPrecision(precision, interval time.Duration)
- func (a *Accumulator) StringField(measurement string, field string) (string, bool)
- func (a *Accumulator) TagValue(measurement string, key string) string
- func (a *Accumulator) Uint64Field(measurement string, field string) (uint64, bool)
- func (a *Accumulator) Wait(n int)
- func (a *Accumulator) WaitError(n int)
- type Metric
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLocalHost ¶
func GetLocalHost() string
GetLocalHost returns the DOCKER_HOST environment variable, parsing out any scheme or ports so that only the IP address is returned.
func MockMetrics ¶
MockMetrics returns a mock []telegraf.Metric object for using in unit tests of telegraf output sinks.
func MustMetric ¶
func MustMetric( name string, tags map[string]string, fields map[string]interface{}, tm time.Time, tp ...telegraf.ValueType, ) telegraf.Metric
Metric creates a new metric or panics on error.
func RequireMetricsEqual ¶
func TestMetric ¶
TestMetric Returns a simple test point:
measurement -> "test1" or name tags -> "tag1":"value1" value -> value time -> time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)
Types ¶
type Accumulator ¶
type Accumulator struct { sync.Mutex *sync.Cond Metrics []*Metric Discard bool Errors []error // contains filtered or unexported fields }
Accumulator defines a mocked out accumulator
func (*Accumulator) AddCounter ¶
func (*Accumulator) AddError ¶
func (a *Accumulator) AddError(err error)
AddError appends the given error to Accumulator.Errors.
func (*Accumulator) AddFields ¶
func (a *Accumulator) AddFields( measurement string, fields map[string]interface{}, tags map[string]string, timestamp ...time.Time, )
AddFields adds a measurement point with a specified timestamp.
func (*Accumulator) AddHistogram ¶
func (*Accumulator) AddMetrics ¶
func (a *Accumulator) AddMetrics(metrics []telegraf.Metric)
func (*Accumulator) AddSummary ¶
func (*Accumulator) AssertContainsFields ¶
func (a *Accumulator) AssertContainsFields( t *testing.T, measurement string, fields map[string]interface{}, )
func (*Accumulator) AssertContainsTaggedFields ¶
func (*Accumulator) AssertDoesNotContainMeasurement ¶
func (a *Accumulator) AssertDoesNotContainMeasurement(t *testing.T, measurement string)
func (*Accumulator) AssertDoesNotContainsTaggedFields ¶
func (*Accumulator) BoolField ¶
func (a *Accumulator) BoolField(measurement string, field string) (bool, bool)
BoolField returns the bool value of the given measurement and field or false.
func (*Accumulator) ClearMetrics ¶
func (a *Accumulator) ClearMetrics()
func (*Accumulator) Debug ¶
func (a *Accumulator) Debug() bool
func (*Accumulator) DisablePrecision ¶
func (a *Accumulator) DisablePrecision()
func (*Accumulator) FirstError ¶
func (a *Accumulator) FirstError() error
func (*Accumulator) FloatField ¶
func (a *Accumulator) FloatField(measurement string, field string) (float64, bool)
FloatField returns the float64 value of the given measurement and field or false.
func (*Accumulator) GatherError ¶
func (a *Accumulator) GatherError(gf func(telegraf.Accumulator) error) error
Calls the given Gather function and returns the first error found.
func (*Accumulator) Get ¶
func (a *Accumulator) Get(measurement string) (*Metric, bool)
Get gets the specified measurement point from the accumulator
func (*Accumulator) HasField ¶
func (a *Accumulator) HasField(measurement string, field string) bool
HasField returns true if the given measurement has a field with the given name
func (*Accumulator) HasFloatField ¶
func (a *Accumulator) HasFloatField(measurement string, field string) bool
HasFloatField returns true if the given measurement has a float value
func (*Accumulator) HasInt32Field ¶
func (a *Accumulator) HasInt32Field(measurement string, field string) bool
HasInt32Field returns true if the measurement has an Int value
func (*Accumulator) HasInt64Field ¶
func (a *Accumulator) HasInt64Field(measurement string, field string) bool
HasInt64Field returns true if the measurement has an Int64 value
func (*Accumulator) HasIntField ¶
func (a *Accumulator) HasIntField(measurement string, field string) bool
HasIntField returns true if the measurement has an Int value
func (*Accumulator) HasMeasurement ¶
func (a *Accumulator) HasMeasurement(measurement string) bool
HasMeasurement returns true if the accumulator has a measurement with the given name
func (*Accumulator) HasStringField ¶
func (a *Accumulator) HasStringField(measurement string, field string) bool
HasStringField returns true if the measurement has an String value
func (*Accumulator) HasTimestamp ¶
func (a *Accumulator) HasTimestamp(measurement string, timestamp time.Time) bool
HasTimestamp returns true if the measurement has a matching Time value
func (*Accumulator) HasUIntField ¶
func (a *Accumulator) HasUIntField(measurement string, field string) bool
HasUIntField returns true if the measurement has a UInt value
func (*Accumulator) Int32Field ¶
func (a *Accumulator) Int32Field(measurement string, field string) (int32, bool)
Int32Field returns the int32 value of the given measurement and field or false.
func (*Accumulator) Int64Field ¶
func (a *Accumulator) Int64Field(measurement string, field string) (int64, bool)
Int64Field returns the int64 value of the given measurement and field or false.
func (*Accumulator) IntField ¶
func (a *Accumulator) IntField(measurement string, field string) (int, bool)
IntField returns the int value of the given measurement and field or false.
func (*Accumulator) NFields ¶
func (a *Accumulator) NFields() int
NFields returns the total number of fields in the accumulator, across all measurements
func (*Accumulator) NMetrics ¶
func (a *Accumulator) NMetrics() uint64
func (*Accumulator) SetDebug ¶
func (a *Accumulator) SetDebug(debug bool)
func (*Accumulator) SetPrecision ¶
func (a *Accumulator) SetPrecision(precision, interval time.Duration)
func (*Accumulator) StringField ¶
func (a *Accumulator) StringField(measurement string, field string) (string, bool)
StringField returns the string value of the given measurement and field or false.
func (*Accumulator) TagValue ¶
func (a *Accumulator) TagValue(measurement string, key string) string
func (*Accumulator) Uint64Field ¶
func (a *Accumulator) Uint64Field(measurement string, field string) (uint64, bool)
Uint64Field returns the int64 value of the given measurement and field or false.
func (*Accumulator) Wait ¶
func (a *Accumulator) Wait(n int)
Wait waits for the given number of metrics to be added to the accumulator.
func (*Accumulator) WaitError ¶
func (a *Accumulator) WaitError(n int)
WaitError waits for the given number of errors to be added to the accumulator.